Re: [csswg-drafts] [css-color-4] Converting out of gamut colors to `hsl` can result in negative saturation with the sample code (#9222)

🤔 After a bit of poking I think it's something completely different.

Most color functions describe clipping of values outside certain ranges.

https://www.w3.org/TR/css-color-3/#hsl-color

> If saturation is less than 0%, implementations must clip it to 0%. If the resulting value is outside the device gamut, implementations must clip it to the device gamut. This clipping should preserve the hue when possible, but is otherwise undefined. (In other words, the clipping is different from applying the rules for clipping of RGB colors after applying the algorithm below for converting HSL to RGB.)

But this should be done only during parsing.

In our implementation we always do this step, but after https://github.com/w3c/csswg-drafts/issues/8444 I think it becomes clear that we must only do it when parsing, and not when computing.

------

Are these the same or different colors?

```
hsl(from lab(100 104.3 -50.9) h s l)
hsl(from lab(100 104.3 -50.9) 311.21deg -5.5486% 1.0906%)
hsl(from white 311.21deg -5.5486% 1.0906%)
hsl(311.21deg -5.5486% 1.0906%)
```

-----

Closing and filing a new issue to avoid confusion :)

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


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

Received on Tuesday, 29 August 2023 08:32:43 UTC