@@ -256,6 +256,38 @@ and a percentage of 100% returns the same color converted to the specified color
256256 * which is a slightly-blueish green: <span class="swatch" style="--color: rgb(7.7377% 52.5730% 37.3213%)"></span> rgb(7.7377% 52.5730% 37.3213%)
257257</div>
258258
259+ The choice of mixing colorspace can have a large effect on the end result.
260+
261+ <div class="example" id="ex-mix-colorspaces-black-white">
262+ <!--
263+ https://colorjs.io/notebook/?storage=https%3A%2F%2Fgist.github.com%2Fsvgeesus%2F6e9bc5c573fc5afcb11e9ab47c6e1e2f
264+ -->
265+ This example is a 50% mix of white and black,
266+ in three different color spaces.
267+
268+ <pre class="lang-css">
269+ color-mix(in lch, white, black);
270+ color-mix(in xyz, white, black);
271+ color-mix(in srgb, white, black);
272+ </pre>
273+
274+ The calculation is as follows:
275+ * sRGB <span class="swatch" style="--color: white"></span> white (#008080) is lch(100% 0 0)
276+ * sRGB <span class="swatch" style="--color: black"></span> black (#808000) is lch(0% 0 0)
277+ * The mix in LCH is <span class="swatch" style="--color: rgb(47% 47% 47%"></span> lch(50% 0 0)
278+ * The mix in XYZ is <span class="swatch" style="--color: rgb(74% 74% 74%"></span> lch(76% 0 0)
279+ * The mix in sRGB is <span class="swatch" style="--color: rgb(50% 50% 50%"></span> lch(53.4% 0 0)
280+
281+ The mix in LCH gives an L value of 50%,
282+ a perfect mid gray, exactly as expected
283+ (mixing in Lab would do the same,
284+ as the Lightness axis is the same in LCH and Lab).
285+
286+ The mix in XYZ gives a result that is too light;
287+ XYZ is linear-light but is not perceptually uniform.
288+ The mix in sRGB gives a result that is a bit too light;
289+ sRGB is neither perceptually uniform nor linear-light.
290+ </div>
259291<!--
260292Let's move this example to the appropriate section when we have the new syntax for making these low-level adjustments
261293<div class="example">
0 commit comments