-
Notifications
You must be signed in to change notification settings - Fork 711
[css-images-4] Question: in what color space will gradient interpolation occur? #6094
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Re-tagging to CSS Images 4, where gradients are defined. As defined in CSS Color 4, unless the host syntax overrides (and currently there is no gradient syntax to override) then pairs of legacy sRGB colors will interpolate in gamma-encoded sRGB. This is necessary for Web compat. A pair of non-legacy colors, ore one legacy and one non-legacy, will interpolate in Lab. This includes the non-legacy CSS Images 4 should define a host override syntax to allow other choices of interpolation colorspace. |
It would be nice if CSS images would also provide a way to automatically deduce a colorspace, so it doesn't default to Lab for any non-legacy colors. In particular when all colors of the gradient are defined in the same colorspace, it should use that colorspace. |
That would be one option, but you don't say why it is a good idea (and for many colorspaces it would not be a good idea). It also introduces fragility and surprise: add one color stop and suddenly all the rest of your gradient mysteriously changes. |
The main reason why I consider it a good idea is when the whole CSS file is using the same colorspace for all colors - I could imagine that for CMYK as well as when targeting hardware-specific CSS, like for TVs or cars. Having to add "in @myspace" to every gradient feels tedious and is also easy to forget. And the fragility and surprise is already a problem I guess, when something like I don't have a good solution either, I'd just like a way to avoid lots of "in @myspace". |
Note that color interpolation syntax was just added to all gradient functions in 1f940c6
We have explored using this as a heuristic, but it's a poor heuristic for any gamma-encoded RGB space (e.g. you wouldn't want two There might be value in providing the ability to set defaults for color interpolation, but that wouldn't be gradient specific. |
This is now well-defined in the specifications: see 3.5.2. Coloring the Gradient Line |
Please forgive me to comment on this closed issue. It is not clear to me what the color interpolation method is when it is not specified in the gradient input argument. When omitted, my understanding is that color stops interpolate in oklab, even if some colors are specified in different color spaces. Assuming I guess that gradient colors defined in different color spaces are otherwise gamut mapped in the color interpolation method specified for the gradient. |
3.5.2. Coloring the Gradient Line:
12.1. Color Space for Interpolation:
but
That may means that for gradients with no So (to answer a question you didn't ask) in this case I feel that serialization should include an explicit To answer the question you did ask (explicit The serialization section of CSS Images 4 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 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 |
This differs with your previous comment above:
I guess it might makes sense to require all color stops to be legacy sRGB. For example, the last two color stops in There is currently no
You may be referring to #7948. I will wait for your next edits on this. Thanks for your hindsightful reply (as usual). Aside: I recently commented on some problematic/missing requirements for gradient serialization. |
The spec also differs, between now and the time I wrote that comment :)
Yes. |
Right now, the color between two different colors stops is computed in sRGB space, i.e. if a pixel is half way between two colors stops A and B, the emitted color in sRGB is mix(A, B, 0.5) where A and B are in sRGB color space.
What is the expectation when the color stops are in different color spaces? What happens if single gradient has color values in different color spaces?
The text was updated successfully, but these errors were encountered: