I am using SFML and it has a color function that takes values in RGB. example.. (255,0,0). I would like to be able to cycle these numbers though a loop so that the displayed colour cycles though the hue…
So if I am using (76,204,63) the function will adjust those 3 numbers. So I need the function to intake rgb convert to HSV and then return rgb.
Any ideas how I would go about this?
the sfml code I wish to use is…
_sprite.setColor(76,204,63); This will set the sprite to a colour… I ma trying to work out how once that is done with those numbers to cycle the colour though the hue.
With a bit googling I’ve found this answer and converted the code to C++ with SFML in mind.
I’m casting around pretty badly, so feel free to make it better. I guess it should even be possible to replace the 3×3 array.
Edit: Removed unnecessary casts.
Edit: Got rid of the matrix.
Edit: As I’ve noticed the code doesn’t really work as wanted, but here’s a hardcoded solution that works perfectly, just isn’t that compact and nice.