Skip to content

Commit a5111eb

Browse files
committed
add second example
1 parent 138fe14 commit a5111eb

1 file changed

Lines changed: 38 additions & 6 deletions

File tree

css-color-5/Overview.bs

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,15 @@ Mixing colors: the ''color-mix'' function {#colormix}
4747
in a given colorspace,
4848
by a specified amount.
4949

50+
Unless otherwise specified,
51+
the mixing is done in the ''lch()'' colorspace.
52+
53+
Multiple color functions can be specified.
54+
5055

5156
<pre class='prod'>
52-
<dfn>color-mix()</dfn> = color-mix( <<color>> <<color>> [ <<color-function>> <<colorspace>>? ]? )
57+
<dfn>color-mix()</dfn> = color-mix( <<color>> <<color>>
58+
[ <<number-percent>> | <<color-function>> <<colorspace>>? ]? )
5359
</pre>
5460

5561
<div class="example">
@@ -62,10 +68,36 @@ Mixing colors: the ''color-mix'' function {#colormix}
6268
<pre class="lang-css">mix-color(red, yellow, lightness(30%));</pre>
6369

6470
The calculation is as follows:
65-
* sRGB red (#F00) is lch(54.2917, 106.8390, 40.8526)
66-
* sRGB yellow (#FF0) is lch(97.6071, 94.7077, 99.5746)
67-
* mix lightness is 54.2917*.3 + 97.6071*.7 = 84.6125
68-
* mixed result is lch(84.6125, 106.8390, 40.8526)
69-
* which is a very light red (and outside the gamut of sRGB: rgb(218.081%, 22.5941%, 8.72667%))
71+
* sRGB red (#F00) is lch(54.2917 106.8390 40.8526)
72+
* sRGB yellow (#FF0) is lch(97.6071 94.7077 99.5746)
73+
* mix lightness is 54.2917 * 0.3 + 97.6071 * 0.7 = 84.6125
74+
* mixed result is lch(84.6125 106.8390 40.8526)
75+
* which is a very light red (and outside the gamut of sRGB: rgb(140.4967% 51.2654% 32.6891%))
7076
</div>
7177

78+
Instead of a list of color functions,
79+
a plain number or percentage can be specified,
80+
which applies to all color channels.
81+
82+
<div class="example">
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+

0 commit comments

Comments
 (0)