-
Notifications
You must be signed in to change notification settings - Fork 715
[css-color-4] Allow any color space as part of the interpolation method? #7907
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
All the RGB spaces are defined over the extended range, so all of them with the same or similar gamma will give identical or near-identical results. In particular, Extended-range
This is a fair point. |
I actually came here this morning to ask the inverse question: Why do we offer |
Ah, just noticed one other thing that you mentioned... |
You are right. I wasn't thinking clearly. |
So we basically have two options here:
The current set was intended to cover these cases: a) you want physical linear-light mixing. xyz-d65 is the ideal choice here. srgb-linear will give the same result, as it is defined over the extended range. |
To me it seems better if authors can use any color space that has the behavior they want - instead of forcing them to memorize which is the 'correct' space for a specific behavior. I don't see what about that would be a 'confusing trap' - or how it would trip people up. |
The confusing trap is the following line of reasoning:
|
I suppose I'm not entirely convinced that limiting the available interpolation spaces actually helps authors know what they're doing and avoid that. You'd still get that line of reasoning with all the allowed spaces - and confusion when a space is not allowed. There's no clear logic to teach for which spaces are allowed, and which are not allowed - or why one space was selected as a representative of a particular interpolation outcome. I don't know how I would teach this besides: yeah, sorry, you'll just have to memorize it, or look it up every time. |
This is a fair point. Adding more spaces just makes the teaching burden harder though.
Also, the spec gives specific guidance:
|
Huh, if the argument is that we should only provide 'good' options (those listed in the spec), and a 'legacy' option - then I'm curious why I'm still a bit torn on that as an approach here - but if we want to go the way of limiting to a recommended set, it seems like we should go all-in on that, and limit the list as much as possible, so there are only a few 'best' options to choose from? |
I think that makes the most sense.
|
Maybe this is a naive question, but why does it matter if the result of interpolation is in-gamut for sRGB if browsers will gamut-map it anyway? I understand that gamut-mapping may not always provide ideal results, but neither will sRGB-only (or HSL-only) interpolation. If you do go the route of limiting the interpolation options to only a certain set of desirable behaviors, maybe it would help clarify to users which interpolation method is for which use-case if you named them after the use-case rather than after one example color space that satisfies that use-case? So |
I'm fine adding all color spaces to make this easier to learn. |
You are right, it doesn't actually matter, but that is pretty much the sole advantage of manipulating in HSL. |
Yeah I still find the one example color space per use-case to be a strange solution that is difficult to remember/teach - and would prefer either naming a limited set of options by their declarative intent (as Natalie suggests), or allowing all color spaces. |
To clarify my 'confusing trap' comment: If we offer the ability to use any space, then I don't think it applies. My concern was with offering a limited menu of choices, and having three of those produce identical results. For people that don't understand the math, they're going to look at that and try to decide which one to use. They might try more than one, and wonder why nothing changes. ("Maybe I'm using it wrong? Maybe I need to use different colors?" Etc...) I also like specifying intent rather than implementation, but in this case the specification is presumably going to have to map the intents to actual color spaces. Is there any concern if someone finds a tweak (or alternative) to Oklab that's even more perceptually uniform? (Honest question -- the risk of this may be low enough that it's better to embrace today's state of the art in our naming). |
+1 for allowing all spaces even if they map to the same behavior. What @brianosman is suggesting is a bit orthogonal: allowing behavior-named spaces like "legacy", "best", "perceptual" or whatever. I'm not convinced that we could do this: right now, we are not changing the default behavior from legacy-srgb, because that would break content. If we can't change gradients without breaking content, then having "intent-names" would be bad, because we would have the same problem when trying to change them in the future. I think this forces us out of intent and into explicit opt-ins. |
I suppose authors could also use custom properties to clarify intents, and narrow down their list of 'options' in the same way they do with design tokens: html {
--perceptual: oklab;
--legacy: srgb;
--linear: xyz-d65;
} By leaving that to authors, we avoid the issue of locking-in behavior long term. Is there a consensus developing towards allowing all spaces, and using examples/notes to help guide authors towards the reasons they might use one over another? |
I can live with adding all color spaces. I think it does not make the feature less confusing, by adding a bunch of 'no reason to use these' color spaces. And it adds to the testing burden for no real benefit. But I am okay to go with the majority view. |
Agenda+ to discuss with the working group. The tradeoffs are:
I don't love these options - but I'd like to see this addressed one way or the other before the feature ships. |
Thanks @mirisuzanne for summarizing the options. I'd like to point out that 3 can co-exist with 1 or 2: we could absolutely have lower-level color space options, as well as higher level intent-based keywords that could change in the future. Authors who want control would use the former. Documentation could include the current mapping of intent-based keywords to color space keywords, so that authors can switch to color space keywords before shipping if they want that kind of control. |
I agree with @mirisuzanne that the emerging slight consensus seems to be to allow any of them, and with @LeaVerou that this does not preclude adding declarative names later. Meanwhile the spec does have guidance on what to pick for different desired results. This does increase the testing burden, but not by much. Should I go ahead and make the spec edits for "allow all"? |
Sounds good to me. |
Initially these were implemented as distinct ideas. As we've begun to unify creation and conversion methods for blink::Color, it makes less and less sense to keep them separate. ColorInterpolationSpace was a subset of ColorSpace, so the only logic that needs to be added is to throw if an interpolation is attempted in one of the handful of ColorSpaces that are NOT ColorInterpolationSpaces (display-p3, a98-rgb, prophoto-rgb and rec2020). There is already talk underway to turn these into spaces for interpolation anyway: w3c/csswg-drafts#7907 Also the sRGBLegacy ColorSpace is used more explicitly as it is distinct from sRGB. Change-Id: Iebe1e7b7abce26cb4c606f1787995aa50d5e6d0b Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4327275 Reviewed-by: Justin Novosad <junov@chromium.org> Commit-Queue: Aaron Krajeski <aaronhk@chromium.org> Cr-Commit-Position: refs/heads/main@{#1123288}
Currently, the color-interpolation-method syntax production accepts a limited list of color spaces for interpolation:
That leaves out several of the predefined rgb spaces like
display-p3
,rec2020
, and so on. I imagine that's because all rgb spaces would give a similar (the same?) result to eithersrgb
orsrgb-linear
- so there's no particular use-case? But I think this makes it harder to teach. Ifsrgb
anddisplay-p3
interpolation would have the same result, why not allow authors to use either one? Both are well defined and meaningful, they just happen to be an alias for the same thing. But why should we need to memorize which is the right rgb interpolation space?The text was updated successfully, but these errors were encountered: