[csswg-drafts] [css-color-4] Move gamut mapping to a future spec (#8444)

mysteryDate has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-color-4] Move gamut mapping to a future spec ==
[Section 13.2 of CSS Color 4](https://www.w3.org/TR/css-color-4/#css-gamut-mapping) contains a non-normative section describing a binary search gamut-mapping algorithm. Though user agents are beginning to ship CSS Color 4, there is still a lot of ongoing debate over the appropriateness of this algorithm (https://github.com/w3c/csswg-drafts/issues/7610). Proposed alternatives can be found here: https://github.com/w3c/csswg-drafts/issues/7653.

Some UA developers met recently to discuss the issue. A consensus was reached that it would be better to allow out-of-gamut color conversions to remain out-of-gamut (as opposed to clipping) while the working group continues to develop a gamut mapping algorithm. To that end, we could move the entire section 13 to a CSS Color 5 or 6 while this work is being done.

For CSS Color 4, [step 8](https://www.w3.org/TR/css-color-4/#convert-hslhwb) in converting colors could be removed. And since colors are now possibly out-of-gamut [Converting sRGB Colors to HSL](https://www.w3.org/TR/css-color-4/#rgb-to-hsl) would need to deal with rgb channels outside of the [0,1] range:

```js
/**
 * @param {number} red - Red component
 * @param {number} green - Green component
 * @param {number} blue - Blue component
 * @return {number[]} Array of HSL values: [snip]
 */
function rgbToHsl (red, green, blue) {
   red =   Math.min(Math.max(red,   0), 1); 
   green = Math.min(Math.max(green, 0), 1);
   blue =  Math.min(Math.max(blue,  0), 1);
   let max = Math.max(red, green, blue);
 ```
 
  Since `color-mix()` from CSS Color 5 is the only feature for color 4 or 5 that can result in intermediate out-of-gamut results, our exposure to out-of-gamut colors would remain relatively minimal and we can preserve interoperability. Leaving out-of-gamut results and not clipping avoids the worst results, like saturation at the boundaries and different results for canvases. It has the added bonus of color conversions round tripping. 

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/8444 using your GitHub account


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

Received on Friday, 10 February 2023 21:47:25 UTC