Skip to content
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

[css-color-5] : mix blue and white #44601

Conversation

romainmenke
Copy link
Contributor

@romainmenke romainmenke commented Feb 15, 2024

I somehow assumed that this was already covered and fixed but it wasn't :)

Implementations do very weird things when mixing white and other colors in polar color spaces.

I've also made a couple of codepens which make it easier to see how each implementation does its own thing today.

OKLCH :

https://codepen.io/romainmenke/pen/NWEaKpL

Webkit:

Screenshot 2024-02-15 at 09 10 33

Blink:

Screenshot 2024-02-15 at 09 10 52

Gecko (doesn't support gradients yet):

Screenshot 2024-02-15 at 09 11 10

And the same for LCH :

https://codepen.io/romainmenke/pen/qBvLQJV

Here Gecko produces almost pure red, which is odd :

Screenshot 2024-02-15 at 09 12 39

@svgeesus
Copy link
Contributor

Thanks for these. The cause is a failure to correctly implement CSS Color 4 Interpolating with Missing Components.

This can be seen by changing

#a {
  background: color-mix(in oklch, blue, transparent);
  height: 50px;
}

to

#a {
  background: color-mix(in oklch, blue, oklch(0 0 none / 0);
  height: 50px;
}

or

#b {
  background: linear-gradient(to right in oklch, transparent, blue);
  height: 50px;
}

to

#b {
  background: linear-gradient(to right in oklch, oklch(0 0 none / 0), blue);
  height: 50px;
}

which makes no visual difference. So the conversion of transparent to transparent black to the oklch color (with missing hue) is being done correctly, but this part is not being done:

If a color with a carried forward missing component is interpolated with another color which is not missing that component, the missing component is treated as having the other color’s component value.

Instead a hue angle of 0 is being created to interpolate from, giving the magenta-ish reds.

@svgeesus svgeesus merged commit 96f5143 into web-platform-tests:master Feb 16, 2024
19 checks passed
@romainmenke romainmenke deleted the css-color-5--mix-with-white--ambitious-gar-a4391ee7ca branch February 16, 2024 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants