Skip to content

Commit 9af0cb8

Browse files
svgeesusannevk
andcommitted
[css-color-4] Add corrected examples for HTML-compatible serialization w3c#10550
Co-authored-by: Anne van Kesteren <annevk@annevk.nl>
1 parent 5efa2c4 commit 9af0cb8

File tree

1 file changed

+24
-15
lines changed

1 file changed

+24
-15
lines changed

css-color-4/Overview.bs

+24-15
Original file line numberDiff line numberDiff line change
@@ -6216,37 +6216,46 @@ Serializing sRGB values</h3>
62166216
A seven-character string consisting of the character "#", followed immediately by the two-digit hexadecimal representations of the red component, the green component, and the blue component, in that order, using <a href="https://infra.spec.whatwg.org/#ascii-lower-hex-digit">ASCII lower hex digits</a>. No spaces are permitted.
62176217

62186218
<div class="example" id="ex-canvas-srgb">
6219-
For example, the pixel value from a canvas 2D context
6220-
using the sRGB colorspace is returned as a Uint8ClampedArray:
6219+
For example, fill style is set to <span class="swatch" style="--color: rgb(255, 0, 255)"></span> magenta:
62216220

62226221
<pre lang-js>
6223-
imageData = context.getImageData(0, 0, 1, 1);
6224-
console.log(imageData.colorSpace); // "srgb"
6225-
console.log([...imageData.data]); // [37, 164, 87, 255]
6222+
context.fillStyle = "rgb(255, 0, 255)"
6223+
console.log(context.fillStyle); // "#ff00ff"
62266224
</pre>
62276225

6228-
The color space is sRGB, the representation is 8 bits per component, the data format does not produce ''none'' values nor does it support extended range values, and the alpha is 1 (255/255).
6226+
The color space is sRGB, the representation is 8 bits per component,
6227+
the data format does not produce ''none'' values nor does it support extended range values,
6228+
and the alpha is 1.
62296229

6230-
The HTML-compatible serialization is the string "#25a457" (not "#25A457").
6230+
The HTML-compatible serialization is the string "#ff00ff" (not "#FF00FF").
62316231
</div>
62326232

62336233
Otherwise, for sRGB the <a href="#css-serialization-of-srgb">CSS serialization of sRGB values is used</a> and for other color spaces, the relevant <a href="#serializing-color-values">serialization</a> of the <<color>> value.
62346234

62356235
<div class="example" id="ex-canvas-p3">
6236-
For example, the pixel value from a canvas 2D context,
6237-
this time using the display-p3 colorspace is returned,
6238-
again as a Uint8ClampedArray:
6236+
For example, fill style is set to <span class="swatch" style="--color: rgb(48.63% 13.85% 15.73%)"></span> a dark brown, in CIE Lab:
62396237

62406238
<pre lang-js>
6241-
imageData = context.getImageData(0, 0, 1, 1);
6242-
console.log(imageData.colorSpace); // "display-p3"
6243-
console.log([...imageData.data]); // [80, 162, 95, 255]
6239+
context.fillStyle = "lab(29% 39 20)";
6240+
console.log(context.fillStyle); // "lab(29 39 20)"
62446241
</pre>
62456242

6246-
The CSS serialization is the string "color(display-p3 0.3137 0.6353 0.3725)".
6243+
The CSS serialization is the string "lab(29 39 20)".
62476244
</div>
62486245

62496246
<div class="example" id="ex-srgb-alpha">
6247+
For example, fill style is set to <span class="swatch" style="--color: #ff00ffed"></span> semi-transparent magenta:
6248+
6249+
<pre lang-js>
6250+
context.fillStyle = "#ff00ffed";
6251+
console.log(context.fillStyle); // "rgba(255, 0, 255, 0.93)"
6252+
</pre>
6253+
6254+
The alpha is not 1, so the CSS serialization is the string
6255+
"rgba(255, 0, 255, 0.93)".
6256+
</div>
6257+
6258+
<!-- <div class="example" id="ex-srgb-alpha">
62506259
For example, a color picker has returned the following values,
62516260
in the sRGB colorspace:
62526261

@@ -6256,7 +6265,7 @@ Serializing sRGB values</h3>
62566265

62576266
The alpha is not 1, so the CSS serialization is the string
62586267
"rgba(37, 164, 87, 0.93)".
6259-
</div>
6268+
</div> -->
62606269

62616270
<h4 id="css-serialization-of-srgb">CSS serialization of sRGB values</h4>
62626271

0 commit comments

Comments
 (0)