smoothly cycling through all colours
BlitzMax Forums/BlitzMax Beginners Area/smoothly cycling through all colours
| ||
i can't work out how to smoothly cycle through all the colours, anyone got any tips/sample code? Cheers Charlie |
| ||
All 255 * 255 * 255 colours, or a selection of those? :-) |
| ||
Get yourself a comfy chair (or change the step value)... p.s. or did you mean some move from blues through greens through reds? |
| ||
i guess after tony's sample i mean just a selection. so maybe move from blues through greens through reds. Cheers Charlie |
| ||
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. |
| ||
@imaginary human, that sound like what i'm after. Cheers Charlie |
| ||
http://www.blitzmax.com/codearcs/codearcs.php?code=1380 http://www.blitzmax.com/codearcs/codearcs.php?code=2333 Hue shifting. |
| ||
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. |