-
Notifications
You must be signed in to change notification settings - Fork 756
Description
see : #9759 (comment)
@svgeesus said :
the whole reason we added the serialization of RCS
rgb(),hsl()andhwb()tocolor(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:
- calc expressions in RCS
- interpolation
I might be wrong here
https://codepen.io/romainmenke/pen/dyrvGoz
calc expressions in RCS
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
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?