Post by tenochtitlanuk on Mar 15, 2020 6:51:04 GMT -5
As shown on the RC Julia set thread, it can be helpful to use colour parameters other than RGB.
This is a morning's worth of play--
The only thing to remember is that hue varies 0 to 360, while saturation and value are between 0 and 0.9999.
Works nicely with LB graphic commands and with LB Bresenham routine ( see RC) you can draw very easily lines from A to B whose colour varies along their length.
Typical code example is..
nomainwin
global pi, col$: pi =3.14158265
WindowWidth =570
WindowHeight =600
UpperLeftX =int( ( DisplayWidth -WindowWidth) /2)
UpperLeftY =int( ( DisplayHeight -WindowHeight) /2)
graphicBox #w.g, 9, 9, 537, 537
open "Ring fade demo" for window as #w
#w "trapClose quit"
#w.g "down; fill darkblue ; goto 267 267"
#w.g "size 2"
for R =1 to 255 step 0.25
call hsv2rgb R, 0.49, 0.79 ' hue, saturation, value
#w.g "color "; col$
#w.g "circle "; R
scan
next R
#w.g "getbmp scr 1 1 537 537"
bmpsave "scr", "ring" +str$( time$( "seconds")) +".bmp"
wait
sub hsv2rgb h, s, v ' hue 0-360, saturation 0-1, value 0-1
c =v *s ' chroma
h =h
x =c *( 1 -abs( ( ( h /60) mod 2) -1))
m =v -c ' matching adjustment
select case
case h < 60
r = c: g = x: b = 0
case h <120
r = x: g = c: b = 0
case h <180
r = 0: g = c: b = x
case h <240
r = 0: g = x: b = c
case h <300
r = x: g = 0: b = c
case else
r = c: g = 0: b = x
end select
rd = abs( int( 256 *( r + m)))
gn = abs( int( 256 *( g + m)))
bu = abs( int( 256 *( b + m)))
col$ =right$( " " +str$( rd), 3) +" " +right$( " " +str$( gn), 3) +" " +right$( " " +str$( bu), 3)
end sub
sub quit handle$
close #w
end
end sub