Author Topic: Random Colour Chart  (Read 2163 times)

0 Members and 1 Guest are viewing this topic.

Offline bikemadness

  • Amiga 1200
  • ****
  • Posts: 319
  • Karma: 25
  • Hard players don't go home.
    • View Profile
Random Colour Chart
« on: January 27, 2014 »
Here's something I needed, from my early days.
Down, D-pad to change.

Code: [Select]
open window 640,512
nos=15 rem squares, x-axis
row=nos*.8
boxx=640/nos
boxy=510/row
dim r(nos,row)
dim g(nos,row)
dim b(nos,row)
dim x(nos)
dim y(row)
for c=1 to row
for a=1 to nos
r(a,c)=int(ran(256))
g(a,c)=int(ran(256))
b(a,c)=int(ran(256))
x(a)=a*boxx-(boxx/2)
y(c)=c*boxy-(boxy/2)
next a
next c
repeat
setdrawbuf vm
vm=1-vm
setdispbuf vm
clear window
c=peek("port1")
go=go+1
if go>10 go=10
if go>2 off=0
if and(c,64)>0 and go=10 then
go=1
if go<3 off=1
endif
for c=1 to row
for a=1 to nos
if off=1 then
r(a,c)=int(ran(256))
g(a,c)=int(ran(256))
b(a,c)=int(ran(256))
endif
setrgb 1,r(a,c),g(a,c),b(a,c)
fill rectangle x(a)-(boxx/2),y(c)-(boxy/2) to x(a)+(boxx/2),y(c)+(boxy/2)
setrgb 1,256,256,256
text x(a)-15,y(c)-9,str$(r(a,c))
text x(a)-15,y(c)+3,str$(g(a,c))
text x(a)-15,y(c)+15,str$(b(a,c))
next a
next c
until (1=0)
Have a Yahappy day.
I don't know what is wrong with the world - but I know how to fix it.