Re: [csswg-drafts] [css-images-4] Question: in what color space will gradient interpolation occur? (#6094)

[3.5.2. Coloring the Gradient Line](https://drafts.csswg.org/css-images-4/#coloring-gradient-line):

> If no [`<color-interpolation-method>`](https://www.w3.org/TR/css-color-4/#color-interpolation-method) is specified in the gradient function, the color space used for gradient interpolation is the default interpolation color space as defined in [[css-color-4]](https://drafts.csswg.org/css-images-4/#biblio-css-color-4).

[12.1. Color Space for Interpolation](https://drafts.csswg.org/css-color-4/#interpolation-space):

> The host syntax should define what the default [interpolation color space](https://drafts.csswg.org/css-color-4/#interpolation-color-space) should be for each case, and optionally provide syntax for authors to override this default. If such syntax is part of a property value, it should use a [`<color-interpolation-method>`](https://drafts.csswg.org/css-color-4/#color-interpolation-method) token

> If the host syntax does not define what color space interpolation should take place in, it defaults to Oklab.

but

> However, user agents **may** handle interpolation between legacy sRGB color formats (hex colors, named colors, [rgb()](https://drafts.csswg.org/css-color-4/#funcdef-rgb), [hsl()](https://drafts.csswg.org/css-color-4/#funcdef-hsl) or [hwb()](https://drafts.csswg.org/css-color-4/#funcdef-hwb) and the equivalent alpha-including forms) in gamma-encoded sRGB space.

That may means that for gradients with no `<color-interpolation-method>` where all the stops are in legacy sRGB, the spec is intentionally vague on what color space is used for interpolation (thus permitting existing legacy behavior). It is allowed to be Oklab and it is allowed to be sRGB.

So (to answer a question you didn't ask) in this case I feel that serialization should include an explicit `<color-interpolation-method>`. Currently the spec doesn't say that, because there is disagreement on the level of backwards compatibility we really need.

To answer the question you did ask (explicit `in oklab`, at least one non-legacy-sRGB stop) shortest serialization would indeed suggest omitting the `in oklab` but I am not sure that is wise.

The [serialization section of CSS Images 4](https://drafts.csswg.org/css-images-4/#serialization) is brief and somewhat vague and should probably be examined more carefully and given several more examples. I see small changes compared to [serialization in CSS Images 3](https://drafts.csswg.org/css-images-3/#serialization) and neither level of that spec clearly states whether specified or computed values are being serialized. Notice how the example changes between the two. The impact of `<color-interpolation-method>` on serialization is completely unspecified, so thanks for drawing attention to that!.

@fantasai @LeaVerou 



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


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

Received on Monday, 30 January 2023 17:24:46 UTC