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

[css-color-4] rgb-to-hsl source code produced hue NaN when rgb values are equal #8304

Closed
shuai-z opened this issue Jan 12, 2023 · 1 comment

Comments

@shuai-z
Copy link

shuai-z commented Jan 12, 2023

The souce code in Converting sRGB Colors to HSL (or file css-color-4/rgbToHsl.js) produced hue as NaN when max equals to min. it should be 0 in this case.

@svgeesus
Copy link
Contributor

Yes, this is as expected. The hue is powerless, which is represented in CSS with the keyword none and in code with the value NaN.

For example, in hsl(), the hue component is powerless when the saturation component is 0%; a 0% saturation indicates a grayscale color, which has no hue at all, so 0deg and 180deg, or any other angle, will give the exact same result.

If such a color value is converted to another color space, the value 0 will be used for the missing value. However, if two colors are interpolated and one has a missing value while the other has a valid value for an analogous component, then the missing value is taken from that second color.

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

No branches or pull requests

2 participants