Skip to content

Commit f07f83a

Browse files
committed
Editorial rewrite of the radial gradient size/shape keywords section.
1 parent 9792977 commit f07f83a

2 files changed

Lines changed: 130 additions & 110 deletions

File tree

css3-images/Overview.html

Lines changed: 92 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020

2121
<h1>CSS Image Values and Replaced Content Module Level 3</h1>
2222

23-
<h2 class="no-num no-toc" id=longstatus-date>Editor's Draft 11 August 2011</h2>
23+
<h2 class="no-num no-toc" id=longstatus-date>Editor's Draft 12 August 2011</h2>
2424

2525
<dl><!--<dt>This version:</dt>
26-
<dd><a href="http://www.w3.org/TR/2011/ED-css3-images-20110811/">http://www.w3.org/TR/2011/ED-css3-images-20110811/</a>-->
26+
<dd><a href="http://www.w3.org/TR/2011/ED-css3-images-20110812/">http://www.w3.org/TR/2011/ED-css3-images-20110812/</a>-->
2727

2828
<dt>Latest version:
2929

@@ -786,56 +786,78 @@ <h4 class=no-toc id=radial-gradient-syntax><span class=secno>5.2.1. </span>
786786
<em>implicitly</em> with a size and shape keyword. The <a
787787
href="#ltshape"><i>&lt;shape></i></a> is defined as</p>
788788

789-
<pre><code><dfn id=ltshape>&lt;shape></dfn> = [ circle | ellipse ]</code></pre>
789+
<pre><code><dfn id=ltshape>&lt;shape></dfn> = circle | ellipse</code></pre>
790790

791791
<p>&lsquo;<code class=css>circle</code>&rsquo; indicates that the
792792
ending-ellipse will be a circle with a constant radius. &lsquo;<code
793793
class=css>ellipse</code>&rsquo; indicates that the gradient-shape will
794794
be an axis-aligned ellipse (that is, its major and minor radiuses will
795795
be horizontal and vertical, not necessarily in that order).</p>
796796

797-
<p>The <a href="#ltsize"><i>&lt;size></i></a> keyword is defined as</p>
798-
799-
<pre><code><dfn id=ltsize>&lt;size></dfn> = [ closest-side | closest-corner | farthest-side | farthest-corner | contain | cover ]</code></pre>
800-
801-
<p>If <a href="#ltshape"><i>&lt;shape></i></a> is &lsquo;<code
802-
class=css>circle</code>&rsquo; and <a
803-
href="#ltsize"><i>&lt;size></i></a> is &lsquo;<code
804-
class=css>closest-side</code>&rsquo;, the ending-shape is a circle sized
805-
so that it exactly meets the side of the box closest to its center. For
806-
example, if the box was 100px wide and 200px tall, and the center of the
807-
gradient was &lsquo;<code class=css>10% 10%</code>&rsquo;, then the
808-
closest side is the left side of the box (it is 10px from the
809-
starting-point, while the top is 20px from it, and the right and bottom
810-
sides are much further). The gradient-shape would thus be a circle with
811-
a radius of 10px. If <a href="#ltshape"><i>&lt;shape></i></a> is
812-
&lsquo;<code class=css>ellipse</code>&rsquo; and <a
813-
href="#ltsize"><i>&lt;size></i></a> is &lsquo;<code
814-
class=css>closest-side</code>&rsquo;, the gradient-shape is an ellipse
815-
sized so that it exactly meets the vertical and horizontal sides of the
816-
box closest to its center. Using the same box and starting-point as the
817-
previous example, the gradient-shape would be an ellipse with a 20px
818-
vertical radius and a 10px horizontal radius. (If necessary, such as if
819-
the starting-point is outside of the box, extend the sides of the box so
820-
that there is a line the ellipse can meet.)</p>
821-
822-
<p>&lsquo;<code class=css>farthest-side</code>&rsquo; is identical to
823-
&lsquo;<code class=css>closest-side</code>&rsquo;, except that the
824-
gradient-shape is sized to meet the side of the box that is farthest
825-
from its center (or the farthest vertical and horizontal sides, if the
826-
shape is &lsquo;<code class=css>ellipse</code>&rsquo;). &lsquo;<code
827-
class=css>closest-corner</code>&rsquo; and &lsquo;<code
828-
class=css>farthest-corner</code>&rsquo; size the gradient-shape so that
829-
it exactly meets the closest or farthest corner of the box from its
830-
center, respectively. If <a href="#ltshape"><i>&lt;shape></i></a> is
831-
&lsquo;<code class=css>ellipse</code>&rsquo;, the gradient-shape has the
832-
same ratio of width to height that it would if &lsquo;<code
833-
class=css>closest-side</code>&rsquo; or &lsquo;<code
834-
class=css>farthest-side</code>&rsquo; were specified, as appropriate.
835-
&lsquo;<code class=css>contain</code>&rsquo; is a synonym for
836-
&lsquo;<code class=css>closest-side</code>&rsquo;, and &lsquo;<code
837-
class=css>cover</code>&rsquo; is a synonym for &lsquo;<code
838-
class=css>farthest-corner</code>&rsquo;.</p>
797+
<p>The <a href="#ltsize"><i>&lt;size></i></a> keyword is defined as:</p>
798+
799+
<pre><code><dfn id=ltsize>&lt;size></dfn> = closest-side | closest-corner | farthest-side | farthest-corner | contain | cover</code></pre>
800+
801+
<p>Its values are defined in the list below. For the purpose of these
802+
definitions, consider the box edges as extending infinitely in both
803+
directions, rather than being finite line segments.</p>
804+
805+
<dl>
806+
<dt><dfn id=radial-closest-side>closest-side</dfn>
807+
808+
<dd>
809+
<p>If the <a href="#ltshape"><i>&lt;shape></i></a> is &lsquo;<code
810+
class=css>circle</code>&rsquo;, the ending-shape must be a circle
811+
sized so that it exactly meets the closest side of the box.</p>
812+
813+
<p>If the <a href="#ltshape"><i>&lt;shape></i></a> is &lsquo;<code
814+
class=css>ellipse</code>&rsquo;, the ending-shape must be an ellipse
815+
sized so that it exactly meets the closest horizontal and vertical
816+
sides of the box.</p>
817+
818+
<dt><dfn id=radial-farthest-side>farthest-side</dfn>
819+
820+
<dd>Same as &lsquo;<a href="#radial-closest-side"><code
821+
class=css>closest-side</code></a>&rsquo;, except the ending-shape must
822+
be sized based on the farthest side(s).
823+
824+
<dt><dfn id=radial-closest-corner>closest-corner</dfn>
825+
826+
<dd>
827+
<p>If the <a href="#ltshape"><i>&lt;shape></i></a> is &lsquo;<code
828+
class=css>circle</code>&rsquo;, the ending-shape must be a circle
829+
sized so that it exactly meets the closest corner of the box.</p>
830+
831+
<p>If the <a href="#ltshape"><i>&lt;shape></i></a> is &lsquo;<code
832+
class=css>ellipse</code>&rsquo;, the ending-shape must be an ellipse
833+
with the same aspect-ratio it would have if &lsquo;<a
834+
href="#radial-closest-side"><code
835+
class=css>closest-side</code></a>&rsquo; were specified, but sized so
836+
that it exactly meets the closest corner of the box.</p>
837+
838+
<dt><dfn id=radial-farthest-corner>farthest-corner</dfn>
839+
840+
<dd>Same as &lsquo;<a href="#radial-closest-corner"><code
841+
class=css>closest-corner</code></a>&rsquo;, except the ending-shape
842+
must be sized based on the farthest corner. If <a
843+
href="#ltshape"><i>&lt;shape></i></a> is &lsquo;<code
844+
class=css>ellipse</code>&rsquo;, the ending-shape must have the same
845+
aspect ratio it would have if &lsquo;<a
846+
href="#radial-farthest-side"><code
847+
class=css>farthest-side</code></a>&rsquo; were specified.
848+
849+
<dt><dfn id=radial-contain>contain</dfn>
850+
851+
<dd>This value is an alias for &lsquo;<a
852+
href="#radial-closest-side"><code
853+
class=css>closest-side</code></a>&rsquo;, and has the same meaning.
854+
855+
<dt><dfn id=radial-cover>cover</dfn>
856+
857+
<dd>This value is an alias for &lsquo;<a
858+
href="#radial-farthest-corner"><code
859+
class=css>farthest-corner</code></a>&rsquo;, and has the same meaning.
860+
</dl>
839861

840862
<dt>Explicitly
841863

@@ -850,12 +872,22 @@ <h4 class=no-toc id=radial-gradient-syntax><span class=secno>5.2.1. </span>
850872
box, while percentages used in the second value are relative to the
851873
height of the box.</p>
852874

853-
<p>Both of the values must be non-negative. Specifying either as
854-
&lsquo;<code class=css>0</code>&rsquo; is allowed, but produces a
855-
degenerate shape. The handling of degenerate ending-shapes is specified
856-
later in this specification.</p>
875+
<p>Negative lengths or percentages are a syntax error.</p>
857876
</dl>
858877

878+
<p>Some combinations of position, size, and shape will produce a <dfn
879+
id=degenerate-shape>degenerate shape</dfn> - a circle or ellipse with a
880+
radius of 0. This will occur if the position is on a box edge and the
881+
second argument is &lsquo;<code class=css>circle
882+
closest-side</code>&rsquo;, &lsquo;<code class=css>ellipse
883+
closest-side</code>&rsquo;, or &lsquo;<code class=css>ellipse
884+
closest-corner</code>&rsquo;, or if the position is on a box corner and
885+
the shape is &lsquo;<a href="#radial-closest-corner"><code
886+
class=css>closest-corner</code></a>&rsquo;, or if the size and shape are
887+
given explicitly and either of the radiuses are &lsquo;<code
888+
class=css>0</code>&rsquo;. In these instances, the the gradient represents
889+
a solid-color image equal to the color of the last color-stop.
890+
859891
<p>If this argument is omitted, it defaults to &lsquo;<code
860892
class=css>ellipse cover</code>&rsquo;.
861893

@@ -864,16 +896,6 @@ <h4 class=no-toc id=radial-gradient-syntax><span class=secno>5.2.1. </span>
864896
&lsquo;<code class=css>radial-gradient(10% 10%, red, blue)</code>&rsquo;),
865897
it must be interpreted as a position.
866898

867-
<p>In certain circumstances the given parameters may define a degenerate
868-
shape - a circle or ellipse with a radius of 0. In these instances the
869-
gradient image is just a solid color equal to the color of the last
870-
color-stop in the rule. The following combinations of values will trigger
871-
this: &lsquo;<code class=css>closest-side</code>&rsquo; if the
872-
starting-point is on a box edge, &lsquo;<code
873-
class=css>closest-corner</code>&rsquo; if the starting-point is on a box
874-
corner, and &lsquo;<code class=css>ellipse closest-corner</code>&rsquo; if
875-
the starting-point is on a box edge.
876-
877899
<p>Color-stops are placed on an imaginary line extending from the center of
878900
the gradient toward the right, with the 0% point at the center of the
879901
gradient, and 100% at the point where the line intersects the
@@ -930,8 +952,8 @@ <h4 class=no-toc id=radial-gradient-examples><span class=secno>5.2.2.
930952
</div>
931953

932954
<div class=example>
933-
<p>Here we illustrate a &lsquo;<code class=property>contain</code>&rsquo;
934-
gradient.</p>
955+
<p>Here we illustrate a &lsquo;<a href="#radial-contain"><code
956+
class=property>contain</code></a>&rsquo; gradient.</p>
935957

936958
<pre><code>radial-gradient(20px 30px, contain, red, yellow, green);
937959
radial-gradient(20px 30px, 20px 30px, red, yellow, green);</code></pre>
@@ -1560,13 +1582,15 @@ <h3 id=object-fit><span class=secno>6.4. </span> Sizing Objects: the
15601582

15611583
<dd>
15621584
<p>Size the content as if &lsquo;<code class=property>none</code>&rsquo;
1563-
or &lsquo;<code class=property>contain</code>&rsquo; were specified,
1564-
whichever would result in a smaller size.</p>
1585+
or &lsquo;<a href="#radial-contain"><code
1586+
class=property>contain</code></a>&rsquo; were specified, whichever would
1587+
result in a smaller size.</p>
15651588

15661589
<p class=note>Note that both &lsquo;<code
1567-
class=property>none</code>&rsquo; and &lsquo;<code
1568-
class=property>contain</code>&rsquo; respect the content's intrinsic
1569-
aspect ratio, so the concept of "smaller" is well-defined.</p>
1590+
class=property>none</code>&rsquo; and &lsquo;<a
1591+
href="#radial-contain"><code class=property>contain</code></a>&rsquo;
1592+
respect the content's intrinsic aspect ratio, so the concept of
1593+
"smaller" is well-defined.</p>
15701594
</dl>
15711595

15721596
<p>If the content does not completely fill the replaced element, the
@@ -1588,7 +1612,8 @@ <h3 id=object-fit><span class=secno>6.4. </span> Sizing Objects: the
15881612
for &lsquo;<a href="#object-position0"><code
15891613
class=property>object-position</code></a>&rsquo;. The fifth value,
15901614
&lsquo;<code class=css><span class=css>scale-down</span>, in this case
1591-
looks identical to </code>&rsquo;<span class=css>contain</span>.</p>
1615+
looks identical to </code>&rsquo;<a class=css
1616+
href="#radial-contain">contain</a>.</p>
15921617
</div>
15931618

15941619
<p class=note>Note: the &lsquo;<a href="#object-fit0"><code

css3-images/Overview.src.html

Lines changed: 38 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -525,43 +525,46 @@ <h4 class='no-toc' id='radial-gradient-syntax'>
525525
<em>implicitly</em> with a size and shape keyword. The <i>&lt;shape></i>
526526
is defined as </p>
527527

528-
<pre><code><dfn>&lt;shape></dfn> = [ circle | ellipse ]</code></pre>
528+
<pre><code><dfn>&lt;shape></dfn> = circle | ellipse</code></pre>
529529

530530
<p>''circle'' indicates that the ending-ellipse will be a circle with
531531
a constant radius. ''ellipse'' indicates that the gradient-shape
532532
will be an axis-aligned ellipse (that is, its major and minor radiuses
533533
will be horizontal and vertical, not necessarily in that order).</p>
534534

535-
<p>The <i>&lt;size></i> keyword is defined as </p>
536-
537-
<pre><code><dfn>&lt;size></dfn> = [ closest-side | closest-corner | farthest-side | farthest-corner | contain | cover ]</code></pre>
538-
539-
<p>If <i>&lt;shape></i> is ''circle'' and <i>&lt;size></i> is ''closest-side'',
540-
the ending-shape is a circle sized so that it exactly meets the side
541-
of the box closest to its center. For example, if the box was 100px
542-
wide and 200px tall, and the center of the gradient was ''10% 10%'',
543-
then the closest side is the left side of the box (it is 10px from
544-
the starting-point, while the top is 20px from it, and the right and
545-
bottom sides are much further). The gradient-shape would thus be a
546-
circle with a radius of 10px. If <i>&lt;shape></i> is ''ellipse'' and
547-
<i>&lt;size></i> is ''closest-side'', the gradient-shape is an ellipse
548-
sized so that it exactly meets the vertical and horizontal sides of
549-
the box closest to its center. Using the same box and starting-point
550-
as the previous example, the gradient-shape would be an ellipse with
551-
a 20px vertical radius and a 10px horizontal radius. (If necessary,
552-
such as if the starting-point is outside of the box, extend the sides
553-
of the box so that there is a line the ellipse can meet.)</p>
554-
555-
<p>''farthest-side'' is identical to ''closest-side'', except that
556-
the gradient-shape is sized to meet the side of the box that is farthest
557-
from its center (or the farthest vertical and horizontal sides, if
558-
the shape is ''ellipse''). ''closest-corner'' and ''farthest-corner''
559-
size the gradient-shape so that it exactly meets the closest or farthest
560-
corner of the box from its center, respectively. If <i>&lt;shape></i>
561-
is ''ellipse'', the gradient-shape has the same ratio of width to height
562-
that it would if ''closest-side'' or ''farthest-side'' were specified,
563-
as appropriate. ''contain'' is a synonym for ''closest-side'', and
564-
''cover'' is a synonym for ''farthest-corner''.</p>
535+
<p>The <i>&lt;size></i> keyword is defined as:</p>
536+
537+
<pre><code><dfn>&lt;size></dfn> = closest-side | closest-corner | farthest-side | farthest-corner | contain | cover</code></pre>
538+
539+
<p>Its values are defined in the list below. For the purpose of these definitions, consider the box edges as extending infinitely in both directions, rather than being finite line segments.</p>
540+
541+
<dl>
542+
<dt><dfn id='radial-closest-side'>closest-side</dfn></dt>
543+
<dd>
544+
<p>If the <i>&lt;shape></i> is ''circle'', the ending-shape must be a circle sized so that it exactly meets the closest side of the box.</p>
545+
546+
<p>If the <i>&lt;shape></i> is ''ellipse'', the ending-shape must be an ellipse sized so that it exactly meets the closest horizontal and vertical sides of the box.</p>
547+
</dd>
548+
549+
<dt><dfn id='radial-farthest-side'>farthest-side</dfn></dt>
550+
<dd>Same as ''closest-side'', except the ending-shape must be sized based on the farthest side(s).</dd>
551+
552+
<dt><dfn id='radial-closest-corner'>closest-corner</dfn></dt>
553+
<dd>
554+
<p>If the <i>&lt;shape></i> is ''circle'', the ending-shape must be a circle sized so that it exactly meets the closest corner of the box.</p>
555+
556+
<p>If the <i>&lt;shape></i> is ''ellipse'', the ending-shape must be an ellipse with the same aspect-ratio it would have if ''closest-side'' were specified, but sized so that it exactly meets the closest corner of the box.</p>
557+
</dd>
558+
559+
<dt><dfn id='radial-farthest-corner'>farthest-corner</dfn></dt>
560+
<dd>Same as ''closest-corner'', except the ending-shape must be sized based on the farthest corner. If <i>&lt;shape></i> is ''ellipse'', the ending-shape must have the same aspect ratio it would have if ''farthest-side'' were specified.</dd>
561+
562+
<dt><dfn id='radial-contain'>contain</dfn></dt>
563+
<dd>This value is an alias for ''closest-side'', and has the same meaning.</dd>
564+
565+
<dt><dfn id='radial-cover'>cover</dfn></dt>
566+
<dd>This value is an alias for ''farthest-corner'', and has the same meaning.</dd>
567+
</dl>
565568
</dd>
566569

567570
<dt>Explicitly</dt>
@@ -577,26 +580,18 @@ <h4 class='no-toc' id='radial-gradient-syntax'>
577580
the box, while percentages used in the second value are relative to
578581
the height of the box.</p>
579582

580-
<p>Both of the values must be non-negative. Specifying either as
581-
''0'' is allowed, but produces a degenerate shape. The handling of
582-
degenerate ending-shapes is specified later in this specification.</p>
583+
<p>Negative lengths or percentages are a syntax error.</p>
583584
</dd>
584585
</dl>
585586

587+
<p>Some combinations of position, size, and shape will produce a <dfn>degenerate shape</dfn> - a circle or ellipse with a radius of 0. This will occur if the position is on a box edge and the second argument is ''circle closest-side'', ''ellipse closest-side'', or ''ellipse closest-corner'', or if the position is on a box corner and the shape is ''closest-corner'', or if the size and shape are given explicitly and either of the radiuses are ''0''. In these instances, the the gradient represents a solid-color image equal to the color of the last color-stop.</p>
588+
586589
<p>If this argument is omitted, it defaults to ''ellipse cover''.</p>
587590

588591
<p>If only one argument is provided before the color-stops, and it could
589592
be interpreted as either a position or an explicit size (for example, in
590593
''radial-gradient(10% 10%, red, blue)''), it must be interpreted as a position.</p>
591594

592-
<p>In certain circumstances the given parameters may define a degenerate
593-
shape - a circle or ellipse with a radius of 0. In these instances the
594-
gradient image is just a solid color equal to the color of the last color-stop
595-
in the rule. The following combinations of values will trigger this:
596-
''closest-side'' if the starting-point is on a box edge, ''closest-corner''
597-
if the starting-point is on a box corner, and ''ellipse closest-corner''
598-
if the starting-point is on a box edge.</p>
599-
600595
<p>Color-stops are placed on an imaginary line extending from the center
601596
of the gradient toward the right, with the 0% point at the center of the
602597
gradient, and 100% at the point where the line intersects the ending-ellipse.
@@ -705,7 +700,7 @@ <h3 id='repeating-gradients'>
705700

706701
<pre><code>repeating-radial-gradient(20px 30px, circle contain, red, yellow, green 100%, yellow 150%, red 200%)</code></pre>
707702
<p><img src="repeating3.png" alt=""></p>
708-
</div>
703+
</div>
709704

710705
<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>
711706

0 commit comments

Comments
 (0)