Dark Bit Factory & Gravity

PROGRAMMING => Other languages => Yabasic => Topic started by: bikemadness on August 24, 2007

Title: small system control sample
Post by: bikemadness on August 24, 2007
I've always liked adjustment controls and this one turned into a great exercise.

I fully-controlled the doily program, with a display.

Code: [Select]
open window 640,512
ang=pi/180
x=400
y=260
sel1=1
sel2=1
dim title$(7)
for b=1 to 7
read title$(b)
next b
dim instruction$(15)
for b=1 to 15
read instruction$(b)
next b
doilys=10
dim points(doilys),dir(doilys),gap(doilys)
dim ra(doilys),r(doilys),g(doilys),b(doilys) 
for c=1 to doilys   
points(c)=doilys+13-c 
dir(c)=360/points(c)
gap(c)=int(points(c)/2)+1 
ra(c)=250-(c*20) 
r(c)=200 
g(c)=200 
b(c)=200 
next c
repeat
setdrawbuf vm
vm=1-vm
setdispbuf vm
clear window
setrgb 1,200,200,0
fill rectangle 0,0 to 160,640
setrgb 1,0,0,0
line 10,275 to 130,275
triangle 41,390 to 55,390 to 48,377
line 105,380 to 115,390
line 115,380 to 105,390
rectangle 127,409 to 141,423
circle 38,467,7
setrgb 1,0,0,0
for b=1 to 7
text 10,b*30+30,title$(b)
next b
setrgb 1,80,80,80
for b=1 to 15
text 0,b*17+251,instruction$(b)
next b
d=peek("port1")
go=go+1
if go>10 go=10
if and(d,16)>0 and go=10 then
sel1=sel1-1
go=0
endif
if and(d,64)>0 and go=10 then
sel1=sel1+1
go=0
endif
if sel1<1 sel1=1
if sel1>6 sel1=6
setrgb 1,0,100,0
text 80,sel1*30+30,"<"
rectangle 78,sel1*30+20 to 93,sel1*30+35
if and(d,128)>0 and go=10 then
sel2=sel2-1
go=0
endif
if and(d,32)>0 and go=10 then
sel2=sel2+1
go=0
endif
if sel2<1 sel2=1
if sel2>doilys sel2=doilys
if and(d,32768)>0 and go=10 then
doilys=doilys-1
go=0
endif
if and(d,8192)>0 and go=10 then
doilys=doilys+1
go=0
endif
if doilys<1 doilys=1
if doilys>10 doilys=10
setrgb 1,0,0,0
text 55,20,"doilys:"+str$(doilys)
for c=1 to doilys
setrgb 1,0,0,0   
if sel2=c then
text 65,40,"doily#"+str$(c)
text 100,60,str$(points(c))
text 100,90,str$(gap(c))
text 100,120,str$(ra(c))
text 100,150,str$(r(c))
text 100,180,str$(g(c))
text 100,210,str$(b(c))
setrgb 1,r(c),g(c),b(c)
fill rectangle 100,225 to 120,245
setrgb 1,0,0,0
rectangle 100,225 to 120,245
endif
if and(d,4096)>0 and sel2=c and sel1=1 and go=10 then
points(sel2)=points(sel2)+1
go=0
endif
if and(d,16384)>0 and sel2=c and sel1=1 and go=10 then
points(sel2)=points(sel2)-1
go=0
endif
if points(sel2)<gap(sel2)*2+1 points(sel2)=gap(sel2)*2+1
if points(sel2)>40 points(sel2)=40
if and(d,4096)>0 and sel2=c and sel1=2 and go=10 then
gap(sel2)=gap(sel2)+1
go=0
endif
if and(d,16384)>0 and sel2=c and sel1=2 and go=10 then
gap(sel2)=gap(sel2)-1
go=0
endif
if gap(sel2)<1 gap(sel2)=1
if gap(sel2)>points(sel2)/2-1 gap(sel2)=points(sel2)/2-1
if and(d,4096)>0 and sel2=c and sel1=3 ra(sel2)=ra(sel2)+1
if and(d,16384)>0 and sel2=c and sel1=3 ra(sel2)=ra(sel2)-1
if ra(sel2)<40 ra(sel2)=40
if ra(sel2)>250 ra(sel2)=250
if and(d,4096)>0 and sel2=c and sel1=4 r(sel2)=r(sel2)+1
if and(d,16384)>0 and sel2=c and sel1=4 r(sel2)=r(sel2)-1
if r(sel2)<0 r(sel2)=0
if r(sel2)>256 r(sel2)=256
if and(d,4096)>0 and sel2=c and sel1=5 g(sel2)=g(sel2)+1
if and(d,16384)>0 and sel2=c and sel1=5 g(sel2)=g(sel2)-1
if g(sel2)<0 g(sel2)=0
if g(sel2)>256 g(sel2)=256
if and(d,4096)>0 and sel2=c and sel1=6 b(sel2)=b(sel2)+1
if and(d,16384)>0 and sel2=c and sel1=6 b(sel2)=b(sel2)-1
if b(sel2)<0 b(sel2)=0
if b(sel2)>256 b(sel2)=256
if and(d,1024)>0 then
points(c)=int(ran(37))+3
gap(c)=int(ran(points(c)/2))+1
ra(c)=int(ran(200))+50
r(c)=int(ran(256))
g(c)=int(ran(256))
b(c)=int(ran(256))
endif
dir(c)=360/points(c)
setrgb 1,r(c),g(c),b(c)
for a=1 to points(c)
line cos(dir(c)*a*ang)*ra(c)+x,sin(dir(c)*a*ang)*ra(c)+y to cos(dir(c)*(a+gap(c))*ang)*ra(c)+x,sin(dir(c)*(a+gap(c))*ang)*ra(c)+y
next a
next c
until (1=0)
data "points","  gaps","radius"," col-R"," col-G"," col-B","RGBmix"
data " instructions","Use L/R to see","plot-points of"
data "each doily.","Use U/D to high","-light a doily"
data "plot-point. ","Use   and   to","alter the plot-"
data "points. Use","to decrease the","number of doilys"
data "or   to add them","back.","L1 to random"

Have a Yahappy day.
Title: Re: small system control sample
Post by: rain_storm on August 24, 2007
Sweet I would like to put one of these together for myself I never tried generating patterns using parameters that can be altered (but not have it ruin the pattern). You pulled it off nicely here i must say
Title: Re: small system control sample
Post by: Clanky on August 25, 2007
Very Nice!!!

K+