Re: [csswg-drafts] [css-color] Computing lch/lab to srgb with lightness = 0% or 100% (#8794)

The requirement to force colors to white or black by setting chroma/hue and a/b to zero when the lightness is 0 or 100 during the conversion can seem jarring in these situations, and I wonder if such requirements are better suited in gamut mapping and not conversion. These requirements in conversion are essentially gamut mapping these extreme "lightness" cases, but nothing else.

I believe the idea is that when lightness is at these extremes, said lightness will essentially overpower any contribution to the color that chroma and hue are providing making them meaningless. While I don't disagree with this assertion, I do wonder if conversion is the right place to make these corrections.

I don't know if browsers intentionally or unintentionally have left out this CSS requirement, but I know that I've currently left out this requirement in my color library as the results feel surprising. Granted, my goal isn't necessarily to strictly follow what CSS does, but to simply handle CSS color formats as inputs and outputs.

Consider the example below. We interpolate between `lch(0 100 100)` and `lch(100 100 100)`. The first does as browsers do and clips any out-of-gamut color. The second does as CSS suggests and sets chroma/hue (or a/b for lab) to zero if lightness is at its extremes. The last uses a more proper gamut mapping.

<img width="1351" alt="Screenshot 2023-05-05 at 6 27 53 AM" src="https://user-images.githubusercontent.com/1055125/236458679-8a935d90-9850-4d77-abc2-0d0a581770da.png">

We can see that just clipping, as browsers currently do, gives a consistent transition, but does not resolve these extremes to white or black. With the added requirement by CSS (which browsers are not currently doing), we see that we get a jarring discontinuity in color. Lastly, when using proper gamut mapping, we will naturally resolve these extreme cases as black or white and provide a more consistent transition to them.

For the above reasons, I wonder if such resolutions of colors should be left solely up to the gamut mapping method being used. I do admit that there may be non-obvious reasons (to me) why CSS desires these additions.




-- 
GitHub Notification of comment by facelessuser
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/8794#issuecomment-1536240587 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Friday, 5 May 2023 13:10:07 UTC