Skip to content

Commit 8c4867d

Browse files
committed
[css-color-5] Add example, w3c#8499
1 parent b4c7ee4 commit 8c4867d

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

css-color-5/Overview.bs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -974,6 +974,39 @@ so it has meaningful values for the channels.</p>
974974
which determines how "colorful" the color is.)
975975
</div>
976976

977+
<div class="example" id="ex-no-percentage-magic">
978+
<p>Beware when using components outside their normal position;
979+
when percentages are resolved,
980+
there is no "magic scaling"
981+
to account for the changed position.
982+
For example,</p>
983+
984+
<pre>
985+
color: color(from color(srgb 0 0 0 / 60%) srgb alpha 0.6 0.6 / 0.9);
986+
</pre>
987+
988+
<p>The alpha component is resolved as a <<number>>,
989+
giving 0.6; thus the resulting color is
990+
<span class="swatch" style="--color: rgb(60% 60% 60% / 0.9)"></span> ''color(srgb 0.6 0.6 0.6 / 0.9)''.
991+
</p>
992+
993+
<p>However, in this second example, again the alpha resolves to 0.6,
994+
giving a very different color due to the color component range in
995+
legacy rgb() syntax:
996+
</p>
997+
998+
<pre>
999+
color: rgb(from rgb(0 0 0 / 60%) alpha 153 153 / 0.9);
1000+
</pre>
1001+
1002+
<p>which results in
1003+
<span class="swatch" style="--color: rgb(0.235% 60% 60% / 0.9)"></span> ''rgb(0.6 153 153 / 0.9)''
1004+
and not
1005+
<span class="swatch" style="--color: rgb(153 153 153 / 0.9)"></span> ''rgb(153 153 153 / 0.9)''.
1006+
</p>
1007+
1008+
</div>
1009+
9771010
Missing components are handled the same way as with
9781011
[[css-color-4#interpolation-missing]]:
9791012
the origin colorspace and the relative function colorspace

0 commit comments

Comments
 (0)