-
Notifications
You must be signed in to change notification settings - Fork 131
/
pservers.html
1831 lines (1522 loc) · 66.4 KB
/
pservers.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional+edit//EN" "xhtml1-transitional+edit.dtd">
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:edit="http://xmlns.grorg.org/SVGT12NG/">
<head>
<title>Paint Servers: Solid Colors, Gradients, and Patterns</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/>
<!-- Style sheets for local dev. Will be standardized in processing.
Add attribute data-keep="" to any extra stylesheet link you do not want removed
(or use <style>), and include it before here. -->
<link rel="stylesheet" href="style/svg.css" type="text/css" />
<link rel="stylesheet" href="style/W3C-ED.css" type="text/css" />
</head>
<body>
<h1>Paint Servers: Gradients and Patterns</h1>
<h2 id="Introduction">Introduction</h2>
<p>
This section covers <strong>Paint Servers</strong>, a method which
allows the <a>'fill'</a> or <a>'stroke'</a> of an object to be defined
by a resource found elsewhere. It allows resources to be reused
throughout a document. See the section
<a href="painting.html">Painting: Filling and Stroking</a> for a
general discussion of filling and stroking objects.
</p>
<!-- Fill and stroke are already defined in painting.html. No need to
redefine them here. -->
<p>
SVG defines several types of paint servers:
</p>
<ul>
<li><a href="#Gradients">Gradients</a>,</li>
<li><a href="#Patterns">Patterns</a>.</li>
</ul>
<div class="annotation svg2-requirement">
<table>
<tr>
<th>SVG 2 Requirement:</th>
<td>Arbitrary fills for shapes.</td>
</tr>
<tr>
<th>Resolution:</th>
<td><a href="http://www.w3.org/2011/10/28-svg-irc#T18-32-32">SVG 2 shall support filling and stroking from arbitrary elements.</a></td>
</tr>
<tr>
<th>Purpose:</th>
<td>To allow for example videos or images to be used as a fill source.</td>
</tr>
<tr>
<th>Owner:</th>
<td>Alex? (no action)</td>
</tr>
</table>
</div>
<div class="figure">
<img
alt="Image of two types of paint servers."
src="images/pservers/pservers_example.svg"/>
<p class="caption">Two types of paint servers. From left to right:
A linear gradient.
A pattern.
</p>
</div>
<p>
Paint servers are used by including a <a>URL reference</a> in
a <a>'fill'</a> or <a>'stroke'</a> property (i.e. fill="url(#MyLightPurple)").
</p>
<p>
<a>Properties</a> inherit
into a paint-server element from its ancestors;
properties do <em>not</em> inherit from the element referencing
the paint server element.
</p>
<p>
Paint-server elements are never rendered directly; their only usage is
as something that can be referenced using
the <a>'fill'</a> and <a>'stroke'</a> properties.
The <a>'display'</a> value for these elements
must always be set to <span class="prop-value">none</span>
by the <a>user agent style sheet</a>,
and this declaration must have importance over any other CSS rule or presentation attribute.
<!--The
<a>'display'</a> property does not apply to a paint-server element;
thus, paint-server elements are not directly rendered even if
the <a>'display'</a> property is set to a value other
than <span class="prop-value">none</span>, and -->
Paint-server elements
are available for referencing even when the <a>'display'</a>
property on the paint-server element or any of its ancestors is set
to <span class="prop-value">none</span>.
</p>
<h3 id="PaintServerTemplates">Using paint servers as templates</h3>
<p>
Most paint server elements accept an <span class="attr-name">‘href’</span> attribute,
which can be used to define a compatible paint server element as a template.
Attributes defined for the template element
are used instead of the initial value
if corresponding attributes are not specified
on the current element.
Furthermore, if the current element does not have any
child content other than <a>descriptive elements</a>,
than the child content of the template element is cloned to replace it.
</p>
<div class="note">
<p>
The exclusion of descriptive content is new in SVG 2 for <a>'pattern'</a>,
consistent with the behavior of gradients,
and with changes to make descriptive content valid for any SVG element.
</p>
<p>
Also new: template cross-references may be to external file resources
(different chapters in SVG 1.1 had inconsistent guidance on this point),
and the "inheritance" of child elements is represented through a shadow tree.
</p>
</div>
<p>
Templating can be indirect to an arbitrary level
(subject to security limits on external file resources,
which can make a reference invalid).
Thus, if the referenced template element does not have relevant child content
or does not define the specified attribute,
then the attribute value or cloned content is derived
from another element referenced by the template's own <span class="attr-name">‘href’</span> attribute.
</p>
<p>
The description of each <span class="attr-name">‘href’</span> attribute in this chapter defines
the limits of the templating process, as follows:
</p>
<ul>
<li>What type of element is a valid target for the reference</li>
<li>Which attributes are duplicated from the template</li>
</ul>
<p>
If any of the specified attributes are not
defined on the current element,
or if the current element has no child elements other than <a>descriptive elements</a>,
the user agent must <a href="linking.html#processingURL">process the URL</a>
to identify the referenced resource.
If the URL reference is not <a>invalid</a>,
then the URL's target element is used as the template element, as follows:
</p>
<ul>
<li>
<p>
For any of the specified attributes not defined on the current element,
the user agent must determine the value of the attribute
for the template element
and use it as the value for the current element.
The template value is derived
from recursive cross-references if required.
The initial value for the attribute is only substituted
after all valid URL references are exhausted.
</p>
</li>
<li>
<p>
If the current element has no child elements other than <a>descriptive elements</a>,
the user agent must generate a <a>shadow tree</a> for this element,
which must behave equivalently to a <a>use-element shadow tree</a>,
except that the host is the current paint server element.
The <a>corresponding elements</a> for the <a>element instances</a>
cloned into the shadow tree are:
</p>
<ul>
<li>
the child content of the template element,
if it has child elements other than <a>descriptive elements</a>,
</li>
<li>
the <a>corresponding elements</a> that are used, or would be used, to generate
the template element's own shadow tree, otherwise.
</li>
</ul>
</li>
</ul>
<p>
When a paint-server element has a shadow tree,
the <a>element instances</a> in that tree
must be used in rendering the paint server effect,
as if they were the paint server element's own children.
</p>
<p class="note">
The <a>use-element shadow tree</a> model for templating
allows cloned content to inherit different styles than the original.
This behavior is newly defined in SVG 2;
SVG 1.1 did not define how styles applied to inherited paint server content.
</p>
<h2 id="Gradients">Gradients</h2>
<p>Gradients consist of smooth color transitions between points on a
drawing surface. SVG provides for three types of gradients:</p>
<ul>
<li><a href="#LinearGradients">linear gradients</a>,</li>
<li><a href="#RadialGradients">radial gradients</a>.</li>
</ul>
<p>Once a gradient is defined, a <a>graphics element</a> can be
filled or stroked with the gradient by setting the <a>'fill'</a>
or <a>'stroke'</a> properties to reference the gradient.</p>
<p>
Color transitions for linear and radial gradients are defined by a
series of color <a href="#GradientStops">stops</a> along a gradient
vector. A gradient normal defines how the colors in a vector are
painted to the surface. For a linear gradient, a normal is a line
perpendicular to the vector. For a radial gradient, a normal is a
circle intersecting the vector at a right angle. Each gradient
normal is painted with one color determined by the vector.
</p>
<div class="figure">
<img
alt="Image of linear and radial gradients with vectors and normals indicated."
src="images/pservers/gradient_vector_and_normal_alt.png"/>
<p class="caption">
Linear and radial gradients with the gradient vector
indicated. The vector consists of three stops shown by small
circles. One gradient normal is shown for each gradient.
</p>
</div>
<p class='ready-for-wider-review'>
For linear and radial gradients, the color value between two stops along the
gradient vector is the linear interpolation, per channel, of the color for
each stop, weighted by the distance from each stop.
</p>
<div role="math" aria-describedby="math-gradient-linear-interpolation" class='ready-for-wider-review'>
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
<mi>V</mi>
<mo>=</mo>
<msub>
<mi>C</mi><mn>0</mn>
</msub>
<mo>+</mo>
<mo>(</mo>
<msub>
<mi>C</mi><mn>1</mn>
</msub>
<mo>-</mo>
<msub><mi>C</mi><mn>0</mn></msub>
<mo>)</mo>
<mo>(</mo>
<mfrac>
<mrow>
<mi>D</mi>
<mo>-</mo>
<msub><mi>O</mi><mn>0</mn></msub>
</mrow>
<mrow>
<msub><mi>O</mi><mn>1</mn></msub>
<mo>-</mo>
<msub><mi>O</mi><mn>0</mn></msub>
</mrow>
</mfrac>
<mo>)</mo>
</math>
<pre id="math-gradient-linear-interpolation">
$V = C0.rgba + (C1.rgba - C0.rgba) * ((D - C0.offset) / (C1.offset - C0.offset));
</pre>
</div>
<p class='ready-for-wider-review'>
Where, for each channel:
</p>
<ul class='ready-for-wider-review'>
<li>V is the interpolated result for that channel</li>
<li>C<sub>0</sub> is the stop color for the stop with the lowest offset</li>
<li>O<sub>0</sub> is the offset of C<sub>0</sub></li>
<li>C<sub>1</sub> is the other stop color</li>
<li>O<sub>1</sub> is the offset of C<sub>1</sub></li>
<li>D is the distance along the gradient vector</li>
</ul>
<p>
When a <a>graphics element</a> references a gradient, conceptually the
<a>graphics element</a> should take a copy of the gradient vector
with gradient normals and treat it as part of its own geometry. Any
transformations applied to the <a>graphics element</a> geometry also
apply to the copied gradient vector and gradient normals. Any
gradient transforms that are specified on the reference gradient are
applied before any <a>graphics element</a> transformations are
applied to the gradient.
</p>
<h3 id="Definitions">Definitions</h3>
<dl class="definitions">
<dt><dfn id="TermGradientElement" data-dfn-type="dfn" data-export="">gradient element</dfn></dt>
<dd>A gradient element is one that defines a gradient paint server.
This specification defines the following gradient elements:
<edit:elementcategory name='gradient'/>.
</dd>
</dl>
<h3 id="LinearGradients">Linear gradients</h3>
<edit:with element='linearGradient'>
<p id="LinearGradientElement">Linear gradients are defined by a
<a>'linearGradient'</a> element.</p>
<edit:elementsummary name='linearGradient'/>
<h4 id="LinearGradientAttributes">Attributes</h4>
<p class="note">
Note that the <a>'x1'</a>,<a>'y1'</a>, <a>'x2'</a> and <a>'y2'</a> attributes
on a <a>'linearGradient'</a> are not presentation attributes;
the used value is not affected by CSS styles.
The <a>'gradientTransform'</a> attribute is a presentation attribute
for the <a>'transform'</a> property.
</p>
<dl class="attrdef-list-svg2">
<dt id="LinearGradientElementGradientUnitsAttribute"><span class="adef">gradientUnits</span></dt>
<dd>
<p>
Defines the coordinate system for attributes <a>'x1'</a>,
<a>'y1'</a>, <a>'x2'</a> and <a>'y2'</a>.
</p>
<dl class="attrdef-svg2">
<dt>Value</dt> <dd>userSpaceOnUse | objectBoundingBox</dd>
<dt><a>Initial value</a></dt> <dd>objectBoundingBox</dd>
<dt><a>Animatable</a></dt> <dd>yes</dd>
</dl>
<dl class="attrdef-values">
<dt>userSpaceOnUse</dt>
<dd>
<p>
If <span class="attr-value">gradientUnits="userSpaceOnUse"</span>,
<a>'x1'</a>, <a>'y1'</a>, <a>'x2'</a>, and <a>'y2'</a>
represent values in the coordinate system that results
from taking the current user coordinate system in place at
the time when the gradient element is referenced (i.e.,
the user coordinate system for the element referencing the
gradient element via a <a>'fill'</a> or <a>'stroke'</a>
property) and then applying the transform specified by
attribute <a>'gradientTransform'</a>. Percentages
represent values relative to the current SVG viewport.
</p>
</dd>
<dt>objectBoundingBox</dt>
<dd>
<p>
If <span class="attr-value">gradientUnits="objectBoundingBox"</span>,
the user coordinate system for attributes
<a>'x1'</a>, <a>'y1'</a>, <a>'x2'</a> and <a>'y2'</a>
is established using the bounding box of the element to
which the gradient is applied
(see <a href="coords.html#ObjectBoundingBox">Object
bounding box units</a>) and then applying the transform
specified by attribute <a>'gradientTransform'</a>.
Percentages represent values relative to the bounding box
for the object.
</p>
<p>
When <span class="attr-value">gradientUnits="objectBoundingBox"</span>
and <a>'gradientTransform'</a> is the identity matrix, the
normal of the linear gradient is perpendicular to the
gradient vector in object bounding box space (i.e., the
abstract coordinate system where (0,0) is at the top/left
of the object bounding box and (1,1) is at the
bottom/right of the object bounding box). When the
object's bounding box is not square, the gradient normal
which is initially perpendicular to the gradient vector
within object bounding box space may render
non-perpendicular relative to the gradient vector in user
space. If the gradient vector is parallel to one of the
axes of the bounding box, the gradient normal will remain
perpendicular. This transformation is due to application
of the non-uniform scaling transformation from bounding
box space to user coordinate system.
</p>
</dd>
</dl><!-- Attribute values -->
</dd>
<dt id="LinearGradientElementGradientTransformAttribute">
<span class="adef">gradientTransform</span>
</dt>
<dd>
<p>
Contains the definition of an optional additional
transformation from the gradient coordinate system onto the
target coordinate system
(i.e., <span class='attr-value'>'userSpaceOnUse'</span> or
<span class='attr-value'>'objectBoundingBox'</span>).
This allows for things such as skewing the gradient.
This additional transformation matrix is post-multiplied to
(i.e., inserted to the right of) any previously defined
transformations, including the implicit transformation
necessary to convert
from <a href="coords.html#ObjectBoundingBox">object bounding
box units</a> to user coordinate system.
</p>
<dl class="attrdef-svg2">
<dt>Value</dt> <dd><a><transform-list></a></dd>
<dt><a>Initial value</a></dt> <dd>identity transform</dd>
<dt><a>Animatable</a></dt> <dd>yes</dd>
</dl>
</dd>
<dt id="LinearGradientElementX1Attribute"><span class="adef">x1</span></dt>
<dd>
<p>
<a>'x1'</a>, <a>'y1'</a>, <a>'x2'</a> and <a>'y2'</a> define
a <em>gradient vector</em> for the linear
gradient. This <em>gradient vector</em> provides starting and
ending points onto which the <a href="#GradientStops">gradient
stops</a> are mapped. The values
of <a>'x1'</a>, <a>'y1'</a>, <a>'x2'</a> and <a>'y2'</a> can
be either numbers or percentages.
</p>
<dl class="attrdef-svg2">
<dt>Value</dt> <dd><a><length></a></dd>
<dt><a>Initial value</a></dt> <dd>0%</dd>
<dt><a>Animatable</a></dt> <dd>yes</dd>
</dl>
</dd>
<dt id="LinearGradientElementY1Attribute"><span class="adef">y1</span></dt>
<dd>
<p>
See <a>'x1'</a>.
</p>
<dl class="attrdef-svg2">
<dt>Value</dt> <dd><a><length></a></dd>
<dt><a>Initial value</a></dt> <dd>0%</dd>
<dt><a>Animatable</a></dt> <dd>yes</dd>
</dl>
</dd>
<dt id="LinearGradientElementX2Attribute"><span class="adef">x2</span></dt>
<dd>
<p>
See <a>'x1'</a>.
</p>
<dl class="attrdef-svg2">
<dt>Value</dt> <dd><a><length></a></dd>
<dt><a>Initial value</a></dt> <dd>100%</dd>
<dt><a>Animatable</a></dt> <dd>yes</dd>
</dl>
</dd>
<dt id="LinearGradientElementY2Attribute"><span class="adef">y2</span></dt>
<dd>
<p>
See <a>'x1'</a>.
</p>
<dl class="attrdef-svg2">
<dt>Value</dt> <dd><a><length></a></dd>
<dt><a>Initial value</a></dt> <dd>0%</dd>
<dt><a>Animatable</a></dt> <dd>yes</dd>
</dl>
</dd>
<dt id="LinearGradientElementSpreadMethodAttribute">
<span class="adef">spreadMethod</span>
</dt>
<dd>
<p>
Indicates what happens if the gradient starts or ends
inside the bounds of the <em>target rectangle</em>.
</p>
<dl class="attrdef-svg2">
<dt>Value</dt> <dd>pad | reflect | repeat</dd>
<dt><a>Initial value</a></dt> <dd>pad</dd>
<dt><a>Animatable</a></dt> <dd>yes</dd>
</dl>
<dl class="attrdef-values">
<dt>pad</dt>
<dd>
Use the terminal colors of the gradient to fill the
remainder of the target region.
</dd>
<dt>reflect</dt>
<dd>
Reflect the gradient pattern start-to-end, end-to-start,
start-to-end, etc. continuously until the <em>target
rectangle</em> is filled.
</dd>
<dt>repeat</dt>
<dd>
Repeat the gradient pattern start-to-end, start-to-end,
start-to-end, etc. continuously until the target region is
filled.
</dd>
</dl>
<div class="figure">
<img
alt="Image of the three possible values for 'spreadMethod'."
src="images/pservers/spread_method.png"/>
<p class="caption">
Illustration of the three possible values for
<span class="adef">spreadMethod</span>, from left to
right: pad, reflect, repeat. The gradient vector spans
from 40% to 60% of the bounding box width.
</p>
</div>
</dd>
<dt id="LinearGradientElementHrefAttribute">
<span class="adef">href</span>
</dt>
<dd>
<p>
A <a>URL reference</a> to a template gradient element;
to be valid, the reference must be to a
different <a>'linearGradient'</a> or
a <a>'radialGradient'</a> element.
</p>
<p>
Refer to the process for <a href="#PaintServerTemplates">using paint servers as templates</a>,
and to the common handling defined for <a
href="linking.html#linkRefAttrs">URL reference attributes</a> and
<a href="linking.html#XLinkRefAttrs">deprecated XLink attributes</a>.
</p>
<p>
The specified attributes that will be copied from the template are:
</p>
<ul>
<li><a>'x1'</a></li>
<li><a>'y1'</a></li>
<li><a>'x2'</a></li>
<li><a>'y2'</a></li>
<li><a>'gradientTransform'</a></li>
<li><a>'gradientUnits'</a></li>
<li><a>'spreadMethod'</a></li>
</ul>
<dl class="attrdef-svg2">
<dt>Value</dt> <dd>URL <a href="types.html#attribute-url" class="syntax">[URL]</a></dd>
<dt><a>Initial value</a></dt> <dd>empty</dd>
<dt><a>Animatable</a></dt> <dd>yes</dd>
</dl>
</dd>
</dl>
<h4 id="LinearGradientNotes">Notes on linear gradients</h4>
<p>If <a>'x1'</a> = <a>'x2'</a> and <a>'y1'</a> =
<a>'y2'</a>, then the area to be painted will be painted as a
single color using the color and opacity of the last
<a href="pservers.html#GradientStops">gradient stop</a>.</p>
<p id="ExampleLinGrad01"><span class="example-ref">Example lingrad01</span>
shows how to fill a rectangle by referencing a linear gradient paint server.</p>
<edit:example href='images/pservers/lingrad01.svg' name='lingrad01'
description='Fill a rectangle by referencing a linear gradient paint server'
image='yes' link='yes'/>
</edit:with>
<div class="ready-for-wider-review">
<h3 id="RadialGradients">Radial gradients</h3>
<edit:with element='radialGradient'>
<p id="RadialGradientElement">Radial gradients are defined by a
<a>'radialGradient'</a> element.</p>
<edit:elementsummary name='radialGradient'/>
<h4 id="RadialGradientAttributes">Attributes</h4>
<p class="note">
Note that the <a>'cx'</a>,<a>'cy'</a>, and <a>'r'</a> attributes
on a <a>'radialGradient'</a> are not presentation attributes;
the used value is not affected by CSS styles.
The <a>'gradientTransform'</a> attribute is a presentation attribute
for the <a>'transform'</a> property.
</p>
<dl class="attrdef-list-svg2">
<dt id="RadialGradientElementGradientUnitsAttribute">
<span class="adef">gradientUnits</span> =
"<span class="attr-value">userSpaceOnUse | objectBoundingBox</span>"
</dt>
<dd>
<p>
Defines the coordinate system for attributes
<a>'cx'</a>, <a>'cy'</a>, <a>'r'</a>, <a>'fx'</a>, <a>'fy'</a>, and <a>'fr'</a>.
</p>
<dl class="attrdef-svg2">
<!--
<dt>Value</dt> <dd>userSpaceOnUse | objectBoundingBox</dd>
-->
<dt><a>Initial value</a></dt> <dd>objectBoundingBox</dd>
<dt><a>Animatable</a></dt> <dd>yes</dd>
</dl>
<dl class="attrdef-values">
<dt>userSpaceOnUse</dt>
<dd>
<p>
If <span class="attr-value">gradientUnits="userSpaceOnUse"</span>,
<a>'cx'</a>, <a>'cy'</a>, <a>'r'</a>, <a>'fx'</a>, <a>'fy'</a>,
and <a>'fr'</a>
represent values in the coordinate system that results
from taking the current user coordinate system in place at
the time when the gradient element is referenced (i.e.,
the user coordinate system for the element referencing the
gradient element via a <a>'fill'</a> or <a>'stroke'</a>
property) and then applying the transform specified by
attribute <a>'gradientTransform'</a>. Percentages
represent values relative to the current SVG viewport.
</p>
</dd>
<dt>objectBoundingBox</dt>
<dd>
<p>
If <span class="attr-value">gradientUnits="objectBoundingBox"</span>,
the user coordinate system for attributes
<a>'cx'</a>, <a>'cy'</a>, <a>'r'</a>, <a>'fx'</a>, <a>'fy'</a>,
and <a>'fr'</a>
is established using the bounding box of the element to
which the gradient is applied
(see <a href="coords.html#ObjectBoundingBox">Object
bounding box units</a>) and then applying the transform
specified by attribute <a>'gradientTransform'</a>.
Percentages represent values relative to the bounding box
for the object.
</p>
<p>
When <span class="attr-value">gradientUnits="objectBoundingBox"</span>
and <a>'gradientTransform'</a> is the identity matrix,
then the rings of the radial gradient are circular with
respect to the object bounding box space (i.e., the
abstract coordinate system where (0,0) is at the top/left
of the object bounding box and (1,1) is at the
bottom/right of the object bounding box). When the
object's bounding box is not square, the rings that are
conceptually circular within object bounding box space
will render as elliptical due to application of the
non-uniform scaling transformation from bounding box space
to user coordinate system.
</p>
</dd>
</dl><!-- Attribute values -->
</dd>
<dt id="RadialGradientElementGradientTransformAttribute">
<span class="adef">gradientTransform</span> =
"<span class="attr-value"><a><transform-list></a></span>"
</dt>
<dd>
<p>
Contains the definition of an optional additional
transformation from the gradient coordinate system onto the
target coordinate system
(i.e., <span class='attr-value'>'userSpaceOnUse'</span> or
<span class='attr-value'>'objectBoundingBox'</span>).
This allows for things such as skewing the gradient.
This additional transformation matrix is post-multiplied to
(i.e., inserted to the right of) any previously defined
transformations, including the implicit transformation
necessary to convert
from <a href="coords.html#ObjectBoundingBox">object bounding
box units</a> to user coordinate system.
</p>
<dl class="attrdef-svg2">
<!-- <dt>Value</dt> <dd><a><transform-list></a></dd> -->
<dt><a>Initial value</a></dt> <dd>identity transform</dd>
<dt><a>Animatable</a></dt> <dd>yes</dd>
</dl>
</dd>
<dt id="RadialGradientElementCXAttribute">
<span class="adef">cx</span> =
"<span class="attr-value"><a><length></a></span>"
</dt>
<dd>
<p>
<a>'cx'</a>, <a>'cy'</a> and <a>'r'</a> define the end circle for the radial gradient. The
gradient will be drawn such that the
100% <a href="#GradientStops">gradient stop</a> is mapped
to the perimeter of this end circle.
</p>
<dl class="attrdef-svg2">
<!-- <dt>Value</dt> <dd><a><length></a></dd> -->
<dt><a>Initial value</a></dt> <dd>50%</dd>
<dt><a>Animatable</a></dt> <dd>yes</dd>
</dl>
</dd>
<dt id="RadialGradientElementCYAttribute">
<span class="adef">cy</span> =
"<span class="attr-value"><a><length></a></span>"
</dt>
<dd>
<p>
See <a>'cx'</a>.
</p>
<dl class="attrdef-svg2">
<!-- <dt>Value</dt> <dd><a><length></a></dd> -->
<dt><a>Initial value</a></dt> <dd>50%</dd>
<dt><a>Animatable</a></dt> <dd>yes</dd>
</dl>
</dd>
<dt id="RadialGradientElementRAttribute">
<span class="adef">r</span> =
"<span class="attr-value"><a><length></a></span>"
</dt>
<dd>
<p>
See <a>'cx'</a>.
</p>
<p>
A negative value is an error
(see <a href="conform.html#ErrorProcessing">Error
processing</a>).
</p>
<dl class="attrdef-svg2">
<!-- <dt>Value</dt> <dd><a><length></a></dd> -->
<dt><a>Initial value</a></dt> <dd>50%</dd>
<dt><a>Animatable</a></dt> <dd>yes</dd>
</dl>
</dd>
<dt id="RadialGradientElementFXAttribute">
<span class="adef">fx</span> =
"<span class="attr-value"><a><length></a></span>"
</dt>
<dd>
<p>
<a>'fx'</a>, <a>'fy'</a>, and <a>'fr'</a> define the start
circle for the radial gradient. The
gradient will be drawn such that the
0% <a href="#GradientStops">gradient stop</a> is mapped
to the perimeter of this start circle.
</p>
<dl class="attrdef-svg2">
<!-- <dt>Value</dt> <dd><a><length></a></dd> -->
<dt><a>Initial value</a></dt> <dd>see below</dd>
<dt><a>Animatable</a></dt> <dd>yes</dd>
</dl>
<p>
If attribute <a>'fx'</a> is not specified, <a>'fx'</a> will coincide
with the presentational value of <a>'cx'</a> for the element whether the
value for 'cx' was inherited or not. If the element references an
element that specifies a value for 'fx', then the value of 'fx' is
inherited from the referenced element.
</p>
<div class="figure">
<img
alt="Diagram of various radial gradient attributes."
src="images/pservers/radial_gradient_dimensions.png"/>
<p class="caption">
This diagram shows how the geometric attributes are defined
for the case where <a>'fr'</a> is 50% of <a>'r'</a>. The
small circle marks the center of the outermost circle
(<a>'cx'</a>,<a>'cy'</a>), while the cross marks the center
of the innermost circle (<a>'fx'</a>,<a>'fy'</a>). The
dashed lines show two gradient vectors. Vectors connect
corresponding points on the inner and outer most circles.
The region outside the outer circle is painted with the
last <a>'stop-color'</a> while the region inside the inner
circle is painted with the first <a>'stop-color'</a>.
</p>
</div>
</dd>
<dt id="RadialGradientElementFYAttribute">
<span class="adef">fy</span> =
"<span class="attr-value"><a><length></a></span>"
</dt>
<dd>
<p>
See <a>'fx'</a>.
</p>
<dl class="attrdef-svg2">
<!-- <dt>Value</dt> <dd><a><length></a></dd> -->
<dt><a>Initial value</a></dt> <dd>see below</dd>
<dt><a>Animatable</a></dt> <dd>yes</dd>
</dl>
<p>
If attribute <a>'fy'</a> is not specified, <a>'fy'</a>
will coincide with the presentational value of <a>'cy'</a>
for the element whether the value for 'cy' was inherited
or not. If the element references an element that
specifies a value for 'fy', then the value of 'fy' is
inherited from the referenced element.
</p>
</dd>
<dt id="RadialGradientElementFRAttribute">
<span class="adef">fr</span> =
"<span class="attr-value"><a><length></a></span>"
</dt>
<dd>
<p class="note">New in SVG 2. Added to align with Canvas.</p>
<p>
<a>'fr'</a> is the radius of the focal circle. See <a>'fx'</a>.
</p>
<p>
A negative value is an error
(see <a href="conform.html#ErrorProcessing">Error
processing</a>).
</p>
<dl class="attrdef-svg2">
<!-- <dt>Value</dt> <dd><a><length></a></dd> -->
<dt><a>Initial value</a></dt> <dd>0%, see below</dd>
<dt><a>Animatable</a></dt> <dd>yes</dd>
</dl>
<p>
If the attribute is not specified, the effect is as if a
value of <span class='attr-value'>'0%'</span> were
specified. If the element references an element that
specifies a value for 'fr', then the value of 'fr' is
inherited from the referenced element.
</p>
<div class="annotation svg2-requirement">
<table>
<tr>
<th>SVG 2 Requirement:</th>
<td>Allow specifying focal circle radius in radial gradients.</td>
</tr>
<tr>
<th>Resolution:</th>
<td><a href="http://www.w3.org/2011/07/29-svg-minutes.html#item06">Add an <span class="attr-name">'fr'</span> attribute to <span class="element-name">'radialGradient'</span>> for SVG 2.</a></td>
</tr>
<tr>
<th>Purpose:</th>
<td>To align with Canvas. The zero-offset stop would be along the circle
defined by the <span class="attr-name">'fx'</span>, <span class="attr-name">'fy'</span>
and <span class="attr-name">'fr'</span> attributes.</td>
</tr>
<tr>
<th>Owner:</th>
<td>Erik (<a href="http://www.w3.org/Graphics/SVG/WG/track/actions/3098">ACTION-3098</a>)</td>
</tr>
</table>
</div>
</dd>
<dt id="RadialGradientElementSpreadMethodAttribute">
<span class="adef">spreadMethod</span> = "pad | reflect | repeat"
</dt>
<dd>
<p>
Indicates what happens if the gradient starts or ends inside
the bounds of the object(s) being painted by the gradient. Has
the same values and meanings as the <a>'linearGradient/spreadMethod'</a>
attribute on <a>'linearGradient'</a> element.
</p>
<dl class="attrdef-svg2">
<!-- <dt>Value</dt> <dd>pad | reflect | repeat</dd> -->
<dt><a>Initial value</a></dt> <dd>pad</dd>
<dt><a>Animatable</a></dt> <dd>yes</dd>
</dl>
</dd>
<dt id="RadialGradientElementHrefAttribute">
<span class="adef">href</span> =
<a href="types.html#attribute-url" class="syntax">[URL]</a>
</dt>
<dd>
<p>
A <a>URL reference</a> to a template gradient element;
to be valid, the reference must be to a
<a>'linearGradient'</a> element or
a different <a>'radialGradient'</a> element.
</p>
<p>
Refer to the process for <a href="#PaintServerTemplates">using paint servers as templates</a>,
and to the common handling defined for <a
href="linking.html#linkRefAttrs">URL reference attributes</a> and
<a href="linking.html#XLinkRefAttrs">deprecated XLink attributes</a>.
</p>
<p>
The specified attributes that will be copied from the template are:
</p>
<ul>
<li><a>'cx'</a></li>
<li><a>'cy'</a></li>
<li><a>'r'</a></li>
<li><a>'fx'</a></li>
<li><a>'fy'</a></li>
<li><a>'fr'</a></li>
<li><a>'gradientTransform'</a></li>
<li><a>'gradientUnits'</a></li>
<li><a>'spreadMethod'</a></li>
</ul>
<p>
Refer to the common handling defined for <a
href="linking.html#linkRefAttrs">URL reference attributes</a> and
<a href="linking.html#XLinkRefAttrs">deprecated XLink attributes</a>.
</p>
<dl class="attrdef-svg2">
<!-- <dt>Value</dt> <dd><a><url></a></dd> -->
<dt><a>Initial value</a></dt> <dd>empty</dd>
<dt><a>Animatable</a></dt> <dd>yes</dd>
</dl>
</dd>