smoothly cycling through all colours

BlitzMax Forums/BlitzMax Beginners Area/smoothly cycling through all colours

jkrankie(Posted 2009) [#1]
i can't work out how to smoothly cycle through all the colours, anyone got any tips/sample code?

Cheers
Charlie


Brucey(Posted 2009) [#2]
All 255 * 255 * 255 colours, or a selection of those? :-)


tonyg(Posted 2009) [#3]
Get yourself a comfy chair (or change the step value)...


p.s. or did you mean some move from blues through greens through reds?


jkrankie(Posted 2009) [#4]
i guess after tony's sample i mean just a selection. so maybe move from blues through greens through reds.

Cheers
Charlie


ImaginaryHuman(Posted 2009) [#5]
One way that you can kind of emulate a hue shift, is to start out with red ie $FF0000. Then gradually increase the green component until $FFFF00. Then decrease the red component back down to 0 ie $00FF00. Then raise the blue component to $00FFFF. Then decrease green ie $0000FF. Then increase red to $FF00FF. Then decrease blue back to red $FF0000. This lets you cycle through RED-orange-YELLOW-GREEN-cyan-BLUE-indigo-VIOLET(magneta)-RED in a kind of linear fashion without having to convert to a HSB color model.


jkrankie(Posted 2009) [#6]
@imaginary human, that sound like what i'm after.

Cheers
Charlie


Beaker(Posted 2009) [#7]
http://www.blitzmax.com/codearcs/codearcs.php?code=1380
http://www.blitzmax.com/codearcs/codearcs.php?code=2333

Hue shifting.


ImaginaryHuman(Posted 2009) [#8]
Yah you dont wanna do real hue shifting unless you have to, it requires conversion of colorspaces. If you don't need varying levels of saturation or value then you can just use the above technique to change the color.

So, since you have 6 phases of color change, and there are 256 levels of change in each phase, you have 6*256=1536 total steps. You can check if the (counter mod 256=255) to decide when to switch to changing a different component. Even if you change one step per frame, it'll take 25 seconds to go all the way through back to red.