Re: [csswg-drafts] [css-color-5] How should negative percentages behave in color-mix()? (#6047)

> Going outside of the 0-100% range violates the mental model that this is mixing colors 

No, it really doesn't. Indeed the very first color equivalency mixing experiments in the 1920s and 30s utilized negative colors.

![mixing](https://www.sciencedirect.com/topics/engineering/color-matching-function)

> and makes this function behave differently than the other mixing functions (cross-fade() in particular). 

Firstly, `cross-fade()` is not the canonical definition of color mixing or or image compositing :) these have already been described in the literature since 1931 (CIE, mixing light) or 1984 (Porter-Duff)

- [CIE 1931 XYZ](https://www.sciencedirect.com/topics/engineering/color-matching-function)
- Thomas Porter; Tom Duff. Compositing digital images. July 1984. 

Secondly no, mixing light can and does have percentages below zero or greater than 100%. This can be easily visualized on a chromaticity diagram. The two colors to be mixed are represented as points on the u'v' plane, colors produced by interpolation lie on the straight line between them and extrapolated colors lie on the continuation of that line beyond the endpoints.

As an example, producing the secondary colors yellow, cyan and magenda from RGB primaries:

![example uv chromaticity diagram](https://drafts.csswg.org/css-color-4/images/UCS-display-p3.svg)

But obviously any two colors can be mixed, not just the primaries.

> The behavior y'all are describing isn't interpolation, either, it's arbitrary scaling and addition of the colors.

If you are outside the [0-100] range it is not linear interpolation but linear extrapolation. The math is entirely the same though. That aside, it is exactly mixing colors.

Having said all that, which expands on "This is easily defined" on the call, let me go back to my other point on the call "no-one really seems to be asking for this". Sam is implementing and just wanted it defined what happens when someone gives percentages outside [0% .. 100%]. The options are:

1. say its invalid, halt and catch fire
2. silently clip to the [0% .. 100%] range
3. just do the mixing math, which is the same as the interpolation math actually.

I don't much like option 1 but could get behind either 2. or 3.

Note that picking 2. locks us out of ever moving to 3. after a while, because of Web compat.

-- 
GitHub Notification of comment by svgeesus
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/6047#issuecomment-791802138 using your GitHub account


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

Received on Saturday, 6 March 2021 00:06:35 UTC