Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HSV to int mapping documentation #24

Open
TiMESPLiNTER opened this issue Apr 15, 2022 · 1 comment
Open

HSV to int mapping documentation #24

TiMESPLiNTER opened this issue Apr 15, 2022 · 1 comment

Comments

@TiMESPLiNTER
Copy link

TiMESPLiNTER commented Apr 15, 2022

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.

@TiMESPLiNTER
Copy link
Author

TiMESPLiNTER commented Apr 15, 2022

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant