Re: [csswg-drafts] [css-color-5] Gamut mapping in HSL/HWB (#7107)

> This seems to be the result of gamut mapping occurring in the sRGB space rather than the HSL space. However, the color-mix in the test states that the color mixing should occur in the HSL space. If I convert the HSL color to sRGB before gamut mapping, and then back to HSL afterward for interpolation the test passes. However, I don't see where in the spec that is required. 

In [Calculating the result of color-mix](https://drafts.csswg.org/css-color-5/#color-mix-result), which says (my emphasis):

>> Both colors are converted to the specified [<color-space>](https://drafts.csswg.org/css-color-4/#typedef-color-space). If the specified color space _cannot express the color_ (for example, the [hsl](https://drafts.csswg.org/css-color-4/#valdef-hsl-hsl) and [hwb](https://drafts.csswg.org/css-color-4/#valdef-hwb-hwb) spaces cannot express colors outside the [sRGB](https://drafts.csswg.org/css-color-4/#valdef-color-srgb) gamut), gamut mapping will occur.

> It says:

>>    For intermediate color calculations, these out of gamut values are preserved.

They are, for all the predefined RGB spaces which use the extended range (component values not not clamped to 0.0 .. 1.0). However, HSL and HWB take, as input, an in-gamut sRGB color and thus, gamut mapping will occur at that step. This sRGB to sRGB gamut mapping  is [computed in OKLCH](https://drafts.csswg.org/css-color-4/#css-gamut-mapping)

> In this case, we're converting from OKLCH to HSL, and then comparing the clipped result via deltaE, so I would consider sRGB to be an intermediate space.

Yes, sRGB is an intermediate space; but sRGB to HSL requires the input values to be in gamut because HSL and HWB) cannot represent out of sRGB-gamut colors.

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


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

Received on Monday, 7 March 2022 19:39:46 UTC