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

Implement CSS Color 4 gamut mapping #154

Closed
4 tasks done
svgeesus opened this issue Jun 23, 2022 · 11 comments
Closed
4 tasks done

Implement CSS Color 4 gamut mapping #154

svgeesus opened this issue Jun 23, 2022 · 11 comments
Assignees
Labels
bug Something isn't working enhancement New feature or request spec-parity Parity with the CSS Color specs Topic: Algorithms Issues that relate to the actual color science

Comments

@svgeesus
Copy link
Member

svgeesus commented Jun 23, 2022

Currently, gamut mapping tries to allow any coordinate in any color space to be reduced (including nonsensical ones like hue) and uses deltaE 2000 as a color distance metric.

See also this codepen and this demo

@svgeesus svgeesus self-assigned this Jun 23, 2022
@svgeesus svgeesus added bug Something isn't working enhancement New feature or request Topic: Algorithms Issues that relate to the actual color science labels Jun 23, 2022
@svgeesus
Copy link
Member Author

Does not just affect GM single colors, but also affects smoothness of gradients, see this awful example

@svgeesus
Copy link
Member Author

svgeesus commented Jul 1, 2022

On lab(50% -127 -127) I get starting oklch of
[ 0.42226189321340196, 1.9540778145796625, 191.20237227483153 ]
and after GM I get
[ 0.43100803800138154, 0.0741924017206513, 191.0338159551419 ]

So the chroma is vastly reduced but the hue is very similar.

@svgeesus
Copy link
Member Author

svgeesus commented Jul 2, 2022

Exploring the CIE Lab L=50 plane over a,b = -125 to +125 I am struck by the OKLab a value in the -125,-125 corner:

lab(50% 125 125) = oklab(60.58% 0.357 0.152)
lab(50% -125 125) = oklab(53.41% -0.32 0.194)
lab(50% -125 -125) = oklab(42.27% -1.9 -0.37)
lab(50% 125 -125) = oklab(65.4% 0.257 -0.35)

@svgeesus
Copy link
Member Author

svgeesus commented Jul 2, 2022

So exploring the CIE a,b plane gives odd results if the GMA is using OKLCH

image

but equally, exploring the OKLab ab plane while mapping in CIE LCH is odd too

image

@svgeesus
Copy link
Member Author

svgeesus commented Jul 2, 2022

(TIL that screenshots of Canvas elements on my WCG screen look nothing like the actual screen)

@svgeesus
Copy link
Member Author

svgeesus commented Jul 2, 2022

Here exploring OKLab a,b we see mapping in CIELCH gives a patch of solid color in the a positive, b positive corner (bottom right)

image

@svgeesus
Copy link
Member Author

svgeesus commented Jul 2, 2022

Live versions:

@jamesnw
Copy link
Contributor

jamesnw commented Nov 10, 2023

@svgeesus - We are looking to use Color.js to implement CSS Color 4 logic (conversions, gamut, etc) for Sass in the node-embedded-host, and gamut mapping is one piece that is currently missing. Is there anything blocking this algorithm from being used in Color.js? (Perhaps waiting for clarity on w3c/csswg-drafts#9449 or other outstanding issues?)

If there isn't anything blocking, are there parts that we could help implement here in Color.js?

@LeaVerou
Copy link
Member

@jamesnw exciting! Would love to support you folks in this.
AFAIK the only blocker is our lack of time: both @svgeesus and I are spread very thin. So yeah, we'd love help from you folks! Happy to assist with any questions about the codebase, architecture, API etc.

@jamesnw jamesnw mentioned this issue Nov 14, 2023
2 tasks
@jamesnw
Copy link
Contributor

jamesnw commented Nov 14, 2023

@LeaVerou Great! I have a draft PR at #344. I have a few questions there, and am open to your thoughts on documentation and how best to incorporate this change. Thanks!

@svgeesus svgeesus added the spec-parity Parity with the CSS Color specs label Nov 16, 2023
@svgeesus
Copy link
Member Author

svgeesus commented Jan 4, 2024

Closed by #352

@svgeesus svgeesus closed this as completed Jan 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request spec-parity Parity with the CSS Color specs Topic: Algorithms Issues that relate to the actual color science
Projects
None yet
Development

No branches or pull requests

3 participants