-
Notifications
You must be signed in to change notification settings - Fork 707
[css-color-5] Hue interpolation and multiple colors #5277
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
I do like the keyword options that we have for 2 colors, so whatever the outcome for I suspect though that for In linear-light colorspaces, I think additivity also means that we can do pairwise combination in any order: mix color_1 and color_2 to get color_a, then mix color_a and color_3 to get color_b and so on. Would need to test out that intuition though by doing such a calculation twice (starting from either end of the list). In general though the order does matter, and greater weight is given to the later colors in the list (same as with alpha compositing, the top one has more effect). We should also keep in mind what are the actual use case for 3 or more color mixing. Or did we just add it for completeness? If so we can save a lot of trouble by just not doing that. |
For mixing multiple colors, can we just stack the functions? i.e. |
We could, although the order then becomes significant. |
Re-tagging to css color 4 because the color interpolation section moved. |
Hi @svgeesus
YES, at least in part.
For linear tristimulus color models, if color-mix() only uses plain addition, then order does not matter. If after addition, there is an averaging, then order does not matter for n-colors being mixed at the same time that are to be averaged at the same time but otherwise mathematical order of operations always applies. However, a key reason to work in a linear-space is to not have to do any averaging at all, just add 'em up. Order can matter when the blend operations are more complex, like overlay, screen. If you add two colors, and average, then add another and average, order matters regardless of TRC, because that is a PEMDAS issue. Some gamma encoded tristimulus additive spaces are also not necessarily order specific, except if there are overflow issues. That is, you can add three sRGB colors together in any order and average them after adding all three. Again, PEMDAS applies, but so does overflow or clipping. I wrote a brief in #4711 regarding recursively mixing pairs only, which on further reading I see @una had already suggested. The post provides additional support for the concept. Parting Thought on Multicolor MixingI say keep it to color pairs, and allow recursive/iterative mixing. BUT It would be useful to add one utility feature: Shade/Tint/ToneKeep it to a pair of colors, but allow the addition of an achromatic modifier, from I'd say it should be the last of the parameters. color-mix( orange 35%, cyan, -64) Which if any of the color parameters the achromatic modifier is applied to depends on the space. It's applied to all three channels in a tristimulus space, but only L* C* in an LCh mode for instance (where it subtracts from C*), and maybe only L* in LAB. |
Noting that color-mix to allow more than two colors? concluded
and was closed, |
Per discussion in #4735, we resulted in 5 different hue interpolation algorithms (specified, longer, shorter, increasing, decreasing).
However, these are defined in terms of doing fixup on a pair of angles, and it is unclear to me and @svgeesus how this extrapolates to multiple colors, since the fixup may be different per pair. Since we eventually intend to allow multiple color interpolation in
color-mix()
, as of #4711, we need to figure this out.The text was updated successfully, but these errors were encountered: