Jump to content


Photo

Drawing a star with outline and fill at any angle


  • Please log in to reply
No replies to this topic

#1 Cipher Diaz

Cipher Diaz
  • Administrators
  • 313 posts

Posted 01 February 2013 - 07:51 PM

 procedure drawStar(const aCanvas:TW3Canvas; 
           center_x, 
           center_y, 
           aRadius, 
           aCoreSize, 
           aAngle:float; 
           aPoints:integer; 
           aOutlineColor, 
           aFillColor:TColor); 
 var 
   angle: float; 
   i:  Integer; 
   rr: float; 
   px,py:  float; 
 Begin 
   angle:=PI/aPoints; 
   
   aCanvas.strokestyle:=ColorToWebStr(aOutLineColor); 
   aCanvas.fillstyle:=ColorToWebStr(aFillColor); 
   acanvas.lineWidth:=8; 
   aCanvas.beginpath; 
   
   for i:=0 to (aPoints*2)-1 do 
   Begin 
     if (i and 1)=0  then 
     rr:=aRadius else 
     rr:=aCoreSize; 
   
     px:= center_x + cos ( i * angle - pi/2 + aAngle) * rr; 
     py:= center_y + sin ( i * angle - PI/2 + aAngle) * rr; 
     if i=0 then 
     aCanvas.movetoF(px,py) else 
     aCanvas.linetoF(px,py); 
   end; 
   
   acanvas.closepath; 
   aCanvas.fill; 
   aCanvas.stroke; 
 end; 





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users