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

> This discussion made me wonder why none of the JS libraries use undefined or null to represent undefined hues, and use NaN instead. 

In [culori.js](https://culorijs.org) I use `undefined` (by way of omitting the object property) for:

* `h` (hue) in achromatic colors
* `alpha` of colors strings that don't contain an explicit opacity

(Mostly a stylistic choice, `NaN` / `undefined` / `null` all have some sort of tradeoff in arithmetic or JSON serialization.)

> And can missing ever occur in (scriptless) CSS and how does it get represented there? Can I say lch(50, 1, missing) and if so what stops me saying lch(50, 100, missing) which is not a color?

I know this is just the old `gray()` syntax with a fake mustache, but what if `lch()` colors are only valid if you omit both the chroma and the hue? e.g. `lch(50)` fills in the missing gaps with `lch(50, 0, missing)`. I would find the syntax valuable for placing an achromatic color in a gradient and have it pick up the hues of its adjacent color stops.

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


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

Received on Saturday, 4 September 2021 07:25:27 UTC