Skip to content

Commit e3a202c

Browse files
committed
[css-color] Better define lab()/lch() argument syntax and handling. Fix lch()'s hue to use <<hue>>. Add an explanatory note to gray(). Fixes w3c#272.
1 parent a54f8b2 commit e3a202c

1 file changed

Lines changed: 45 additions & 18 deletions

File tree

css-color/Overview.bs

Lines changed: 45 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1530,7 +1530,8 @@ Device-independent Colors: Lab and LCH</h2>
15301530
LCH has the same L axis as Lab,
15311531
but uses polar coordinates C (chroma) and H (hue).
15321532
C is the geometric distance from the L axis
1533-
and H is the angle, in degrees, from the positive a axis.
1533+
and H is the angle from the positive a axis,
1534+
with positive angles being more clockwise.
15341535

15351536
Note: The Lightness axis in Lab should not be confused with the L axis in HSL.
15361537
For example, in HSL, the sRGB colors blue (#00F) and yellow (#FF0)
@@ -1552,30 +1553,53 @@ Specifying Lab and LCH: the lab() and lch() functional notations</h3>
15521553
<dfn>lab()</dfn> = lab( <<number>> <<number>> <<number>> [ / <<alpha-value>> ]? )
15531554
</pre>
15541555

1555-
The first argument specifies the CIE Lightness,
1556-
the second argument is a and the third is b.
1557-
L is constrained to the range [0, 100]
1558-
while a and b are signed values and theoretically unbounded
1556+
The first argument specifies the CIE Lightness.
1557+
This is typically a number between ''0''
1558+
(representing black)
1559+
and ''100''
1560+
(representing white),
1561+
similar to the lightness argument of ''hsl()''.
1562+
However, CIE Lightness <em>can</em> exceed this range on some systems,
1563+
with extra-bright whites using a lightness up to ''400''.
1564+
1565+
The second and third arguments are the distances along the "a" and "b" axises
1566+
in the Lab colorspace,
1567+
as described in the previous section.
1568+
These values are signed
1569+
(allow both positive and negative values)
1570+
and theoretically unbounded
15591571
(but in practice do not exceed ±160).
1572+
15601573
There is an optional fourth alpha value,
1561-
separated by a slash.
1574+
separated by a slash,
1575+
and interpreted identically to the <<alpha-value>> in ''rgb()''.
15621576

15631577
<pre class='prod'>
1564-
<dfn>lch()</dfn> = lch( <<number>> <<number>> <<number>> [ / <<alpha-value>> ]? )
1578+
<dfn>lch()</dfn> = lch( <<number>> <<number>> <<hue>> [ / <<alpha-value>> ]? )
15651579
</pre>
15661580

15671581
The first argument specifies the CIE Lightness,
1568-
the second argument is C and the third is H.
1569-
L is constrained to the range [0, 100].
1570-
C is an unsigned number, theoretically unbounded
1571-
(but in practice does not exceed 230).
1572-
H is constrained to the range [0, 360).
1573-
There is an optional fourth alpha value, separated by a slash.
1574-
1575-
Issue: Need to define handling for out of range numbers.
1576-
Clip L, wrap H?
1577-
Have also seen L up to 400,
1578-
specifically for high dynamic range situations.
1582+
interpreted identically to the Lightness argument of ''lab()''.
1583+
1584+
The second argument is the chroma
1585+
(roughly representing the "amount of color").
1586+
Its minimum useful value is ''0'',
1587+
while its maximum is theoretically unbounded
1588+
(but in practice does not exceed ''230'').
1589+
If the provided value is negative,
1590+
it is clamped to ''0''.
1591+
1592+
The third argument is the hue.
1593+
It's interpreted identically to the <<hue>> argument of ''hsl()'',
1594+
but doesn't map hues to angles in the same way.
1595+
Instead, ''0deg'' represents red (pointing along the positive "a" axis),
1596+
''90deg'' represents yellow (the positive "b" axis),
1597+
''180deg'' represents green (the negative "a" axis),
1598+
and ''270deg'' represents blue (the negative "b" axis).
1599+
1600+
There is an optional fourth alpha value,
1601+
separated by a slash,
1602+
and interpreted identically to the <<alpha-value>> in ''rgb()''.
15791603

15801604
Issue: Need to decide what, if anything, to do for high dynamic range on luminance.
15811605

@@ -1651,6 +1675,9 @@ Specifying Grays: the ''gray()'' functional notation</h2>
16511675
equal to the CIE Lightness,
16521676
while the second optional argument specifies the alpha channel of the gray.
16531677

1678+
Note: In other words,
1679+
''gray(a / b)'' is equal to ''lab(a 0 0 / b)''.
1680+
16541681
<h3 id='gray-to-rgb'>
16551682
Converting gray colors to sRGB colors</h3>
16561683

0 commit comments

Comments
 (0)