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

The non-normative, deliberately simplified, sample code can omit this subtlety but you are right, the "Converting" sections should state this clearly.

So [looking at real code](https://github.com/LeaVerou/color.js/blob/15a5dd0ad4b7f1cf7fb51b98d6fea6d87bb0b573/src/spaces/lch.js#L16-L34):

```js
  lab (Lab) {
   // Convert to polar form
   let [L, a, b] = Lab;
   let hue;
   const ε = 0.02;

   if (Math.abs(a) < ε && Math.abs(b) < ε) {
    hue = NaN;
   }
   else {
    hue = Math.atan2(b, a) * 180 / Math.PI;
   }

   return [
    L, // L is still L
    Math.sqrt(a ** 2 + b ** 2), // Chroma
    angles.constrain(hue) // Hue, in degrees [0 to 360)
   ];
  }
```


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


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

Received on Saturday, 20 March 2021 03:10:56 UTC