8000 Editorial: clean up color conversion presentation in canvas · whatwg/html@a4809f6 · GitHub
[go: up one dir, main page]

Skip to content

Commit a4809f6

Browse files
Editorial: clean up color conversion presentation in canvas
1 parent 54b7302 commit a4809f6

File tree

1 file changed

+33
-38
lines changed

1 file changed

+33
-38
lines changed

source

Lines changed: 33 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -66579,8 +66579,6 @@ typedef (<span>HTMLOrSVGImageElement</span> or
6657966579
<span>OffscreenCanvas</span> or
6658066580
<span>VideoFrame</span>) <dfn typedef>CanvasImageSource</dfn>;
6658166581

66582-
enum <dfn enum>PredefinedColorSpace</dfn> { "<span data-x="dom-PredefinedColorSpace-srgb">srgb</span>", "<span data-x="dom-PredefinedColorSpace-display-p3">display-p3</span>" };
66583-
6658466582
enum <dfn enum>CanvasColorType</dfn> { "<span data-x="dom-CanvasColorType-unorm8">unorm8</span>", "<span data-x="dom-CanvasColorType-float16">float16</span>" };
6658566583

6658666584
enum <dfn enum>CanvasFillRule</dfn> { "<span data-x="dom-context-2d-fillRule-nonzero">nonzero</span>", "<span data-x="dom-context-2d-fillRule-evenodd">evenodd</span>" };
@@ -67015,22 +67013,6 @@ context.fillRect(100,0,50,50); // only this square remains</code></pre>
6701567013

6701667014
<hr>
6701767015

67018-
<p>The <code>PredefinedColorSpace</code> enumeration is used to specify the <span
67019-
data-x="concept-canvas-color-space">color space</span> of the canvas's backing store.</p>
67020-
67021-
<p>The "<dfn enum-value for="PredefinedColorSpace"><code
67022-
data-x="dom-PredefinedColorSpace-srgb">srgb</code></dfn>" value indicates the <span>'srgb'</span>
67023-
color space.</p>
67024-
67025-
<p>The "<dfn enum-value for="PredefinedColorSpace"><code
67026-
data-x="dom-PredefinedColorSpace-display-p3">display-p3</code></dfn>" value indicates the
67027-
<span>'display-p3'</span> color space.</p>
67028-
67029-
<p class="note">The algorithm for converting between color spaces can be found in the
67030-
<span>Converting Colors</span> section of <cite>CSS Color</cite>. <ref>CSSCOLOR</ref></p>
67031-
67032-
<hr>
67033-
6703467016
<p>The <code>CanvasColorType</code> enumeration is used to specify the <span
6703567017
data-x="concept-canvas-color-type">color type</span> of the canvas's backing store.</p>
6703667018

@@ -70004,8 +69986,11 @@ try {
7000469986

7000569987
<p id="interpolation">Once a gradient has been created (see below), stops are placed along it to
7000669988
define how the colors are distributed along the gradient. <span w-nodev>The color of the
70007-
gradient at each stop is the color specified for that stop. Between each such stop, the colors and
70008-
the alpha component must be linearly interpolated over the RGBA space without premultiplying the
69989+
gradient at each stop is the color specified for that stop, <span
69990+
data-x="Converting Colors">converted</span> to the <span
69991+
data-x="concept-canvas-color-space">context's color space</span>. Between each such stop, the
69992+
colors and the alpha component must be linearly interpolated in the <span
69993+
data-x="concept-canvas-color-space">context's color space</span> without premultiplying the
7000969994
alpha value to find the color to use at that offset. Before the first stop, the color must be the
7001069995
color of the first stop. After the last stop, the color must be the color of the last stop. When
7001169996
there are no stops, the gradient is <span>transparent black</span>.</span></p>
@@ -71900,6 +71885,17 @@ console.log(pixels.data[2]);
7190071885
and line styles must be honored, and the stroke must itself also be subjected to the current
7190171886
transformation matrix.</p></li>
7190271887

71888+
<li>
71889+
<p>Convert the image <var>A</var> to the <span data-x="concept-canvas-color-space">context's
71890+
color space</span>.</p>
71891+
71892+
<p class="note">There do not exist any inputs to a 2D context for which the color space is
71893+
undefined. The color space for CSS colors is defined in <cite>CSS Color</cite>. The color space
71894+
for images that specify no color profile information is <span>'srgb'</span>, as
71895+
specified in the <a href="https://drafts.csswg.org/css-color/#untagged">Color Spaces of Untagged
71896+
Colors</a> section of <cite>CSS Color</cite>. <ref>CSSCOLOR</ref></p>
71897+
</li>
71898+
7190371899
<li><p>Multiply the alpha component of every pixel in <var>A</var> by <code
7190471900
data-x="concept-canvas-global-alpha">global alpha</code>.</p></li>
7190571901

@@ -72940,28 +72936,27 @@ interface <dfn interface>OffscreenCanvasRenderingContext2D</dfn> {
7294072936
<!--en-GB--><h5 id="colour-spaces-and-colour-correction">Color spaces and color space
7294172937
conversion</h5>
7294272938

72943-
<p>The <code>canvas</code> APIs provide mechanisms for specifying the color space of the canvas's
72944-
backing store. The default backing store color space for all canvas APIs is
72945-
<span>'srgb'</span>.</p>
72939+
<pre><code class="idl">enum <dfn enum>PredefinedColorSpace</dfn> { "<span data-x="dom-PredefinedColorSpace-srgb">srgb</span>", "<span data-x="dom-PredefinedColorSpace-display-p3">display-p3</span>" };</code></pre>
72940+
72941+
<p>The <code>PredefinedColorSpace</code> enumeration is used to specify the <span
72942+
data-x="concept-canvas-color-space">color space</span> of the canvas's backing store.</p>
72943+
72944+
<p>The "<dfn enum-value for="PredefinedColorSpace"><code
72945+
data-x="dom-PredefinedColorSpace-srgb">srgb</code></dfn>" value indicates the <span>'srgb'</span>
72946+
color space.</p>
72947+
72948+
<p>The "<dfn enum-value for="PredefinedColorSpace"><code
72949+
data-x="dom-PredefinedColorSpace-display-p3">display-p3</code></dfn>" value indicates the
72950+
<span>'display-p3'</span> color space.</p>
7294672951

7294772952
<p><span data-x="Converting Colors">Color space conversion</span> must be applied to the canvas's
72948-
backing store when rendering the canvas to the output device. This color space conversion must be
72953+
backing store when rendering the canvas to the output device.</p>
72954+
72955+
<p class="note">The algorithm for converting between color spaces can be found in the
72956+
<span>Converting Colors</span> section of <cite>CSS Color</cite>. This color space conversion is
7294972957
identical to the color space conversion that would be applied to an <code>img</code> element with
7295072958
a color profile that specifies the same <span data-x="concept-canvas-color-space">color
72951-
space</span> as the canvas's backing store.</p>
72952-
72953-
<p>When drawing content to a 2D context, all inputs must be <span data-x="Converting
72954-
Colors">converted</span> to the <span data-x="concept-canvas-color-space">context's color
72955-
space</span> before drawing. Interpolation of gradient color stops must be performed on color
72956-
values after conversion to the <span data-x="concept-canvas-color-space">context's color
72957-
space</span>. Alpha blending must be performed on values after conversion to the <span
72958-
data-x="concept-canvas-color-space">context's color space</span>.</p>
72959-
72960-
<p class="note">There do not exist any inputs to a 2D context for which the color space is
72961-
undefined. The color space for CSS colors is defined in <cite>CSS Color</cite>. The color space
72962-
for images that specify no color profile information is assumed to be <span>'srgb'</span>, as
72963-
specified in the <a href="https://drafts.csswg.org/css-color/#untagged">Color Spaces of Untagged
72964-
Colors</a> section of <cite>CSS Color</cite>. <ref>CSSCOLOR</ref></p>
72959+
space</span> as the canvas's backing store. <ref>CSSCOLOR</ref></p>
7296572960

7296672961
</div>
7296772962

0 commit comments

Comments
 (0)
0