Museum of modern art
Posted: Mon Jan 28, 2019 12:22 pm
The byte magazine of december 1986 was about computer graphics. It contained an article about cellular automata. The technique is interesting. If you google on "Byte magazine", you will find a website where nearly all Byte magazines may be downloaded. They fit nicely in "iBooks".
I used the technique in a stand-alone program, of which a will post a second version soon. I also made a little function wich does generate interesting patterns, based on the technique. This function may be called from an app as kind of a gadget. You have to use an additional button in the calling program. Placement and size are free, because upon terminating the function, the original background of the screen is restored.
The code:
I used the technique in a stand-alone program, of which a will post a second version soon. I also made a little function wich does generate interesting patterns, based on the technique. This function may be called from an app as kind of a gadget. You have to use an additional button in the calling program. Placement and size are free, because upon terminating the function, the original background of the screen is restored.
The code:
Code: Select all
' test program to show "museum" gadget
'
graphics ! graphics clear .8,.8,.8
button "mus" text "Museum visit" at 600,40 size 120,30
draw color 0,0,1 ! draw size 2
for s=20 to 500 step 20
draw line s,20 to s,500 ! draw line 20,s to 500,s
next s
draw text "To stop, touch the button again" at 20,550
do ! slowdown ! until button_pressed("mus")
art(100,100,300,200,1,"mus")
end
' museum of modern art, free tour along the paintings
' graphics mode assumed
' x,y,w,h are position and size of the paintings
' p is admiration time in seconds for each painting
' button$ is the name of the button in the calling app
' that is used to activate the function
' press the button again to stop and to restore
' the original background of the app
'
def art(x,y,w,h,p,button$)
refresh off ! draw color .5,.5,.5
w-=odd(w) ! t=6 ! npx=w/2-t ! npy=h/2-t
xs=x+t/3-1 ! ys=y+t/3-1 ! toggle=0
dim va(npx+2),vb(npx+2),r(11)
sprite "bg" scan x-t/2,y-t/2,w,h
draw size t ! draw rect x,y to x+w-t-1,y+h-t ! randomize
do
for i=1 to 10 ! r(i)=rnd(4) ! next i
for i=1 to npx ! va(i)=rnd(4) ! next i
for k=0 to npy ! yy=ys+2*k+2
for i=1 to npx
if toggle=0 then ! s=r(va(i-1)+va(i)+va(i+1)) ! vb(i)=s
else ! s=r(vb(i-1)+vb(i)+vb(i+1)) ! va(i)=s
end if
if s=0 then fill color 0,0,0 ! if s=1 then fill color 1,0,0
if s=2 then fill color 0,1,0 ! if s=3 then fill color 0,0,1
xx=xs+2*i ! fill rect xx,yy to xx+1,yy+1
next i ! toggle=1-toggle
next k ! refresh ! pause p
until button_pressed(button$)
refresh on
sprite "bg" at x-t/2,y-t/2 ! sprite "bg" stamp
end def