[csswg-drafts] [css-color-5] unclamped alpha through RCS (#9805)

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

== [css-color-5] unclamped alpha through RCS ==
see : https://github.com/w3c/csswg-drafts/issues/9759#issuecomment-1889541570

@svgeesus said :

> the whole reason we added the serialization of RCS `rgb()`, `hsl()` and `hwb()` to `color(srgb)` specifically to enable round-tripping of out of gamut values. But the text from CSS Color 4 that I quoted above prevents that, which means that CSS Color 5 needs to specifically say that RCS versions of those color functions do not clamp out of range values. And then, do we really want unclamped alpha values like that?

------

I kept coming back to this.
I initially concluded that this behavior isn't useful.

But I wanted to have a better understanding of the implication of either mode.

------

I think there are 2 cases where an unclamped alpha could be observable:
1. calc expressions in RCS
2. interpolation

_I might be wrong here_

https://codepen.io/romainmenke/pen/dyrvGoz

### calc expressions in RCS

```css
rgb(
  /* produce an alpha higher than 1 */
  from rgb(from red r g b / r)
  /* make it smaller */
  r g b / calc(alpha / 2))
```

If the value is clamped then the result must be `0.5`, if it is unclamped it must be `1`.

### interpolation

```css
color-mix(
  in srgb,
  /* produce an alpha higher than 1 */
  rgb(from red r g b / r),
  /* mix it with something semi-transparent */
  rgb(50% 50% 50% / 0.5) 90%
)
```

If the value is clamped then the result must be `rgba(151, 104, 104, 0.55)`, if it is unclamped then it must be `rgb(253, 2, 2)`.

_Other channels are also affected because premultiplying by alpha will have very different results._

----------

Compared to other channels which aren't clamped:

https://codepen.io/romainmenke/pen/OJqpMgr

_Best viewed in Chrome as that implementation is more up to date_

----------

I do think that it is observable that alpha is clamped or not in RCS but I still don't think it enables authors to do something useful.

While clamping will almost always produce the results you would intuitively expect.

There also seems to be interop for clamping alpha in RCS.

@svgeesus thoughts?

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


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

Received on Tuesday, 16 January 2024 22:20:16 UTC