Re: [csswg-drafts] [css-color-4] Parse-time clip of HSL negative saturation for modern syntax? (#9222)

> Should it be considered a bug if saturation is also capped at 100% before conversion to RGB?

Yes, and that should be observable via `color-mix()` when output to `color(srgb ...)`. I mean clamping will happen during conversion to `rgb()` but not *before* conversion.

> But I cannot find where clamping values outside of [0,255] after conversion to RGB, is defined.

It is in [5.1 The RGB functions: `rgb()` and `rgba()`](https://drafts.csswg.org/css-color-4/#rgb-functions):

> Values outside these ranges are not invalid, but are clamped to the ranges defined here at parsed-value time.

and, hmm,

[14.1. Resolving sRGB values](https://drafts.csswg.org/css-color-4/#resolving-sRGB-values)

> Also for historical reasons, when calc() is simplified down to a single value, the color values are clamped to [0.0, 255.0].

> This clamping also takes care of values such as [Infinity](https://drafts.csswg.org/css-values-4/#valdef-calc-infinity), -Infiinity, and [NaN](https://drafts.csswg.org/css-values-4/#valdef-calc-nan) which will clamp at 255, 0 and 0 respectively.

I agree that it doesn't say explicitly about _after conversion_. In particular,

[11. Converting Colors](https://drafts.csswg.org/css-color-4/#color-conversion) says

> Colors may be converted from one color space to another and, provided that there is no gamut mapping and that each color space can represent out of gamut colors, (for RGB spaces, this means that the transfer function is defined over the extended range) then (subject to numerical precision and round-off error) the two colors will look the same and represent the same color sensation.

Which is true, but does not cover the case where the color space (in this case, sRGB) is defined over the extended range but a serialization form (`rgb()`) does not allow extended range values.

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


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

Received on Friday, 16 February 2024 17:33:47 UTC