@@ -11,6 +11,7 @@ Editor: Chris Lilley, W3C, chris@w3.org, w3cid 1438
1111Editor : Una Kravets, Google
1212Editor : Lea Verou, Invited Expert, http://lea.verou.me/about, w3cid 52258
1313Abstract : This module extends CSS Color [[css-color-4]] to add color modification functions.
14+ Repository : w3c/csswg-drafts
1415</pre>
1516
1617Introduction {#intro}
@@ -79,24 +80,39 @@ a plain number or percentage can be specified,
7980which applies to all color channels.
8081
8182<div class="example">
82- This example produces the mixture of red and yellow,
83- in ''lch'' colorspace (the default),
84- with each lch channel being 65% of the value for red
85- and 35% of the value for yellow.
86-
87- Note: interpolating on hue and chroma
88- keeps the intermediate colors
89- as saturated as the endpoint colors.
90-
91- <pre class="lang-css"> mix-color(red, yellow, 65%);</pre>
92-
93- The calculation is as follows:
94- * sRGB red (#F00) is lch(54.2917 106.8390 40.8526)
95- * sRGB yellow (#FF0) is lch(97.6071 94.7077 99.5746)
96- * mix lightness is 54.2917 * 0.65 + 97.6071 * 0.35 = 69.4521
97- * mix chroma is 106.83 * 0.65 + 94.7077 * 0.35 = 102.5872
98- * mix hue is 40.8526 * 0.65 + 99.5746 * 0.35 = 61.4053
99- * mixed result is lch(69.4521 102.5872 61.4053)
100- * which is a red-orange: rgb(75.3600% 65.6304% 16.9796%)
83+ This example produces the mixture of red and yellow,
84+ in ''lch'' colorspace (the default),
85+ with each lch channel being 65% of the value for red
86+ and 35% of the value for yellow.
87+
88+ Note: interpolating on hue and chroma
89+ keeps the intermediate colors
90+ as saturated as the endpoint colors.
91+
92+ <pre class="lang-css"> mix-color(red, yellow, 65%);</pre>
93+
94+ The calculation is as follows:
95+ * sRGB red (#F00) is lch(54.2917 106.8390 40.8526)
96+ * sRGB yellow (#FF0) is lch(97.6071 94.7077 99.5746)
97+ * mix lightness is 54.2917 * 0.65 + 97.6071 * 0.35 = 69.4521
98+ * mix chroma is 106.83 * 0.65 + 94.7077 * 0.35 = 102.5872
99+ * mix hue is 40.8526 * 0.65 + 99.5746 * 0.35 = 61.4053
100+ * mixed result is lch(69.4521 102.5872 61.4053)
101+ * which is a red-orange: rgb(75.3600% 65.6304% 16.9796%)
102+ </div>
103+
104+ Selecting the most contrasting color: the ''color-contrast()'' function {#colorcontrast}
105+ ========================================================================================
106+
107+ This function takes, firstly, a single color
108+ (typically a background, but not necessarily),
109+ and then second, a list of two or more colors;
110+ it selects from the list of colors
111+ the one with highest luminance contrast
112+ to the single color.
113+
114+ <div class="example">
115+ <pre class="lang-css"> color-contrast(wheat tan, sienna, var(--myAccent), #d2691e)</pre>
116+
101117 </div>
102118
0 commit comments