@@ -7,7 +7,7 @@ Group: csswg
77TR : https://www.w3.org/TR/css-color-5/
88ED : https://drafts.csswg.org/css-color-5/
99Work Status : exploring
10- Delta Spec : yes
10+ ! Delta Spec : yes
1111Editor : Chris Lilley, W3C, chris@w3.org, w3cid 1438
1212Editor : Una Kravets, Google, https://una.im, w3cid 115525
1313Editor : Lea Verou, Invited Expert, http://lea.verou.me/about, w3cid 52258
@@ -80,35 +80,67 @@ Mixing colors: the ''color-mix'' function {#colormix}
8080</pre>
8181
8282<div class="example">
83- This example produces the mixture of red and white ,
83+ This example produces the mixture of a deep green and a sky blue ,
8484 in ''lch()'' colorspace (the default),
85- with the lightness being 50% of the lightness of red
86- (and thus, 50% of the lightness of white ).
87- The chroma and hue of red are left unchanged.
85+ with the lightness being 50% of the lightness of the green
86+ (and thus, 50% of the lightness of the blue ).
87+ The chroma and hue of the green are left unchanged.
8888
89- <pre class="lang-css"> mix-color(red, white , lightness(50%));</pre>
89+ <pre class="lang-css"> mix-color(rgb(0% 42.35% 33.33%), rgb(41.2% 69.88% 96.64%) , lightness(50%));</pre>
9090
9191 The calculation is as follows:
92- * sRGB red (#F00) is lch(54.2917 106.8390 40.8526)
93- * sRGB white (#FFF) is lch(100 0 0)
94- * mix lightness is 54.2917 * 0.5 + 100 * 0.5 = 77.14585
95- * mixed result is lch(77.14585 81.95 37.192)
96- * which results in a lighter red, like a Salmon color
92+ * <span class="swatch" style="--color: rgb(0% 42.35% 33.33%)"></span> rgb(0% 42.35% 33.33%) is lch(40.083% 32.808 171.175)
93+ * <span class="swatch" style="--color: rgb(41.2% 69.88% 96.64%)"></span> rgb(41.2% 69.88% 96.64%) is lch(70% 42.5 258.2)
94+ * mix lightness is 40.083 * 0.5 + 70% * 0.5 = 55.0415
95+ * mixed result is <span class="swatch" style="--color: rgb(22.87% 57.56% 47.73%)"></span> lch(55.0415 32.808 171.175)
96+ * which is a <span class="swatch" style="--color: rgb(22.87% 57.56% 47.73%)"></span> rgb(22.87% 57.56% 47.73%), a lighter green
97+
98+ </div>
99+
100+ <div class="example">
101+ This example produces the mixture of a red and a sky blue,
102+ in ''lch()'' colorspace (the default),
103+ with the hue being 38% of that of the red
104+ (and thus, 62% of that of the blue).
105+ The chroma and lightness of the red are left unchanged.
97106
98- <!-- this is out of gamut, so unsuitable as a first example
99- salmon =[77.14585, 81.95, 37.192]
100- Array(3) [ 77.14585, 81.95, 37.192 ]
107+ <pre class="lang-css"> mix-color(rgb(82.02% 30.21% 35.02%), rgb(5.64% 55.94% 85.31%), hue(75.23%));</pre>
101108
102- salmon_sRGB=LCH_to_sRGB(salmon)
103- Array(3) [ 1.2120451417178173, 0.5158157138581139, 0.40505102735813037 ]
104- notice the 1.21 (121%)
105- -->
109+ The calculation is as follows:
110+ * <span class="swatch" style="--color: rgb(82.02% 30.21% 35.02%)"></span> rgb(82.02% 30.21% 35.02%) is lch(52% 58.1 22.7)
111+ * <span class="swatch" style="--color: rgb(5.64% 55.94% 85.31%)"></span> rgb(5.64% 55.94% 85.31%) is lch(56% 49.1 257.1)
112+ * mix hue is 22.7 * 0.7523 + 257.1 * 0.2477 = 80.76
113+ * mixed result is <span class="swatch" style="--color: rgb(61.11% 45.85% 0.41%)"></span> lch(52% 58.1 80.76) which is rgb(61.11% 45.85% 0.41%)
106114
107- <!-- showing out of gamut colors next -->
115+ </div>
116+
117+ <div class="example">
118+ This example produces the mixture of
119+ the same two colors as the previous example
120+ (a red and a sky blue),
121+ in ''lch()'' colorspace (the default),
122+ with the hue being 38% of that of the red
123+ (and thus, 62% of that of the blue).
124+ This time, the lightness is set to 68.4% and
125+ the chroma is left unchanged.
126+
127+ <pre class="lang-css"> mix-color(rgb(82.02% 30.21% 35.02%), rgb(5.64% 55.94% 85.31%), hue(75.23%) lightness(68.4%));</pre>
128+
129+ The calculation is as follows:
130+ * <span class="swatch" style="--color: rgb(82.02% 30.21% 35.02%)"></span> rgb(82.02% 30.21% 35.02%) is lch(52% 58.1 22.7)
131+ * <span class="swatch" style="--color: rgb(5.64% 55.94% 85.31%)"></span> rgb(5.64% 55.94% 85.31%) is lch(56% 49.1 257.1)
132+ * mix hue is 22.7 * 0.7523 + 257.1 * 0.2477 = 80.76
133+ * new lightness is 68.4%
134+ * mixed result is <span class="swatch" style="--color: rgb(79.67% 62.48% 22.09%)"></span> lch(68.4% 58.1 80.76) which is rgb(79.67% 62.48% 22.09%)
108135
109136</div>
110137
111- <img src="images/mix_red_white_lightness50.png" alt="Result of mix-color(red, white, lightness(50%)" />
138+ <!-- number | percent is ambiguous for lightness because lightness is itself a percentage -->
139+
140+ <!-- showing out of gamut colors next -->
141+
142+
143+ <!-- <img src="images/mix_red_white_lightness50.png" alt="Result of mix-color(red, white, lightness(50%)" /> -->
112144
113145<div class="example">
114146 This example produces the mixture of red and yellow,
0 commit comments