@@ -79,14 +79,44 @@ Mixing colors: the ''color-mix'' function {#colormix}
7979 [ <<color-function>> <<colorspace>> ? ]?] )
8080</pre>
8181
82+ <div class="example">
83+ This example produces a mixture of 40% <span class="swatch" style="--color: peru"></span> peru
84+ and 60% <span class="swatch" style="--color: lightgoldenrod"></span> lightgoldenrod.
85+
86+ <pre class="lang-css"> mix-color(peru lightgoldenrod 40%)</pre>
87+
88+ The mixing is done in ''lch()'' colorspace.
89+ Here is a top-down view, looking along the neutral L axis:
90+
91+ <figure>
92+ <img src="images/CH-mixing.svg" style="width: 50vw">
93+ <figcaption> Mixtures of peru and lightgoldenrod.
94+ Peru has a hue angle, measured from the positive a axis,
95+ of 63.677 degrees
96+ while lightgoldenrod has a hue angle of 98.821 degrees.
97+ Peru has a chroma, or distance from the central neutral axis, of 54.011
98+ while lightgoldenrod has a chroma of 31.415.
99+ Mixtures lie along the curve. A 40%/60% mixture is shown.
100+ </figcaption>
101+ </figure>
102+
103+ The calculation is as follows:
104+ * <span class="swatch" style="--color: peru"></span> peru is lch(62.253% 54.011 63.677)
105+ * <span class="swatch" style="--color: lightgoldenrod"></span> lightgoldenrod is lch(91.374% 31.415 98.821)
106+ * the mixed lightness is 62.253 * 40/100 + 91.374 * (100-40)/100 = 79.7256
107+ * the mixed chroma is 54.011 * 40/100 + 31.415 * (100-40)/100 = 40.4534
108+ * the mixed hue is 63.677 * 40/100 + 98.821 * (100-40)/100 = 84.7634
109+ * the mixed result is <span class="swatch" style="--color: rgb(87.41% 76.03% 47.64%)"></span> lch(79.7256% 40.4534 84.7634)
110+ </div>
111+
82112<div class="example">
83113 This example produces the mixture of a deep green and a sky blue,
84114 in ''lch()'' colorspace (the default),
85115 with the lightness being 40% of the lightness of the green
86116 (and thus, 60% of the lightness of the blue).
87117 The chroma and hue of the green are left unchanged.
88118
89- <pre class="lang-css"> mix-color(rgb(0% 42.35% 33.33%) rgb(41.2% 69.88% 96.64%), lightness(40%));</pre>
119+ <pre class="lang-css"> mix-color(rgb(0% 42.35% 33.33%) rgb(41.2% 69.88% 96.64%) lightness(40%));</pre>
90120
91121 The calculation is as follows:
92122 * <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)
0 commit comments