4 ms·
On the frontend, one thing that I discovered when implementing color spaces into my canvas library was that the CSS HWB standard[1] allows the hue part of a col
by rikroots 4y ago
On the frontend, one thing that I discovered when implementing color spaces into my canvas library was that the CSS HWB standard[1] allows the hue part of a color (which is an angle value) to be supplied supplied as either 'Ndeg', 'Nrad', 'Ngrad' or 'Nturn' values. Other CSS color spaces involving hue don't see to accept 'turn' (though I could be misunderstanding them).
[1] - https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/hwb https://developer.mozilla.org/en-US/docs/Web/CSS/color_value...
- chrismorgan 4y agoYou’re misunderstanding things. CSS is typed, and deg/rad/grad/turn are all just angle units; anything that takes an <angle> supports angles in any unit. hsl(0.5turn 100% 50%) is equivalent to hsl(180deg 100% 50%) and #00ffff (and infinite other spellings). When it was introduced, hsl() only took a <number> for hue, which was interpreted as degrees, but it has had proper <angle> support for over a decade (apart from Opera which only got it with the switch to Chromium in 2013). The current state of affairs is `<hue> = <number> | <angle> | none` (https://drafts.csswg.org/css-color-4/#hue-syntax https://drafts.csswg.org/css-color-4/#hue-syntax), and <hue> is used by hsl(), hsla(), hwb(), lch() and oklch().
- rikroots 4y agoAh! Thanks for the explanation. I'll need to fix this in my library.
- chrismorgan 4y agoI recommend reading specs regularly when doing anything like this. Web specs are generally pretty approachable, and they generally match implementations very closely these days (largely because the implementers are the spec-writers, which wasn’t so much the case before, say, the HTMLL5 effort), with the caveat that parts of these drafts precede the implementations and thus may end up being altered due to implementation experience.