w3c / csswg-drafts

CSS Working Group Editor Drafts
https://drafts.csswg.org/
Other
4.42k stars 649 forks source link

Two "variants" of `color-mix()` ?? #10573

Open svgeesus opened 1 month ago

svgeesus commented 1 month ago

In CSS Values 5 I was astonished to read 5.3. Interpolated Color Values: the color-mix() notation

This specification extends the color-mix() functional notation as a mix notation accepting the following syntaxes: ``` = color-mix( && ?, , ) | color-mix( , [ && ?]#{2} ) ``` The used value of the first mix notation variant is equivalent to assigning the <progress> value, as a <percentage>, to the of the second <color> argument in the second variant. That is, color-mix(progress, color1, color2) is equivalent to color-mix(color1, color2 progress). See CSS Color 5 § 3 Mixing Colors: the color-mix() Function for the normative definition of the second variant.

Why is there a second "variant" of color-mix() defined, with zero discussion that I can recall, which is merely a permutation of the parameter order, and has zero tests in WPT, unlike the other "variant" which is widely implemented, with 1510 tests in WPT and part of Interop 2023?

SebastianZ commented 1 month ago

This was added in https://github.com/w3c/csswg-drafts/commit/0d8967a097ba06aeaba3375d636004b8e9575b08, which references the related discussions, especially https://github.com/w3c/csswg-drafts/issues/6245#issuecomment-1813010786. @fantasai can surely explain more. Though it looks like it was added as an initial draft for generalized interpolation functions while the discussion is still going on.

Sebastian

tabatkins commented 1 month ago

Thanks for digging up the ref, @SebastianZ! Yes, we discussed this last year; the reasoning is to give all the mixing functions a consistent grammar form so they can all benefit from all the mixing features, even if they have a legacy grammar that looks a little different.

svgeesus commented 1 month ago

Thanks, @SebastianZ and @tabatkins

So, are any browsers implementing this, or expressing interest?

tabatkins commented 1 month ago

At the moment, all of the mix functions are not yet implemented. But the mix functions in general have implementor interest; we needed them to solve font palette mixing, for example.