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

OkHSL/OkHSV does not use NaN for hue-less colors #516

Closed
KeyboardDanni opened this issue May 16, 2024 · 5 comments · Fixed by #517
Closed

OkHSL/OkHSV does not use NaN for hue-less colors #516

KeyboardDanni opened this issue May 16, 2024 · 5 comments · Fixed by #517
Milestone

Comments

@KeyboardDanni
Copy link

The OkHSL/OkHSV spaces do not seem to use NaN for hue in their conversions, unlike other colorspaces such as HSL/HSV and LCH/OkLCH. One side effect of this is that interpolation from srgb(0.0, 0.0, 1.0) to srgb(1.0, 1.0, 1.0) produces incorrect results:

2024-05-16 15_03_29-Palettejuicer

The top strip is lerping over OkLCH, and the middle and bottom ones are using OkHSV and OkHSL, respectively. Because srgb(1.0, 1.0, 1.0) isn't converting to a hue of NaN, OkHSV and OkHSL are incorrectly blending their hues toward 0.

Reproduction:

const white = { space: "srgb", coords: [1.0, 1.0, 1.0] };

const whiteOklch = to(white, "oklch"); // [ 1.0000000000000002, 4.996003610813204e-16, NaN ]
const whiteOkhsl = to(white, "okhsl"); // [ 180, 0.6519721306444567, 1.0000000000000002 ]
const whiteOkhsv = to(white, "okhsv"); // [ 180, 1.3189507366749435e-15, 1.0000000000000007 ]
@facelessuser
Copy link
Collaborator

Ugh, that was my fault as I implemented the spaces. I'll get a fix up.

@facelessuser
Copy link
Collaborator

I've linked a PR that should fix the issue.

facelessuser added a commit to facelessuser/color.js that referenced this issue May 16, 2024
@svgeesus
Copy link
Member

Fixed by facelessuser@af37eb5

@KeyboardDanni
Copy link
Author

Too soon to close? That's the upstream, which doesn't seem to have been merged yet.

@LeaVerou
Copy link
Member

Nah, we close when fixes are merged, not when the version with them is released.

@LeaVerou LeaVerou added this to the v0.6.0 milestone May 27, 2024
facelessuser added a commit to facelessuser/color.js that referenced this issue May 28, 2024
facelessuser added a commit that referenced this issue May 29, 2024
)

* Ensure Okhsl and Okhsv return undefined hues for achromatic colors

Fixes #516

* Provide variables for epsilon values

* Update to use null and rework Okhsl saturation handling
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

Successfully merging a pull request may close this issue.

4 participants