Re: [csswg-drafts] [css-color-4] Channel clipping breaks author expectations, especially when using 'perceptually uniform' spaces (#9449)

I opened this issue to try and step away from the specific numerical mechanics of an algorithm, and ensure that we first agree on the desired behavior. At that point we can better judge if the given algorithms achieve the goal we've agreed on. Without that, the mathematical discussions just seem to go in circles – solving different problems. 

I also think it's pretty essential that in conversations about CSS color we don't lose track of the far most common use-cases – setting background and foreground colors. We set them on the overall page, on sections of the page, individual components, buttons, links, inputs, etc. While color-matching across images and canvas elements is a real use-case that we should consider and provide tools far, it is _extremely less common_ than day-to-day backgrounds and foregrounds. So when discussing the default behavior for out-of-gamut colors, I think it would be a mistake to leave out the central question:

- When the viewer is not able to see the exact foreground/background colors requested, what aspects of those colors should ideally be preserved?

When we look at the adjustments being applied [in the example above](https://github.com/w3c/csswg-drafts/issues/9449#issuecomment-1929679581), it complicates the question of 'which result is _closer_' to the original:

![locking oklch(90% 90% 0deg) to the p3 gamut with colorjs.io, mapping results in oklch(88.8% 0.0864 356) while clipping gives oklch(74% 0.273 343) (farther on both lightness and hue, only closer in chroma)](https://github.com/w3c/csswg-drafts/assets/104161/ad9e69e5-e54f-465c-bcb7-82d6b42d1ce3) (I grayed out the first result, since it can't be displayed without either clipping or mapping)

<details>
<summary>the colorjs.io code used</summary>

```js
let color = new Color("oklch(90% 90% 0deg)");
color.clone().toGamut({method:'css', space:'p3'});
color.clone().toGamut({method:'clip', space:'p3'});
```

</details>

Do we mean that individual rgb channels are maintained? Is that a priority for readers? Or are we trying to maintain more perceptual concepts like lightness, hue, and chroma? The clipping variation maintains high chroma by making moving both lightness and hue _farther_ from the requested color.

|            | (ok) l c h            |
|------------|-----------------------|
| requested  | `90%   0.36   0deg`   |
| mapped     | `88.8% 0.0864 356deg` |
| clipped    | `74%   0.273  343deg` |




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


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

Received on Friday, 9 February 2024 18:47:26 UTC