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

 @devongovett  thanks for raising this. Also, I wasn't aware of [parcel-css](https://github.com/parcel-bundler/parcel-css) and it looks like an interesting tool for authoring in more modern CSS while still covering older browsers.And if you are implementing [CCSS gamut mapping](https://drafts.csswg.org/css-color-4/#css-gamut-mapping) in Rust, I would be interested to know whether you found the specification sufficiently clear.

Specification wise:

1. CSS Color 5 [Calculating the result of color-mix](https://drafts.csswg.org/css-color-5/#color-mix-result) looks to be correct but **converted to the specified [<color-space>](https://drafts.csswg.org/css-color-4/#typedef-color-space)**  needs a link from **converted** to a general term on color conversion in CSS Color 4.
2. CS Color 4 needs the general convert between color spaces concept which can then point off to the varous existing, more specialized conversion sections such as [Converting between predefined RGB color spaces](https://drafts.csswg.org/css-color-4/#predefined-to-predefined). I have several times considered adding a diagram about overall colorspace conversion, and that would be a good place for it.
3. For this particular case of _convert any random color into HSL_, in CSS Color 4, [Converting sRGB colors to HSL colors](https://drafts.csswg.org/css-color-4/#rgb-to-hsl) I should add some clarifying statements that colors in non-sRGB colorspaces are first converted to sRGB; then they are CSS gamut mapped into the sRGB gamut, and then the conversion to HSL is done as per the sample code. This is implicit, but needs to be explicit.

Implementation-wise, @facelessuser is right that I need to finish off and then land the CSS Gamut mapping code in color.js, which is currently [off in a branch](https://github.com/LeaVerou/color.js/tree/oklch-gamutmap).

Then the individual stages in this sub-test can be evaluated and the expected result checked. @weinig you wrote this test, could you share the working for this sub-test? And does it do extended sRGB to in-gamut sRGB gamut mapping in oklch or was it written at a time when it was specified to use CIE LCH? The test itself just mentions that it is testing that naive clipping is not used.

-- 
GitHub Notification of comment by svgeesus
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/7107#issuecomment-1061054652 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:30:45 UTC