- From: Tab Atkins Jr.. via cvs-syncmail <cvsmail@w3.org>
- Date: Wed, 03 Aug 2011 23:41:21 +0000
- To: public-css-commits@w3.org
Update of /sources/public/csswg/css3-images In directory hutz:/tmp/cvs-serv23914 Modified Files: Overview.html Overview.src.html Log Message: Fixed the 0-width repeating gradient to give the same result as non-zero-but-too-small. Added examples of both types of degenerate gradients. Index: Overview.html =================================================================== RCS file: /sources/public/csswg/css3-images/Overview.html,v retrieving revision 1.121 retrieving revision 1.122 diff -u -d -r1.121 -r1.122 --- Overview.html 3 Aug 2011 23:22:36 -0000 1.121 +++ Overview.html 3 Aug 2011 23:41:19 -0000 1.122 @@ -927,16 +927,26 @@ <p><img alt="" src=repeating3.png></p> </div> - <p>If the distance between the first and last color-stops is zero, the - gradient must be rendered as a solid-color image equal to the "average" - color of the gradient, determined by linearly blending the colors of all - the color-stops in premultipied sRGBA space. - <p>If the distance between the first and last color-stops is non-zero, but is small enough that the implementation knows that the physical resolution of the output device is insufficient to faithfully render the gradient, - the gradient must be rendered as a solid-color image equal to the weighted - average color of the gradient, as determined by the following algorithm: + the implementation must <a href="#find-the-average-color-of-a-gradient"><i + title=gradient-average-color>find the average color of the + gradient</i></a> and render the gradient as a solid-color image equal to + the average color. + + <p>If the distance between the first and last color-stops is zero (or + rounds to zero due to implementation limitations), the implementation must + <a href="#find-the-average-color-of-a-gradient"><i + title=gradient-average-color>find the average color</i></a> of a gradient + with the same number and color of color-stops, but with the first and last + color-stop an arbitrary non-zero distance apart, and the remaining + color-stops equally spaced between them. Then it must render the gradient + as a solid-color image equal to that average color. + + <p>To <dfn id=find-the-average-color-of-a-gradient + title=gradient-average-color>find the average color of a gradient</dfn>, + run these steps: <ol> <li>Define <var>list</var> as an initially-empty list of premultiplied @@ -952,15 +962,25 @@ second color-stop. <li>Sum the entries of <var>list</var> component-wise to produce the - average color. + average color, and return it. </ol> <p class=note>As usual, implementations may use whatever algorithm they wish, so long as it produces the same result as the above. <div class=example> - <p class=issue>TODO fill in examples here of the 0-length or - too-small-length cases.</p> + <p>For example, the following gradient is rendered as a solid light-purple + image (equal to <code>rgb(75%,50%,75%)</code>):</p> + + <pre class=css>repeating-linear-gradient(red 0px, white 0px, blue 0px);</pre> + + <p>The following gradient would render the same as the previous under + normal circumstances (because desktop monitors can't faithfully render + color-stops 1/10th of a pixel apart), but would render as a normal + repeating gradient if, for example, the author applied "zoom:100;" to the + element on which the gradient appears:</p> + + <pre class=css>repeating-linear-gradient(red 0px, white .1px, blue .2px);</pre> </div> <!-- ====================================================================== --> Index: Overview.src.html =================================================================== RCS file: /sources/public/csswg/css3-images/Overview.src.html,v retrieving revision 1.128 retrieving revision 1.129 diff -u -d -r1.128 -r1.129 --- Overview.src.html 3 Aug 2011 23:22:36 -0000 1.128 +++ Overview.src.html 3 Aug 2011 23:41:19 -0000 1.129 @@ -694,22 +694,30 @@ <p><img src="repeating3.png" alt=""></p> </div> - <p>If the distance between the first and last color-stops is zero, the gradient must be rendered as a solid-color image equal to the "average" color of the gradient, determined by linearly blending the colors of all the color-stops in premultipied sRGBA space.</p> + <p>If the distance between the first and last color-stops is non-zero, but is small enough that the implementation knows that the physical resolution of the output device is insufficient to faithfully render the gradient, the implementation must <i title="gradient-average-color">find the average color of the gradient</i> and render the gradient as a solid-color image equal to the average color.</p> - <p>If the distance between the first and last color-stops is non-zero, but is small enough that the implementation knows that the physical resolution of the output device is insufficient to faithfully render the gradient, the gradient must be rendered as a solid-color image equal to the weighted average color of the gradient, as determined by the following algorithm:</p> + <p>If the distance between the first and last color-stops is zero (or rounds to zero due to implementation limitations), the implementation must <i title="gradient-average-color">find the average color</i> of a gradient with the same number and color of color-stops, but with the first and last color-stop an arbitrary non-zero distance apart, and the remaining color-stops equally spaced between them. Then it must render the gradient as a solid-color image equal to that average color.</p> + + <p>To <dfn title="gradient-average-color">find the average color of a gradient</dfn>, run these steps:</p> <ol> <li>Define <var>list</var> as an initially-empty list of premultiplied RGBA colors, and <var>total-length</var> as the distance between first and last color stops.</li> <li>For each adjacent pair of color-stops, define <var>weight</var> as half the distance between the two color-stops, divided by <var>total-length</var>. Add two entries to <var>list</var>, the first obtained by representing the color of the first color-stop in premultiplied sRGBA and scaling all of the components by <var>weight</var>, and the second obtained in the same way with the second color-stop.</li> - <li>Sum the entries of <var>list</var> component-wise to produce the average color.</li> + <li>Sum the entries of <var>list</var> component-wise to produce the average color, and return it.</li> </ol> <p class='note'>As usual, implementations may use whatever algorithm they wish, so long as it produces the same result as the above.</p> <div class='example'> - <p class='issue'>TODO fill in examples here of the 0-length or too-small-length cases.</p> + <p>For example, the following gradient is rendered as a solid light-purple image (equal to <code>rgb(75%,50%,75%)</code>):</p> + + <pre class="css">repeating-linear-gradient(red 0px, white 0px, blue 0px);</pre> + + <p>The following gradient would render the same as the previous under normal circumstances (because desktop monitors can't faithfully render color-stops 1/10th of a pixel apart), but would render as a normal repeating gradient if, for example, the author applied "zoom:100;" to the element on which the gradient appears:</p> + + <pre class="css">repeating-linear-gradient(red 0px, white .1px, blue .2px);</pre> </div> <!-- ====================================================================== -->
Received on Wednesday, 3 August 2011 23:41:23 UTC