Hello everyone,
I've been experimenting with colour gradients.
When I made gradients with only three or four shades I wasn't happy with how the colours looked, the first few colours looked too similar. I think this is just the way we perceive differences in colour, the brighter colours are the more easily we can distinguish between them.
Anyway, I made a gradient using SIN and I think it looks much more balanced to the eye. Here are lots of gradients, the first line is normal gradient and the second line is sine gradient.
rem Colour Blending
rem by OBese87
rem 10th June 2010
set display mode 1024,768,32
hide mouse
sync on
sync rate 0
max = 1022
f# = 90/(max+.0) :rem used in sine blending
LF# = 255/(max+.0) :rem used in linear blending
xsize = 1023/(max+1.0)
ysize = 31
y=0
rem === MAIN ===
for gradient = 1 to 12
for blend = 0 to 1
for x = 0 to max
rem First line is linear blending, second line sine blending.
if blend = 0 then g = x*LF# else g = sin(x*f#)*255
rem set colour according to gradient rules
select gradient
`red to white
case 1 : ink rgb(255,g,g),0 : endcase
`yellow to white
case 2 : ink rgb(255,255,g),0 : endcase
`green to white
case 3 : ink rgb(g,255,g),0 : endcase
`cyan to white
case 4 : ink rgb(g,255,255),0 : endcase
`blue to white
case 5 : ink rgb(g,g,255),0 : endcase
`magenta to white
case 6 : ink rgb(255,g,255),0 : endcase
`red to yellow
case 7 : ink rgb(255,g,0),0 : endcase
`red to blue
case 8 : ink rgb(255,0,g),0 : endcase
`green to yellow
case 9 : ink rgb(g,255,0),0 : endcase
`green to cyan
case 10 : ink rgb(0,255,g),0 : endcase
`blue to magenta
case 11 : ink rgb(g,0,255),0 : endcase
`blue to cyan
case 12 : ink rgb(0,g,255),0 : endcase
endselect
rem draw swatch
box x*xsize,ysize*y,(x+1)*xsize,ysize*(y+1)
next x
rem move down a line
inc y
next blend
next gradient
sync
wait key
Does it look better to you?
Something else I was wondering is those gradient rules in the select block, is there a way to do away with the select and just use a FOR loop with them? There is a definite pattern to them but I can't work out how I could do it.
The select is a massive improvement on what I had earlier, it was about 300 lines long!
Cheers