REM ***********************************************
REM Title: 2D Convex Polygon
REM Author: Phaelax
REM Downloaded from: http://dbcc.zimnox.com/
REM ***********************************************
 
sync on
sync rate 60
 
do
   cls
   a#=wrapvalue(a#+1)
   DrawPolyCircle(300,200,150,7,a#)
   sync
loop
 
REM =====================================
REM Draw polygon with center at [x,y] and
REM a radius of 'r' with 'segs' number of
REM segments and rotated at 'Rot#' angle
REM =====================================
Function DrawPolyCircle(x,y,r,segs,Rot#)
   AngStep# = 360.0 / segs
   Ang# = Rot#
   For s = 1 To segs
      OldAng# = Ang#
      Ang# = Ang# + AngStep#
      x1 = x + (r * Sin(Ang#))
      y1 = y + (r * Cos(Ang#))
      x2 = x + (r * Sin(OldAng#))
      y2 = y + (r * Cos(OldAng#))
      Line x1,y1,x2,y2
   Next s
EndFunction