Skip to content

Commit c431211

Browse files
committed
[css-color-4] Split hue angle into its own section, allow NaN, fix w3c#5309
1 parent 561d918 commit c431211

1 file changed

Lines changed: 49 additions & 10 deletions

File tree

css-color-4/Overview.bs

Lines changed: 49 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,8 @@ Representing Colors: the <<color>> type</h2>
244244
such as the ''hsl()'' and ''lch()'' functions,
245245
or the long list of [=named colors=].
246246

247+
<h3 id="color-syntax">The <<color>> syntax</h3>
248+
247249
Colors are represented as a list of components,
248250
also sometimes called “channels”,
249251
representing axises in the color space.
@@ -269,6 +271,14 @@ Representing Colors: the <<color>> type</h2>
269271
<<lab()>>, <<lch()>>, and
270272
<<color()>>.
271273

274+
Of those, <<hsl()>>, <<hsla()>>, <<hwb()>> and <<lch()>>
275+
are cylindrical polar representations,
276+
which specify color using a <<hue>> angle,
277+
a central axis representing lightness
278+
(black-to-white),
279+
and a radius representing saturation or chroma
280+
(how far the color is from a neutral grey)
281+
272282
<!-- <<device-cmyk()>> does not actually specify a color; it can't be converted to Lab -->
273283

274284
For easy reference in other specifications,
@@ -277,6 +287,40 @@ Representing Colors: the <<color>> type</h2>
277287
but fully transparent--
278288
i.e. <nobr>''rgb(0 0 0 / 0%)''</nobr>.
279289

290+
<h3 id="hue-syntax">The <<hue>> syntax</h3>
291+
292+
Hue is represented as an angle of the color circle
293+
(the rainbow, twisted around into a circle).
294+
295+
<pre class='prod'>
296+
<dfn>&lt;hue></dfn> = <<number>> | <<angle>>
297+
</pre>
298+
299+
Because this value is so often given in degrees,
300+
the argument can also be given as a number,
301+
which is interpreted as a number of degrees.
302+
303+
The angles and spacing
304+
corresponding to particular hues
305+
depend on the colorspace.
306+
For example, in HSL and HWB, which use the sRGB colorspace,
307+
sRGB green is 120 degrees.
308+
In LCH, sRGB green is 134.39 degrees,
309+
display-p3 green is 136.01 degrees,
310+
a98-rgb green is 145.97 degrees
311+
and prophoto-rgb green is 141.04 degrees
312+
(because these are all different shades of green).
313+
314+
For colors very close to the neutral axis,
315+
the hue angle becomes indeterminate
316+
(for example, in Lab,
317+
minute changes in near-zero a and b values
318+
give huge changes in LCH hue angle).
319+
<span id="NaN-hue">Therefore, sometimes a hue angle of Nan
320+
(not a number) may be returned.</span>
321+
This impacts, for example,
322+
<a href="https://drafts.csswg.org/css-color-5/#hue-interpolation">hue interpolation</a>.
323+
280324
<h3 id="notes">
281325
Accessibility and Conveying Information By Color</h3>
282326

@@ -1068,20 +1112,15 @@ HSL Colors: ''hsl()'' and ''hsla()'' functions</h2>
10681112

10691113
<pre class='prod'>
10701114
<dfn>hsl()</dfn> = hsl( <<hue>> <<percentage>> <<percentage>> [ / <<alpha-value>> ]? )
1071-
<dfn>&lt;hue></dfn> = <<number>> | <<angle>>
10721115
</pre>
10731116

1074-
The first argument specifies the hue.
1075-
Hue is represented as an angle of the color circle
1076-
(the rainbow, twisted around into a circle).
1077-
The angle ''0deg'' represents red
1117+
The first argument specifies the hue angle.
1118+
1119+
In HSL (and HWB) the angle ''0deg'' represents sRGB primary red
10781120
(as does ''360deg'', ''720deg'', etc.),
10791121
and the rest of the hues are spread around the circle,
1080-
so ''120deg'' represents green,
1081-
''240deg'' represents blue, etc.
1082-
Because this value is so often given in degrees,
1083-
the argument can also be given as a number,
1084-
which is interpreted as a number of degrees.
1122+
so ''120deg'' represents sRGB primary green,
1123+
''240deg'' represents sRGB primary blue, etc.
10851124

10861125
The next two arguments are the saturation and lightness, respectively.
10871126
For saturation, ''100%'' is a fully-saturated, bright color,

0 commit comments

Comments
 (0)