I want to have a gradient with rainbow colors.
I have numeric values, the maximum value is the color Red, and minimum value is the color Blue.
I try to find an algorithm to have proportional colors, i.e the half will be Green, between half and max will be Yellow or Orange….
I begin with this : Get color value from numeric values
But my function is not correct, if someone can help me… I try with HSV, RGB … But I am more WebDesigner than Developper..
Thanks !
EDIT —————–
This help ! Thanks a lot, I was sure that Value must be variable, but only with the Hue I get the right thing…
$h = ($value * 360) / $max;
$color = HSV_TO_RGB($h / 360, 1, 1);
First time, I forgot to divide by 360 to have a value between 0-1… I am an idiot. The HSV_TO_RGB function can be easily found on Web (hsv to rgb php in Google).
I get the right colors now, using a boucle.
Thanks a lot.
Basicaly what you will need is a HSV to RGB function with fixed Value and Saturation (let’s say 100 for saturation and value) and only change the Hue between 0 (your min value) and 360 (your max value).
You can find many hsv2rgb php implementation over the network and i think that should do the trick.
hope this help