Skip to content

Commit

Permalink
[css-color-5] define serialization of results, see #6206
Browse files Browse the repository at this point in the history
  • Loading branch information
svgeesus committed Jun 19, 2021
1 parent 09d3732 commit de3dab7
Showing 1 changed file with 49 additions and 7 deletions.
56 changes: 49 additions & 7 deletions css-color-5/Overview.bs
Expand Up @@ -1102,12 +1102,12 @@ the allowed [=channel keywords=] are:
after its conversion to relative, D50-adapted CIE XYZ color space.

<!--
██████ ████████ ████████ ████ ███ ██
██ ██ ██ ██ ██ ██ ██ ██ ██
██ ██ ██ ██ ██ ██ ██ ██
██████ ██████ ████████ ██ ██ ██ ██
██ ██ ██ ██ ██ █████████ ██
██ ██ ██ ██ ██ ██ ██ ██ ██
██████ ████████ ████████ ████ ███ ██
██ ██ ██ ██ ██ ██ ██ ██ ██
██ ██ ██ ██ ██ ██ ██ ██
██████ ██████ ████████ ██ ██ ██ ██
██ ██ ██ ██ ██ █████████ ██
██ ██ ██ ██ ██ ██ ██ ██ ██
██████ ████████ ██ ██ ████ ██ ██ ████████
-->

Expand Down Expand Up @@ -1154,6 +1154,11 @@ The string "." shall be used as a decimal separator,
regardless of locale,
and there shall be no thousands separator.

As usual,
if the alpha of the result is exactly 1,
it is omitted from the serialization;
an implicit value of 1 (fully opaque) is the default.


Serializing color-mix() {#serial-color-mix}
-------------------------------------------
Expand Down Expand Up @@ -1193,7 +1198,18 @@ depends on the color space specified with "in".
<td>lch</td>
<td>lch(l c h)</td>
</tr>
</table>

<div class="example">
The result of this color mixture
<pre>color-mix(in lch, peru 40%, palegoldenrod)</pre>
is serialized as the string <span class="swatch" style="--color: rgb(87.416% 76.036% 47.637%)"></span>
"lch(79.7256% 40.448 84.771)"
while the result of
<pre>color-mix(in srgb, peru 40%, palegoldenrod)</pre>
is serialized as the string <span class="swatch" style="--color: rgb(88.16% 75.45% 49.88%)"></span>
"color(srgb 0.8816 0.7545 0.4988)".
</div>


Serializing color-contrast() {#serial-color-contrast}
Expand All @@ -1206,16 +1222,42 @@ The form used
is the same as that used to specify
the winning color.

<div class="example">
The winner of this contrast choice
<pre>color-contrast(wheat vs olive, sienna, maroon)</pre>
is maroon,
so the result is serialized as
<span class="swatch" style="--color: maroon"></span>
"rgb(128 0 0)".

While the winner of
<pre>color-contrast(wheat vs color(prophoto-rgb 0.4 0.4 0.2), color(display-p3 0.45 0.08 0.05))</pre>
is color(display-p3 0.45 0.08 0.05),
so the result is serialized as
<span class="swatch" style="--color: rgb(49.277% 0.414% 0.524%)"></span>
"color(display-p3 0.45 0.08 0.05)".
</div>

Serializing relative color-mix() {#serial-color-mix}
----------------------------------------------------

The serialization of the result of a relative color function
is a <<color>>,
as defined in [[css-color-4#serializing-color-values]].
The form used
is the same as that used to specify
the relative color.
the relative color,
but using the absolute form.

<div class="example">
The result of serializing
<pre>lch(from peru calc(l * 0.8) calc(c * 0.7) calc(h + 180)) </pre>
is the string
<span class="swatch" style="--color: rgb(3.12% 50.352% 68.894%)"></span>
"lch(49.80224% 37.80819 243.6803)"

</div>



<!--
Expand Down

0 comments on commit de3dab7

Please sign in to comment.