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

Ensure Okhsl and Okhsv return undefined hues for achromatic colors #517

Merged
merged 3 commits into from
May 29, 2024

Conversation

facelessuser
Copy link
Collaborator

Fixes #516

Copy link

netlify bot commented May 16, 2024

Deploy Preview for colorjs ready!

Name Link
🔨 Latest commit ce85731
🔍 Latest deploy log https://app.netlify.com/sites/colorjs/deploys/665529fa1f2c050008094de3
😎 Deploy Preview https://deploy-preview-517--colorjs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

src/spaces/okhsl.js Outdated Show resolved Hide resolved
Copy link
Member

@LeaVerou LeaVerou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@KeyboardDanni
Copy link

Will need updating due to the switch from NaN to null.

@facelessuser
Copy link
Collaborator Author

Yeah, I was hoping to get in before all that. I'll rebase and update it probably tomorrow if I have time.

@LeaVerou LeaVerou added this to the v0.6.0 milestone May 27, 2024
@LeaVerou
Copy link
Member

@facelessuser let me know if I can help!

@facelessuser
Copy link
Collaborator Author

I've rebased and updated to use null.

Copy link
Member

@LeaVerou LeaVerou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes LGTM, thanks!

As a side comment, these spaces appear to be duplicating a lot of logic that they should ideally import from other spaces, but that shouldn't hold this PR up.

@facelessuser
Copy link
Collaborator Author

@LeaVerou Okhsl and Okhsv is duplicating logic? Which part? Did you mean to comment in the Oklrab PR? I could see the claim that that PR was duplicating code.

@LeaVerou
Copy link
Member

Perhaps it's not exactly duplication, but the conversion of these spaces to/from base is very weird, it seems to be going through sRGB Linear somehow? If so, why not just define sRGB linear as the base?

@facelessuser
Copy link
Collaborator Author

It goes through linear sRGB as that is the gamut the Okhsl and Okhsv space are converting to. This is required to find the cusp of the hue slice of Oklab in relation to linear sRGB. It is specifically part of the conversion algorithm, but the algorithm also requires Oklab to calculate the initial chroma and lightness. That's just how the algorithm works. I need to convert to both Oklab and linear sRGB, I can't just pick one.

If I require the base to be sRGB linear, then I'll also have to convert it to Oklab right away.

@facelessuser
Copy link
Collaborator Author

To be honest, I'm pretty indifferent as to whether the base is Oklab or linear sRGB. If you want the base to be different, I can do it, and instead of having the Oklab to sRGB linear conversion, I'll add the linear sRGB to Oklab conversion. It's all the same to me. It all amounts to pretty much the same thing.

@facelessuser
Copy link
Collaborator Author

For context, the original algorithm did conversion back and forth between llnear sRGB and Oklab, but I've made the initial base Oklab and only require a conversion to sRGB linear, not from, simplifying the code.

@LeaVerou
Copy link
Member

If it needs both color spaces, then I guess up to you.

@facelessuser
Copy link
Collaborator Author

I'll leave it as is unless a specific need arises requiring such a change.

@facelessuser facelessuser merged commit cf5f15e into color-js:main May 29, 2024
4 of 5 checks passed
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 this pull request may close these issues.

OkHSL/OkHSV does not use NaN for hue-less colors
3 participants