Skip to content

Commit f5587c5

Browse files
committed
[css-color-5] add syntactic equivalence example
1 parent 19feaee commit f5587c5

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

css-color-5/Overview.bs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,30 @@ Mixing colors: the ''color-mix()'' function {#color-mix}
143143
and
144144
<var>p2</var> becomes <var>p2</var> / (<var>p1</var> + <var>p2</var>).
145145

146+
<div class="example">
147+
These syntactic forms are thus all equivalent:
148+
149+
<pre class="lang-css">
150+
color-mix(in lch, purple 50%, plum 50%)
151+
color-mix(in lch, purple 50%, plum)
152+
color-mix(in lch, purple, plum 50%)
153+
color-mix(in lch, purple, plum)
154+
color-mix(in lch, plum, purple)
155+
color-mix(in lch, purple 80%, plum 80%)
156+
</pre>
157+
158+
All produce a 50-50 mix of <span class="swatch" style="--color: purple"></span> purple and <span class="swatch" style="--color: plum"></span> plum,
159+
in lch: <span class="swatch" style="--color: rgb(68.51%, 36.01%, 68.29%)"></span> lch(51.51% 52.21 325.8) which is <span class="swatch" style="--color: rgb(68.51%, 36.01%, 68.29%)"></span> rgb(68.51% 36.01% 68.29%).
160+
161+
However, this form is <em>not</em> the same, as the alpha is less than one:
162+
163+
<pre class="lang-css">
164+
color-mix(in lch, purple 30%, plum 30%)
165+
</pre>
166+
167+
This produces <span class="swatch" style="--color: rgb(68.51%, 36.01%, 68.29%, 0.6)"></span> lch(51.51% 52.21 325.8 / 0.6) which is <span class="swatch" style="--color: rgb(68.51%, 36.01%, 68.29%, 0.6)"></span> rgb(68.51% 36.01% 68.29% / 0.6).
168+
</div>
169+
146170
After normalizing both percentages, the result is produced via the following algorithm:
147171

148172
1. Both colors are converted to the specified <<color-space>>.

0 commit comments

Comments
 (0)