W3C home > Mailing lists > Public > public-css-archive@w3.org > October 2020

[csswg-drafts] [css-images-4] sRGBA assumption on gradients, and premultiplied other color spaces (#5669)

From: Chris Lilley via GitHub <sysbot+gh@w3.org>
Date: Tue, 27 Oct 2020 16:16:49 +0000
To: public-css-archive@w3.org
Message-ID: <issues.opened-730600420-1603815408-sysbot+gh@w3.org>
svgeesus has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-images-4] sRGBA assumption on gradients, and premultiplied other color spaces ==
_Tagging Images 4 for fixing; I'm aware that currently, Images 4 has the same gradient stuff as Images 3._

Two things in the CSS Images  definition of gradients hinder integration with CSS Color 4:

1. The `<<color>>` token links to CSS Color 3, which only allows sRGB values. CSS Color 4, which is the current work, allows other RGB spaces, CMYK, Lab, and LCH.

2. the section [coloring the gradient line](https://drafts.csswg.org/css-images-3/#coloring-gradient-line) says that

> 	Between two color stops, the gradient line’s color is interpolated between the colors of the two color stops, with the interpolation taking place in premultiplied RGBA space

which would force all colors to be

a) converted to sRGB, resulting in gamut mapping
b) interpolated in sRGB gamma-encoded space.

Suggested fixes are

1. Change the link for `<<color>>` to CSS Color 4, which is the current specification
2. Link to the existing [interpolation section of CSS Color 5](https://drafts.csswg.org/css-color-5/#interpolation) which already covers things like hue interpolation in cylindrical colorspaces
3. State that for compatibility, color stops which are all in an sRGB space (this includes hsl, hwb, named colors) are interpolated in premultiplied sRGBA (this gives a poor result, but is Web compatible)
4. Add an opt-in feature on gradients to select another color space. At minimum CIE XYZ (for linear-light blending) and CIE Lab (for perceptually uniform linear interpolation) and CIE LCH (for perceptually uniform chroma-preserving angular interpolation) should be supported

In addition, the interpolation section of CSS Color 5 needs to define how premultiplied alpha is handled. For example in Lab or in XYZ, premultiplying all three component values will work; in LCH, premultiplying hue would change the hue so should not be done.

I'm happy to help with examples (CSS, color calculations, rendered results) of interpolated gradient lines which involve non-sRGB stops.

@tabatkins @fantasai @LeaVerou 

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

Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Tuesday, 27 October 2020 16:16:51 UTC

This archive was generated by hypermail 2.4.0 : Tuesday, 5 July 2022 06:42:21 UTC