[csswg-drafts] [css-color-5] Why is <hue-adjuster> at the end of color-mix()? (#6772)

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

== [css-color-5] Why is <hue-adjuster> at the end of color-mix()? ==
The [color-mix()](https://drafts.csswg.org/css-color-5/#color-mix) grammar is currently defined as:

```
color-mix() = color-mix( in <color-space> , [ <color> && <percentage [0,100]>? ]#{2} <hue-adjuster>?)
```

This implies that a correct instance could be something like:

```
color-mix(in hsl, red 20%, blue 50% shortest)
```

This looks really weird imo! The 'shortest' appears to be applying to the blue color, but it's actually applying to "in hsl" part, as a part of the directions for how to interpolate the two colors.

This grammar also implies that I can provide a hue-adjuster for any color space, like:

```
color-mix(in srgb, red 20%, blue 50% shortest)
```

which doesn't do anything and seems confusing.

I suggest we move the `<hue-adjuster>` to the first term of the function, with the color space name, and only allow it as part of the cylindrical spaces. The grammar would instead look like:

```
<color-mix()> = color-mix( in <color-mix-space> , [ <color> && <percentage [0,100]>? ]#{2})
<color-mix-space> = <color-mix-rect-space> | <color-mix-hue-space>
<color-mix-rect-space> = srgb | xyz | lab | oklab
<color-mix-hue-space> = [ hsl | hwb | lch | oklch ] && <color-mix-hue-adjuster>?
<color-mix-hue-adjuster> = shorter | longer | increasing | decreasing | specified
```

The above example would then be written as:

```
color-mix(in hsl shortest, red 20%, blue 50%)
/* or with "in shortest hsl" */
```

and the similar "in srgb" example wouldn't be able to take an adjuster at all.

(I think the ability to reorder the space name and hue adjuster seems reasonable, but it's not necessary; we could just use concatenation rather than `&&` if we want to force an ordering.)

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


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

Received on Wednesday, 27 October 2021 22:25:05 UTC