_TITLE "Basic Polygon" 'b+ 2020-08-27
' a circle is 360 degree
' a polygon of n side has central angles = 360 / n > think of a pie the central angle are the angle of slices in center
xC
= _WIDTH / 2 ' middle of screenr = 200 ' radius = less than half screen height
FOR n
= 3 TO 12 ' n = number of sides CIRCLE (xC
, yC
), r
' here is our pie, Apple or Pepperroni :-)) FOR angle
= 0 TO 360 STEP 360 / n
' step the size of pie angles ' let xC, yC be the coordinates at the center of the pie circle
' let r be the radius of the pie
' then the n outside points are
x
= xC
+ r
* COS(_D2R(angle
)) ' x coordinate of outer edge point y
= yC
+ r
* SIN(_D2R(angle
)) ' y coordinate of outer edge point LINE (xC
, yC
)-(x
, y
) ' slice from center of pie to outer edge PRINT "press any to see next polygon up to 12..."