[csswg-drafts] [css-color-4] Achromatic colors converted to hue-ish spaces should treat hue as "missing", not NaN (#6107)

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

== [css-color-4] Achromatic colors converted to hue-ish spaces should treat hue as "missing", not NaN ==
In <https://drafts.csswg.org/css-color-4/#hue-syntax> it's stated that:

> For colors very close to the neutral axis, the hue angle becomes indeterminate (for example, in Lab, minute changes in near-zero a and b values give huge changes in LCH hue angle). Therefore, sometimes a hue angle of NaN (not a number) may be returned.

Then this is later referenced in [interpolation](https://drafts.csswg.org/css-color-4/#hue-interpolation):

> If one of the angles has the value NaN, then for interpolation, NaN is replaced by the value of the other hue angle. If both angles have the value NaN, then for interpolation, NaN is replaced by the value 0 for both angles.

The *intent* of this spec text is good and correct; it means interpolating from gray to green in LCH just becomes greener, rather than interpolating the hue from red to green or something.

However, the exact mechanics of this aren't workable. `NaN` is limited to existing within the bounds of a calculation; [it gets censored to `infinity` if it would escape](https://drafts.csswg.org/css-values/#top-level-calculation). So we can't have a `NaN` value just hanging out in normal CSS values. I think instead this should be phrased as achromatic colors having a "missing" hue, and then interpolation can key off of whether the hue is "missing".

Even if `NaN` did persist into normal CSS values, I don't think we actually want to merge "calculation for the angle yields NaN" with "achromatic color interpolates with chromatic color"; the latter is a common non-error case with an obvious solution, while the former is explicitly the result of a bad or nonsensical calculation with no obvious answer. So we really shouldn't be keying off of `NaN` anyway; a "real" `NaN` should be treated the same as an `infinity` (which it luckily censors itself into already), where it's an error case that just has an arbitrary answer (per #6105, effectively `0deg`).

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


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

Received on Wednesday, 17 March 2021 16:59:01 UTC