HSV to int mapping documentation
Opened this issue · 1 comments
To set the color of a light, the documentation currently states:
Set the color hue of the light. The hue parameter in the HSV color model is between 0°–360° and is mapped to 0–65535 to get 16-bit resolution.
However, it's completely unclear to me, how to come from the three values h, s and v to this integer value. I tried to calculate it like this: round(h * 65535 / 360)
however this only produces white light. I guess I need to combine the three values together and somehow map it into the 0–65535 range.
Maybe an example in the documentation how to come from H, S and V to this integer value would help to understand it better.
Okay, now it's working with round(h * 65535 / 360)
. Don't know what I did wrong. In Javascript:
var hue = Math.round(colorHsv.h * 65535 / 360); // hue is 0-360 degrees, needs to be expressed between 0-65535
var sat = Math.round(colorHsv.s * 255 / 100); // saturation is 0-100%, needs to be expressed between 0-255
Is this the correct way to do it? What to do with v
?