Dark Bit Factory & Gravity
PROGRAMMING => Other languages => Yabasic => Topic started by: bikemadness on January 27, 2014
-
Another from the archives. Down, D-pad to change.
open window 640,512
ang=pi/180
points=30
skip=int(ran(points-1)/2)+1
radius=int(ran(75))+100
dim r(points)
dim g(points)
dim b(points)
for point=1 to points
r(point)=ran(256)
g(point)=ran(256)
b(point)=ran(256)
next point
x=320
y=256
repeat
setdrawbuf vm
vm=1-vm
setdispbuf vm
clear window
go=go+1
if go>10 go=10
c=peek("port1")
if and(c,16384)>0 and go=10 then
go=1
points=int(ran(27))+3
skip=int(ran(points/2))+1
radius=int(ran(75))+100
for point=1 to points
r(point)=ran(256)
g(point)=ran(256)
b(point)=ran(256)
next point
endif
for point=1 to points
dir=360/points
x1=cos(dir*ang*point)*radius+x
y1=sin(dir*ang*point)*radius+y
x2=cos(dir*ang*(point+skip))*radius+x
y2=sin(dir*ang*(point+skip))*radius+y
setrgb 1,r(point),g(point),b(point)
line x1,y1 to x2,y2
next point
setrgb 1,256,256,256
text 20,20," points used: "+str$(points)
text 20,40,"points skipped: "+str$(skip)
text 20,60," diameter: "+str$(radius)
if skip=1 then
text 250,radius+y+40,str$(points)+" sided polygon "
if points=3 text 410,radius+y+40,"(triangle)"
if points=4 text 410,radius+y+40,"(square)"
if points=5 text 410,radius+y+40,"(pentagon)"
if points=6 text 400,radius+y+40,"(hexagon)"
if points=7 text 400,radius+y+40,"(septagon)"
if points=8 text 400,radius+y+40,"(octagon)"
if points=9 text 400,radius+y+40,"(nonagon)"
endif
if skip>1text 250,radius+y+40,str$(points)+" point star"
until (1=0)