Code: Select all
graphics ! graphics clear .8,.8,.8 ! draw color 0,0,0
get screen size sw,sh
m=15 ! w=floor((sw-3*m)/2) ! h=floor((sh-3*m)/2)
draw text "touch any pict to change it" at 10,300 ! pause 2
graphics clear .8,.8,.8
for k=1 to 4
art(m+(w+m)*even(k),m+(h+m)*floor(k/2.1),w,h)
next k
while(1)
art(m+(w+m)*even(k),m+(h+m)*floor(k/2.1),w,h)
do slowdown
get touch 0 as x,y ! if x=-1 then continue
k=floor(2*x/sw)+2*floor(2*y/sh)+1 ! break
until forever
end while
end
' generated picture
' graphics mode assumed
' x,y,w,h are position and size of the picture
'
def art(x,y,w,h)
if not init then ! randomize ! init=1 ! end if
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)
draw size t ! draw rect x,y to x+w-t-1,y+h-t
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,1
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
' fill color bit(s,0),bit(s,1),bit(s,2)
xx=xs+2*i ! fill rect xx,yy to xx+1,yy+1
next i ! toggle=1-toggle
next k
refresh
end def