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

The mapping algo seems pretty interesting. Just explaining it back to myself:

1. Convert the out-of-gamut color into linear-light p3 rgb. (P3 is a nice cubic space, three 0-1 coordinates for in-gamut.)
2. Draw a line connecting the midpoint of p3 (.5, .5, .5) to the out-of-gamut color.
3. Find the intersection of that line with the gamut boundary. (Since the space is a nice cube, this is a trivial scale. Since this is linear light, a simple scale keeps the physical primary proportions intact.)
4. This color is, roughly, the maximum chroma you can get from a pure-chroma reduction.
5. The scaled color might also have adjusted the lightness and hue, tho. So we take the original color's lightness and hue, and the scaled color's chroma, as a new best-guess.
6. This might still be out of gamut, but it'll be much much closer. If it is out, repeat the scale one more time. This should have a relatively minimal hue/lightness shift.

Right?

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


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

Received on Wednesday, 14 February 2024 16:59:07 UTC