I am creating an application in win32 api, which will use a progress bar. This progress bar, should change its color. From red (left end) to green(right), and in the middle some yellow.
I searched a little, and found out, that I should use HSV to achieve this. I just don't know how? I found in this link, two functions, to convert the color, from RGB to HSV and back.
But what should I do if the color has been converted to HSV?
Best How To :
HSV coordinates define a point in a three dimensional space.
You may find a trajectory form one point (x0, one color) to the second (x1) with a formula like:
x = x0 + alpha * (x1-x0)
with alpha varying form 0.0 to 1.0
You can do this for all three components simultaneaously.
With a trajectory from green to red in HSV space you will mainly modify the H (Hue) value. If you want to see some yellow in the middle of your path (and not violett) you need to define a second or even third color and walk
green -> yellow -> red
int hue0 = 0; // red
int hue2 = 120; // green
// find 100 colors between red and green
for(double alpha = 0; alpha <= 1.0; alpha += 0.01)
hueX = hue0 + alpha * (hue1 - hue0);
// same for value, saturation:
// valX = val0 + alpha * (val1 - val0)
// plot this color