During the past weeks, I have been attempting to grasp the basics of procedural methods for such tasks as creating media content.
As an experiment I wrote the following procedure; it draws a perfect 2D polygon with any number of sides (at least three of course).
sw= 1024 : sh= 768
set display mode sw,sh,32
sync on
d= 200 : 'diameter of base circle
white= rgb(255,255,255)
grey= rgb(64,64,64)
Do
For sides= 3 to 9
For rot= 0 to 360
ink grey,0
circle sw/2,sh/2,d
ink white,0
Shape(sw/2,sh/2,sides,d,rot)
sync : cls
next rot
next sides
Loop
Function Shape(x,y,sides,d,rot)
for i= 0 to sides-1
ang= (360/sides)*i +rot
xa= sin(ang)*d +x
ya= cos(ang)*d +y
ang= (360/sides)*(i+1) +rot
xb= sin(ang)*d +x
yb= cos(ang)*d +y
line xa,ya,xb,yb
next i
Endfunction
I am using a PS3 controller to enter this so excuse me for not compressing my code to 20 lines.
I'm not using DB at the moment and so there may be some errors.