Skip to content

Commit 3c37e6a

Browse files
committed
[css-color] update gray() section per SF meeting
1 parent 1b53318 commit 3c37e6a

File tree

1 file changed

+34
-49
lines changed

1 file changed

+34
-49
lines changed

css-color/Overview.bs

Lines changed: 34 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1464,55 +1464,7 @@ Examples of HWB Colors</h3>
14641464
</table>
14651465
</div>
14661466

1467-
1468-
<h2 id='grays'>
1469-
Specifying Grays: the ''gray()'' functional notation</h2>
1470-
1471-
Grays are a very special set of colors.
1472-
They're fully desaturated
1473-
(lacking any actual color at all),
1474-
which means that specifying a gray with any of the other notations requires specifying some redundant information:
1475-
if specifying the color with ''rgb()'', all three channels are identical;
1476-
if specifying the color with ''hsl()'', the hue is irrelevant and the saturation is locked to ''0%''.
1477-
1478-
The ''gray()'' functional notation simplifies specifying this common set of colors,
1479-
so that only the necessary information is required.
1480-
1481-
<pre class='prod'>
1482-
<dfn>gray()</dfn> = gray( [<<number>> | <<percentage>>] [, <<alpha-value>>]? )
1483-
</pre>
1484-
1485-
The first argument specifies the shade of gray,
1486-
while the second optional argument specifies the alpha channel of the color.
1487-
1488-
''gray(A)'' represents the same color as ''rgb(A,A,A)''.
1489-
''gray(A,B)'' represents the same color as ''rgb(A,A,A,B)''.
1490-
1491-
<div class='issue lang-javascript'>
1492-
<a>gray()</a> should have a keyword arg that opts it into smarter modes.
1493-
"luminance", for example, instead of being a simple expansion to ''rgb()'',
1494-
could actually compute the gray with the specified luminance.
1495-
The sRGB power curve means that grays are much darker than they "should" be;
1496-
50% gray has a luminance of .21, for example, rather than .5.
1497-
<!-- that seems to be confusing gamma correction, linear light intensity (luminance),
1498-
and perceptual lightness. -->
1499-
1500-
Reversing luminance to color is easy for grays:
1501-
if L &lt; .0774, <code>x * 12.92</code>;
1502-
otherwise, <code>(x ^ (5/12)) * 1.055 - .055</code>.
1503-
<!-- check, where does .0774 come from, should be .031308 -->
1504-
1505-
Alternately, base it on relative contrast ratios somehow?
1506-
#757575 is the gray that lives exactly between white and black, in contrast-ratio space.
1507-
1508-
Or use the L portion of Lab, where L=50 is a mid gray.
1509-
1510-
<!-- citation required -->
1511-
Taking 0% to be black, 100% to be white, and 50% to be #757575,
1512-
you convert between contrast-ratio space and luminance space
1513-
with <code>L = 21^p</code>,
1514-
then find the gray with that luminance.
1515-
</div>
1467+
15161468

15171469
<h2 id='lab-colors'>
15181470
Device-independent Colors: Lab and LCH</h2>
@@ -1652,6 +1604,39 @@ Converting LCH colors to Lab colors</h3>
16521604
<li>L is the same
16531605
</ol>
16541606

1607+
<h2 id='grays'>
1608+
Specifying Grays: the ''gray()'' functional notation</h2>
1609+
1610+
<p class="issue">As suggested at San Francisco, keep the syntax here but make
1611+
gray(number, alpha?) an alias to Lab with a=b=0. However, this should be
1612+
</p>
1613+
1614+
Grays are fully desaturated colors. The ''gray()'' functional notation simplifies
1615+
specifying this common set of colors, so that only a single numerical parameter
1616+
is required, and so that gray(50%) is a visual mid-gray (perceptually equidistant
1617+
between black and white).
1618+
1619+
1620+
<pre class='prod'>
1621+
<dfn>gray()</dfn> = gray( <<number>> [, <<alpha-value>>]? )
1622+
</pre>
1623+
1624+
The first argument specifies the shade of gray,
1625+
while the second optional argument specifies the alpha channel of the gray.
1626+
1627+
<h3 id='gray-to-rgb'>
1628+
Converting gray colors to sRGB colors</h3>
1629+
1630+
<p>Conversion from gray to sRGB requires multiple steps; in practice all
1631+
but the last step are linear calculations and can be combined.</p>
1632+
1633+
<ol>
1634+
<li>Convert to D65-adapted Lab by setting L to the gray value, a and b to 0
1635+
<li>Convert Lab to (D65-adapted) XYZ (<em>No</em> Bradford transform)
1636+
<li>Convert from (D65-adapted) CIE XYZ to linear sRGB
1637+
<li>Convert from linear-light sRGB to sRGB (do gamma correction)
1638+
</ol>
1639+
16551640
<h2 id='icc-colors'>
16561641
Profiled, Device-dependent Colors</h2>
16571642

0 commit comments

Comments
 (0)