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-4] Does interpolation with achromatic colors truly have a "longer" arc? #9436

Closed
facelessuser opened this issue Oct 4, 2023 · 2 comments
Labels
Closed as Question Answered Used when the issue is more of a question than a problem, and it's been answered.

Comments

@facelessuser
Copy link

This question is in relation to the recently closed issue: #9224.

Based on the conversation there, it appears it was determined that Chrome was handling logic for interpolation with undefined hues correctly. So this question is to specifically clarify the point in the title.

I realize the original question was specifically asking about "transparent" colors, but the resolution there I believe translates to achromatic colors in general. My personal opinion is that the resolution leads to unexpected results.

Consider the following example which interpolates a red color with black.

linear-gradient(to right in oklch longer hue, oklch(0.628 0.26 29.23), oklch(0 0 none / 1));

Results in Chrome

Screenshot 2023-10-04 at 6 27 50 AM

https://codepen.io/facelessuser/pen/MWZPmwy

Because the undefined hue is resolved to inherit the hue of the red color before the hue fix-up, we now get an interpolation around the entire color wheel, as if there was an arc between black and red. The reality is that achromatic colors have no hue; therefore, they have no arc between any hue.

Based on the conversation in #9224, my understanding is that this is indeed "correct" for CSS, even though it seems unintuitive, at least to me.

While Safari may be wrong in its implementation, it seems intuitive. In their case, it seems the undefined hue is not resolved until after the hue fix-up.

Screenshot 2023-10-04 at 6 34 19 AM

So, this is simply to clarify whether this behavior, conceptually, is truly the intention of the CSS spec or not, outside of which browser implemented the spec correctly.

@svgeesus
Copy link
Contributor

svgeesus commented Oct 4, 2023

So this:

Screenshot 2023-10-04 at 6 34 19 AM

looks like a correct implementation if shorter was specified. The hues are the same and the interpolation curve in Oklch is a straight line from red to black.

If shorter evaluates to zero degrees of hue difference, then clearly longer will evaluate to 360 degrees - the long way round.

@facelessuser
Copy link
Author

Okay, so achromatic hues are treated as having an arc then. That answers my question, even if I disagree. Thanks!

@svgeesus svgeesus added the Closed as Question Answered Used when the issue is more of a question than a problem, and it's been answered. label Oct 4, 2023
facelessuser added a commit to facelessuser/color.js that referenced this issue Oct 11, 2023
- The color.js API states that mix takes the same arguments as `range`
  but all options were not getting passed, `hue` being an example.
- Clarification about the CSS spec mentions that when interpolating
  an undefined hue and defined hue that the undefined handling should
  be done before hue fix-up which would create both a shorter and
  longer arc between an undefined and defined hue.
  w3c/csswg-drafts#9436 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Closed as Question Answered Used when the issue is more of a question than a problem, and it's been answered.
Projects
None yet
Development

No branches or pull requests

2 participants