Hi there,
a while back I was looking for a way to make a transition between multiple colors. Thread:
http://en.sfml-dev.org/forums/index.php?topic=7996.msg54612 The other day I picked the project up again and I came up with the following solution: Changing the hue over time and then calculating the RGB from that. I implemented the following code:
hue += 0.5 * fTime;
if(hue > 1.0)
hue = 0.0;
float r = abs(3.0 - 6.0 * hue) - 1.0;
float g = 2.0 - abs(2.0 - 6.0 * hue);
float b = 2.0 - abs(4.0 - 6.0 * hue);
color = sf::Color(CLAMP(r, 0.f, 1.f) * 255.f, CLAMP(g, 0.f, 1.f) * 255.f, CLAMP(b, 0.f, 1.f) * 255.f);
I doesn't give the results i expected though... The transitions are choppy and not all colors are shown. It looks like this:
I don't really know why. The calculation seem to be right. Does anybody know what's wrong?