I would like to generate color according to value from -1 to 1
the base colors are
My gaps are H:0 =1, H:60 = 0.5 , H:170= 0, H:200= -1 ( S:100 and L:50 )
I have found an example that convert percentage from green to red.
function percentageToColor(percentage, maxHue = 200, minHue = 0) {
const hue = percentage * (maxHue - minHue) + minHue;
return `hsl(${hue}, 100%, 50%)`;
}
I would like to adapt it to my case by adding blue and use values from -1 to 1 by respecting the gaps equivalences as I mentioned above but I don't see how to do it.
Upate
I would like to use HSL/HSV
I'm looking for a way to find relation between percentage and H
value