-
Notifications
You must be signed in to change notification settings - Fork 666
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
[css-color-4][css-values-4][web-animations-1] Behavior of additive animations of color properties is unclear #7793
Comments
The whole issue of additive CSS, opened in 2017, is still being discussed. Additive animation makes sense for things like lengths but seems less valuable for color (I guess, in RGB spaces, adding or subtracting a constant offset on a per-component basis is a way to crudely increase or decrease the lightness, if you don't care about the hue changing wildly). Good question about what to do about hue, if additive animation takes place in a polar space. I feel I need to better understand what the use cases are for additive animation of colors, to understand how that should behave. Note that premultiplication in polar spaces is already defined, at least. |
Btw here is a demo of additive animation today: https://codepen.io/leaverou/pen/NWMzmoV That should definitely not be in CSS Values, it belongs in Color, not sure if we can still add it to Color 4 or whether it would need to go into Color 4. The prose also needs editing, this is way too vague. In which premultiplied space? E.g. what do we do when adding these:
In which space do we add their components?? I guess the most obvious, but potentially less useful thing to do would be to pick the color space of the first color, and just naively add arguments. Is there something better we could do? |
Agree it belongs in Color 4.
The one they are animating or transitioning in. |
My understanding is this is an operation that involves multiple animations, which could be interpolating in entirely different color spaces. |
Yes, you are right; and the current spec text for adding colors assumes all colors are resolved to sRGB. So (by analogy with what we did for color interpolation) we need some 'host syntax' wording and then, if host does not specify:
|
Since @birtles does this seem in line with the intent of additive compositing? Then you could add an animation like: @keyframes pulse {
0% { background-color: rgba(0,0,0,0.2); }
100% { background-color: rgba(255,255,255,0.2); }
}
.flashing {
animation: pulse 1s infinite alternate;
animation-composite: add;
} To make an element's background alternate getting a bit darker and lighter. |
Certainly that particular example with translucent colors seems very useful. However, I don't know enough about color to know what would be most useful in the general case. Two considerations that might help frame the question though:
|
This could make sense for |
This was closed in |
While going to fix the following WPT tests in WebKit:
which had failing test cases for additive and accumulative animations of color properties, I ran across a few underspecified areas that could use some clarification:
This works for the rectangular color types, but how should the hue component of the cylindrical color types be added? Should it differ based on what hue interpolation mode is in effect? (this is not currently a problem, as there is no syntax to ask an animation to use a cylindrical interpolation method, but that seems like it is only a manner time).
Also, how does addition of the alpha channel work? Should it overflow if the two values add up to more than 1?
The model for additive animation of colors as assumed by the tests noted above assume that overflow of the sRGB gamut will clip, rather than do gamut mapping. For example, this subtest:
assumes that the overflow of one component (for instance from's red component, which ends up being 128+255) is just clamped. This is a bit out of line with the current status quo, which would likely have this gamut mapped.
I know the use of legacy interpolation is a
may
condition in the CSS Color 4 spec, so perhaps this is not something the editors want to clarify. If that is the case, we should make sure that WPT tests are appropriately relaxed for multiple implementations.The text was updated successfully, but these errors were encountered: