[csswg-drafts] [css-values] Alternative, weighted mean syntax for `calc-mix()` (#9658)

Crissov has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-values] Alternative, weighted mean syntax for `calc-mix()` ==
This started out as a comment to #9343 and is obviously a revival of my suggestion in #4700. 

With their shared use of a single `<progress>` parameter, the [_mix_ functions](https://drafts.csswg.org/css-values-5/#mixing) are currently all limited to two values, _start_ and _end_. While some individual alternative syntaxes support specifying a weight per entry, `calc-mix()` does not.

The alternative syntax of the image mix function `cross-fade()` even supports mixing an arbitrary number of (weighted) images – this includes colors, while the color blending function `color-mix()` is restricted to two values. 

1. If this is useful for images, I would expect that authors would sometimes find a need to mix together multiple values of other types as well. 
2. If the WG agreed with this assumption, `calc-mix()` in particular would need an alternative syntax. Alas, this could not use the established notation for the weights of values, because ”20% 80%“ would be ambiguous.
(Note that the optional weight, `<percentage [0,100]>?`, precedes the value in the grammar for `cross-fade()` and follows it for `color-mix()`, but `&&` means ‘any order’.) 
For linear interpolation of percentages, the order might be irrelevant, but authors may want different ones. 
3. If this was the case indeed, the best way to allow more interpolation methods would probably be to support the various kinds of weighted means (arithmetic, geometric, harmonic, …) – or a generalized mean. #4700
4. If syntax for means was to be introduced, ”calc-mix“ may not the best choice of a name. 

## Compilation of current grammar

~~~~ ebnf
<calc-mix()> = 
  calc-mix( <progress>, <calc-sum>, <calc-sum> )

<color-mix()> =
  color-mix( <progress> && <color-interpolation-method>?, <color>, <color> ) 
  |
  color-mix( <color-interpolation-method>, [<color> && <percentage [0,100]>?]#{2} )

<cross-fade()> =
  cross-fade( <progress>, [ <image> | <color> ], [ <image> | <color> ] ) 
  |
  cross-fade( <cf-image># )
<cf-image> = <percentage [0,100]>? && [ <image> | <color> ]

<transform-mix()> = 
  transform-mix( <progress>, <transform-list>, <transform-list> )

<mix()> =
  mix( <progress> ';' <whole-value> ';' <whole-value> ) 
  |
  mix( <progress> && of <'animation-name'> )
~~~~

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/9658 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Thursday, 30 November 2023 09:21:39 UTC