-
Notifications
You must be signed in to change notification settings - Fork 136
/
Copy pathpainting.html
3578 lines (3179 loc) · 131 KB
/
painting.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>Painting: Filling, Stroking and Marker Symbols</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>Painting: Filling, Stroking and Marker Symbols</h1>
<div class="ready-for-wider-review">
<h2 id="Introduction">Introduction</h2>
<h3 id="Definitions">Definitions</h3>
<dl class="definitions">
<dt><dfn id="TermFill" data-dfn-type="dfn" data-export="">fill</dfn></dt>
<dd>The operation of <a>painting</a> the interior of a
<a>shape</a> or the interior of the
character glyphs in a text string.</dd>
<dt><dfn id="TermStroke" data-dfn-type="dfn" data-export="">stroke</dfn></dt>
<dd>The operation of <a>painting</a> the outline
of a <a>shape</a> or the outline of
character glyphs in a text string.</dd>
</dl>
<p>Graphical elements that define a shape – <a>'path'</a> elements, <a>basic shapes</a>,
and <a>text content elements</a> – are rendered by being <strong>filled</strong>,
which is painting the interior of the object, and <strong>stroked</strong>, which is
painting along the outline of the object. Filling and stroking are both
<strong>painting</strong> operations. SVG 2 supports a number of
different paints that the fill and stroke of a graphical element can be painted with:</p>
<ul>
<li>a single color,</li>
<li>a gradient (linear or radial)</li>
<li>a pattern (vector or raster, possibly tiled),</li>
<li>other images as specified using CSS Image Value syntax [<a href="refs.html#ref-css-images-3">css-images-3</a>].</li>
</ul>
<p>The paint to use for filling and stroking an element is specified using the
<a>'fill'</a> and <a>'stroke'</a> properties. The following section describes
the different values that can be used for these properties.</p>
<p>Other properties, such as <a>'fill-opacity'</a> and <a>'stroke-width'</a>,
also have an effect on the way fill and stroke paint is applied to the
canvas. The <a href='#FillProperties'>Fill properties</a> and <a href='#StrokeProperties'>Stroke properties</a>
sections below describe these properties.</p>
<p>Some graphics elements – <a>'path'</a> elements and <a>basic
shapes</a> – can also have <strong>marker symbols</strong>
drawn at their vertices or at other positions along the path that
they describe. The <a href='#Markers'>Markers</a> section below describes
how markers can be defined and used.</p>
<p class="annotation">SVG 2 adds markers on shapes. Resolved at
<a href="http://www.w3.org/2013/06/03-svg-minutes.html#item03">Tokyo F2F</a>.</p>
<!--
<p>SVG uses the general notion of a <strong>paint server</strong>. Paint
servers are specified using a <a href="linking.html#URLReference">URL reference</a>
on a <a>'fill'</a> or <a>'stroke'</a> property.
<a href="pservers.html">Gradients and patterns</a> are just specific types of
paint servers.</p>
-->
<h2 id="SpecifyingPaint">Specifying paint</h2>
<div class="annotation svg2-requirement">
<table>
<tr>
<th>SVG 2 Requirement:</th>
<td>Add new paint values for referencing current fill paint, stroke paint, etc.</td>
</tr>
<tr>
<th>Resolution:</th>
<td><a href="http://www.w3.org/2011/07/29-svg-minutes.html#item02">We will add new paint values currentFillPaint, currentStrokePaint etc. to SVG 2</a></td>
</tr>
<tr>
<th>Purpose:</th>
<td>Among other things, to provide an easy way to match marker color to stroke color.</td>
</tr>
<tr>
<th>Owner:</th>
<td>Chris (<a href="http://www.w3.org/Graphics/SVG/WG/track/actions/3094">ACTION-3094</a>)</td>
</tr>
</table>
</div>
<div class="annotation svg2-requirement">
<table>
<tr>
<th>SVG 2 Addition:</th>
<td>Allow multiple paints in fill and stroke.</td>
</tr>
<tr>
<th>Resolution:</th>
<td><a href="http://www.w3.org/2013/06/03-svg-minutes.html#item10">We will allow multiple paints in the fill and stroke properties in SVG 2.</a></td>
</tr>
<tr>
<th>Purpose:</th>
<td>Useful for creating cross hatchings, putting a partially transparent pattern on top of a solid fill, etc.</td>
</tr>
<tr>
<th>Owner:</th>
<td>Tav (<a href="http://www.w3.org/Graphics/SVG/WG/track/actions/3500">ACTION-3500</a>)</td>
</tr>
<tr>
<th>Deferred:</th>
<td>This was dropped for SVG 2, but will be added later in sync with
<a href="https://drafts.fxtf.org/paint/">CSS Fill and Stroke Level 3</a>
</td>
</tr>
</table>
</div>
<p>The <a>'fill'</a> and <a>'stroke'</a> properties, defined below, are used to
specify the <dfn id="TermPaint" data-dfn-type="dfn" data-export="">paint</dfn> used to render the interior of and the
stroke around shapes and text. A paint specification describes a way of putting
color values on to the canvas and is composed of one or more paint layers.
Four types of paints within these paint layers are supported:
<a href="https://www.w3.org/TR/css3-values/#colors">solid colors</a>,
<a href="pservers.html#Gradients">gradients</a>, and
<a href="pservers.html#Patterns">patterns</a>.</p>
<p>A <a><paint></a> value is defined as follows:</p>
<p class="definition prod">
<dfn id="DataTypePaint" data-dfn-type="type" data-export=""><paint></dfn>
= none
| <a><color></a>
| <a><url></a> [none | <a><color></a>]?
| context-fill | context-stroke
</p>
<p>With the possible values:</p>
<dl>
<dt>none</dt>
<dd>No paint is applied in this layer.</dd>
<dt><a><url></a> [none | <a><color></a>]?</dt>
<dd>A URL reference to a <dfn id="TermPaintServerElement" data-dfn-type="dfn" data-export="">paint server element</dfn>,
which is an element that defines a <a href="pservers.html">paint server</a>:
<edit:elementcategory name='paint server'/>, optionally followed by a fall-back
value that is used if the paint server reference cannot be resolved.</dd>
<dt><a><color></a></dt>
<dd>A solid color paint.</dd>
<dt>context-fill</dt>
<dd>Use the paint value of <a>'fill'</a> from a <a>context element</a>.</dd>
<dt>context-stroke</dt>
<dd>Use the paint value of <a>'stroke'</a> from a <a>context element</a>.</dd>
</dl>
<p>A <a><paint></a> allows a paint server reference, to be optionally followed
by a <a><color></a> or the keyword <span class='prop-value'>none</span>.
When this optional value is given, the <a><color></a> value or the value
<span class='prop-value'>none</span> is a fallback value to use if the paint
server reference in the layer is invalid (due to pointing to an element that
does not exist or which is not a valid paint server).</p>
<p class="note">Note that this is slightly different from CSS background syntax, where
a background image and color specified in the final layer of a <a>'background'</a>
value will result in both the image and color being rendered.</p>
<p>If a paint server reference in a <a><paint></a> is invalid, and no
fall-back value is given, no paint is rendered for that layer.</p>
<p class="annotation">This is changed from SVG 1.1 behavior where the document
is in error if a paint server reference is invalid and there is no fallback
color specified.</p>
<div class="example">
<pre><![CDATA[
<rect width="100" height="100" fill="url(#MyHatch) powderblue">
]]></pre>
<div class="figure">
<img
alt="An example with a fallback solid paint fill."
src="images/painting/fallback_paint.svg"/>
<p class="caption">The left rectangle shows the expected fill if MyHatch is defined.
The right rectangle shows the expected fill if MyHatch is missing.</p>
</div>
</div>
<p>For any <a><color></a> value, all color syntaxes
defined in <a href="https://www.w3.org/TR/css-color-3/#colorunits">CSS Color Module Level 3</a>
must be supported, including <span class='prop-value'>rgb()</span>,
<span class='prop-value'>rgba()</span>,
<span class='prop-value'>hsl()</span>,
<span class='prop-value'>hsla()</span>,
the <a href="https://www.w3.org/TR/css-color-3/#svg-color">extended color keywords</a> and
the <span class='prop-value'>currentColor</span> value.</p>
<p id="context-paint">The <span class='prop-value'>context-fill</span> and <span class='prop-value'>context-stroke</span>
values are a reference to the paint layers generated for the <a>'fill'</a> or <a>'stroke'</a>
property, respectively, of the <dfn id="TermContextElement" data-dfn-type="dfn" data-export="">context element</dfn>
of the element being painted. The context element of an element is defined as follows:</p>
<ul>
<li>If the element is within a <a>'marker element'</a>, and
is being rendered as part of that marker due to being referenced
via a <a>marker property</a>, then the context element
is the element referencing that <a>'marker element'</a>.</li>
<li>If the element is within a sub-tree that is instantiated
with a <a>'use'</a> element, then the context element is
that <a>'use'</a> element.</li>
<li>Otherwise, there is no context element.</li>
</ul>
<p>If there is no context element and these keywords are used, then no paint is
applied.
</p>
<p>
When the context paint layers include paint server references, then the
coordinate space and the bounding box used
to scale the paint server elements and content are
those of the <a>context element</a>.
In other words, any gradients and patterns referenced with these keywords
should be continuous from the main shape to the markers,
or from one element within a <a>use-element shadow tree</a> to another.
</p>
<p>If the referenced value of <a>'fill'</a> or <a>'stroke'</a> is a
<span class='prop-value'>context-fill</span> and <span class='prop-value'>context-stroke</span>
value, then those contextual referencing is recursive.</p>
<div class="example">
<edit:includefile href="images/painting/marker-context.svg2.svg"/>
<div class="figure">
<img
alt="An example of the content-stroke keyword used in a marker"
src="images/painting/marker-context.svg11.svg" height="200"/>
<p class="caption">The marker is defined using a shape whose
<a>'stroke'</a> is set to <span class='prop-value'>context-stroke</span>.
This causes the marker to take on the color of each <a>'path'</a>
element that uses the marker.</p>
</div>
</div>
<h2 id="ColorProperty">The effect of the <span class="property">'color'</span> property</h2>
<p class="note">See the CSS Color Module Level 3 specification for the
definition of <a>'color'</a>.
[<a href="refs.html#ref-css-color-3">css-color-3</a>]</p>
<p>The <a>'color'</a> property is used to provide a potential indirect value,
<span class="prop-value">currentColor</span>, for the <a>'fill'</a>,
<a>'stroke'</a>, <a>'stop-color'</a>, <a>'flood-color'</a> and
<a>'lighting-color'</a> properties. The property has no other effect
on SVG elements.</p>
<div class="example">
<p>The following example shows how the inherited value of the
<a>'color'</a> property from an HTML document can be used to
set the color of SVG text in an inline SVG fragment.</p>
<pre><![CDATA[
<!DOCTYPE html>
<style>
body { color: #468; font: 16px sans-serif }
svg { border: 1px solid #888; background-color: #eee }
</style>
<p>Please see the diagram below:</p>
<svg width="200" height="100">
<g fill="currentColor">
<text x="70" y="55" text-anchor="end">START</text>
<text x="130" y="55">STOP</text>
<path d="M 85,45 h 25 v -5 l 10,10 -10,10 v -5 h -25 z"/>
</g>
</svg>
]]></pre>
<div class="figure">
<div class="bordered" style="color: #468; font: 16px sans-serif; display: inline-block; text-align: left; padding: 32px 128px 32px 32px">
<p style="margin-top: 0; margin-bottom: 1em">Please see the diagram below:</p>
<svg xmlns="http://www.w3.org/2000/svg" width="200" height="100" style="border: 1px solid #888; background-color: #eee">
<g fill="currentColor">
<text x="70" y="55" text-anchor="end">START</text>
<text x="130" y="55">STOP</text>
<path d="M 85,45 h 25 v -5 l 10,10 -10,10 v -5 h -25 z"/>
</g>
</svg>
</div>
<p class="caption">The text and arrow in the SVG fragment are filled
with the same color as the inherited <a>'color'</a> property.</p>
</div>
</div>
<h2 id="FillProperties">Fill properties</h2>
<h3 id="SpecifyingFillPaint">Specifying fill paint: the <span class="property">'fill'</span> property</h3>
<table class="propdef def">
<tr>
<th>Name:</th>
<td><dfn id="FillProperty" data-dfn-type="property" data-export="">fill</dfn></td>
</tr>
<tr>
<th>Value:</th>
<td><a><paint></a></td>
</tr>
<tr>
<th>Initial:</th>
<td>black</td>
</tr>
<tr>
<th>Applies to:</th>
<td><a>shapes</a> and <a>text content elements</a></td>
</tr>
<tr>
<th>Inherited:</th>
<td>yes</td>
</tr>
<tr>
<th>Percentages:</th>
<td>N/A</td>
</tr>
<tr>
<th>Media:</th>
<td>visual</td>
</tr>
<tr>
<th>Computed value:</th>
<td>as specified, but with <a><color></a> values computed and
<a><url></a> values made absolute</td>
</tr>
<tr>
<th><a>Animation type</a>:</th>
<td>by computed value</td>
</tr>
</table>
<p>The <a>'fill'</a> property paints the interior of the given graphical
element. The area to be painted consists of any areas inside the outline
of the shape. To determine the inside of the shape, all subpaths are
considered, and the interior is determined according to the rules
associated with the current value of the <a>'fill-rule'</a> property.
The zero-width geometric outline of a shape is included in the area to
be painted.</p>
<p>The fill operation fills <a>open subpaths</a> by performing the fill
operation as if an additional "closepath" command were added to the
path to connect the last point of the subpath with the first point of
the subpath. Thus, fill operations apply to both <a>open subpaths</a> within
<a>'path'</a> elements (i.e., subpaths without a closepath command) and
<a>'polyline'</a> elements.</p>
<h3 id="WindingRule">Winding rule: the <span class="property">'fill-rule'</span>
property</h3>
<table class="propdef def">
<tr>
<th>Name:</th>
<td><dfn id="FillRuleProperty" data-dfn-type="property" data-export="">fill-rule</dfn></td>
</tr>
<tr>
<th>Value:</th>
<td>nonzero | evenodd</td>
</tr>
<tr>
<th>Initial:</th>
<td>nonzero</td>
</tr>
<tr>
<th>Applies to:</th>
<td><a>shapes</a> and <a>text content elements</a></td>
</tr>
<tr>
<th>Inherited:</th>
<td>yes</td>
</tr>
<tr>
<th>Percentages:</th>
<td>N/A</td>
</tr>
<tr>
<th>Media:</th>
<td>visual</td>
</tr>
<tr>
<th>Computed value:</th>
<td>as specified</td>
</tr>
<tr>
<th><a>Animation type</a>:</th>
<td>discrete</td>
</tr>
</table>
<p>The <a>'fill-rule'</a> property indicates the algorithm (or
<em>winding rule</em>) which is to
be used to determine what parts of the canvas are included inside the
shape. For a simple, non-intersecting path, it is intuitively clear
what region lies "inside"; however, for a more complex path, such as a
path that intersects itself or where one subpath encloses another, the
interpretation of "inside" is not so obvious.</p>
<p>The <a>'fill-rule'</a> property provides two options for how the
inside of a shape is determined:</p>
<dl>
<dt><span class='prop-value'>nonzero</span></dt>
<dd>
<p>This rule determines the "insideness" of a point on the
canvas by drawing a ray from that point to infinity in any
direction and then examining the places where a segment of
the shape crosses the ray. Starting with a count of zero,
add one each time a path segment crosses the ray from left
to right and subtract one each time a path segment crosses
the ray from right to left. After counting the crossings,
if the result is zero then the point is <em>outside</em>
the path. Otherwise, it is <em>inside</em>. The following
drawing illustrates the <span class='prop-value'>nonzero</span>
rule:</p>
<div class="figure">
<img class="bordered" src="images/painting/fillrule-nonzero.svg" alt="Image showing nonzero fill rule"/>
<p class="caption">The effect of a nonzero fill rule on paths with self-intersections
and enclosed subpaths.</p>
</div>
</dd>
<dt><span class='prop-value'>evenodd</span></dt>
<dd>
<p>This rule determines the "insideness" of a point on the
canvas by drawing a ray from that point to infinity in any
direction and counting the number of path segments from the
given shape that the ray crosses. If this number is odd,
the point is inside; if even, the point is outside. The
following drawing illustrates the <span class='prop-value'>evenodd</span>
rule:</p>
<div class="figure">
<img class="bordered" src="images/painting/fillrule-evenodd.svg" alt="Image showing evenodd fill rule"/>
<p class="caption">The effect of an evenodd fill rule on paths with self-intersections
and enclosed subpaths.</p>
</div>
</dd>
</dl>
<p class="note">The above descriptions do not specify what to do if a path
segment coincides with or is tangent to the ray. Since any ray will do,
one may simply choose a different ray that does not have such problem
intersections.</p>
<h3 id="FillOpacity">Fill paint opacity: the <span class="property">'fill-opacity'</span>
property</h3>
<table class="propdef def">
<tr>
<th>Name:</th>
<td><dfn id="FillOpacityProperty" data-dfn-type="property" data-export="">fill-opacity</dfn></td>
</tr>
<tr>
<th>Value:</th>
<td><‘<a>'opacity'</a>’></td>
</tr>
<tr>
<th>Initial:</th>
<td>1</td>
</tr>
<tr>
<th>Applies to:</th>
<td><a>shapes</a> and <a>text content elements</a></td>
</tr>
<tr>
<th>Inherited:</th>
<td>yes</td>
</tr>
<tr>
<th>Percentages:</th>
<td>N/A</td>
</tr>
<tr>
<th>Media:</th>
<td>visual</td>
</tr>
<tr>
<th>Computed value:</th>
<td>the specified value converted to a number, clamped to the range [0,1]</td>
</tr>
<tr>
<th><a>Animation type</a>:</th>
<td>by computed value</td>
</tr>
</table>
<p><a>'fill-opacity'</a> specifies the opacity of the painting operation used
to paint the fill the current object. (See
<a href="render.html#PaintingShapesAndText">Painting shapes and text</a>).</p>
<dl>
<dt><span class='prop-value'><number></span></dt>
<dd>
The opacity of the fill. Any values outside the
range 0 (fully transparent) to 1 (fully opaque) must be
clamped to this range.
</dd>
<dt><span class='prop-value'><percentage></span></dt>
<dd>
The opacity of the fill expressed as a percentage
of the range 0 to 1.
</dd>
</dl>
<p class="note">See also the <a>'opacity'</a> property, which
specifies group opacity.</p>
<h2 id="StrokeProperties">Stroke properties</h2>
<div class="annotation svg2-requirement">
<table>
<tr>
<th>SVG 2 Requirement:</th>
<td>Support non-scaling stroke.</td>
</tr>
<tr>
<th>Resolutions:</th>
<td><a href="http://www.w3.org/2011/10/28-svg-irc#T17-46-34">SVG 2 will include non-scaling stroke.</a><br/>
<a href="http://www.w3.org/2012/02/02-svg-minutes.html#item05">SVG 2 will have the <span class="property">'vector-effect'</span> property.</a></td>
</tr>
<tr>
<th>Purpose:</th>
<td>To support strokes whose width does not change when zooming a page, as common for example in maps.</td>
</tr>
<tr>
<th>Owner:</th>
<td>Chris or Erik (no action)</td>
</tr>
<tr>
<th>Note:</th>
<td>Note that this could be part of more generic non-scaling features.</td>
</tr>
</table>
</div>
<p>In this section, we define a number of properties that allow the
author to control different aspects of a stroke, including its paint,
thickness, use of dashing, and joining and capping of
path segments.</p>
<p>In all cases, all stroking properties which are affected by
directionality, such as those having to do with dash patterns, must be
rendered such that the stroke operation starts at the same point at
which the graphics element starts. In particular, for <a>'path'</a>
elements, the start of the path is the first point of the initial
"moveto" command.</p>
<p>For stroking properties such as dash patterns whose computations
are dependent on progress along the outline of the graphics element,
distance calculations are required to utilize the SVG user agent's
standard <a href="paths.html#DistanceAlongAPath">Distance along a path</a>
algorithms.</p>
<p>When stroking is performed using a complex paint server, such as a
gradient or a pattern, the stroke operation must be identical to the
result that would have occurred if the geometric shape defined by the
geometry of the current graphics element and its associated stroking
properties were converted to an equivalent <a>'path'</a> element and
then filled using the given paint server.</p>
<h3 id="SpecifyingStrokePaint">Specifying stroke paint: the <span class="property">'stroke'</span>
property</h3>
<table class="propdef def">
<tr>
<th>Name:</th>
<td><dfn id="StrokeProperty" data-dfn-type="property" data-export="">stroke</dfn></td>
</tr>
<tr>
<th>Value:</th>
<td><a><paint></a></td>
</tr>
<tr>
<th>Initial:</th>
<td>none</td>
</tr>
<tr>
<th>Applies to:</th>
<td><a>shapes</a> and <a>text content elements</a></td>
</tr>
<tr>
<th>Inherited:</th>
<td>yes</td>
</tr>
<tr>
<th>Percentages:</th>
<td>N/A</td>
</tr>
<tr>
<th>Media:</th>
<td>visual</td>
</tr>
<tr>
<th>Computed value:</th>
<td>as specified, but with <a><color></a> values computed and
<a><url></a> values made absolute</td>
</tr>
<tr>
<th><a>Animation type</a>:</th>
<td>by computed value</td>
</tr>
</table>
<p>The <a>'stroke'</a> property paints along the outline of the given
graphical element.</p>
<p class="note">Note that when stroking a <a>'path'</a> element,
any subpath consisting of a <a href="paths.html#PathDataMovetoCommands">moveto</a>
but no following line drawing command will not be stroked.
Any other type of zero-length subpath, such as
<span class="attr-value">'M 10,10 L 10,10'</span>
or <span class="attr-value">'M 30,30 Z'</span>
will also not be stroked if the <a>'stroke-linecap'</a> property has a value of
<span class="prop-value">butt</span>. See the definition of
the <a>stroke shape</a> below for the details of computing
the stroke of a path.</p>
<div class="annotation svg2-requirement">
<table>
<tr>
<th>SVG 2 Requirement:</th>
<td>Include a way to specify stroke position.</td>
</tr>
<tr>
<th>Resolution:</th>
<td><a href="http://www.w3.org/2011/10/28-svg-irc#T18-09-48">SVG 2 shall include a way to specify stroke position.</a></td>
</tr>
<tr>
<th>Purpose:</th>
<td>To allow a stroke to be inside or outside the path.</td>
</tr>
<tr>
<th>Owner:</th>
<td>Cameron (<a href="http://www.w3.org/Graphics/SVG/WG/track/actions/3162">ACTION-3162</a>)</td>
</tr>
<tr>
<th>Note:</th>
<td>See <a href="http://www.w3.org/Graphics/SVG/WG/wiki/Proposals/Stroke_position">proposal page</a>.</td>
</tr>
</table>
</div>
<h3 id="StrokeOpacity">Stroke paint opacity: the <span class="property">'stroke-opacity'</span>
property</h3>
<table class="propdef def">
<tr>
<th>Name:</th>
<td><dfn id="StrokeOpacityProperty" data-dfn-type="property" data-export="">stroke-opacity</dfn></td>
</tr>
<tr>
<th>Value:</th>
<td><‘<a>'opacity'</a>’></td>
</tr>
<tr>
<th>Initial:</th>
<td>1</td>
</tr>
<tr>
<th>Applies to:</th>
<td><a>shapes</a> and <a>text content elements</a></td>
</tr>
<tr>
<th>Inherited:</th>
<td>yes</td>
</tr>
<tr>
<th>Percentages:</th>
<td>N/A</td>
</tr>
<tr>
<th>Media:</th>
<td>visual</td>
</tr>
<tr>
<th>Computed value:</th>
<td>the specified value converted to a number, clamped to the range [0,1]</td>
</tr>
<tr>
<th><a>Animation type</a>:</th>
<td>by computed value</td>
</tr>
</table>
<p>The <a>'stroke-opacity'</a> property specifies the opacity of the
painting operation used to stroke the current object. (See
<a href="render.html#PaintingShapesAndText">Painting shapes and text</a>.)
As with <a>'fill-opacity'</a>.</p>
<dl>
<dt><span class='prop-value'><number></span></dt>
<dd>
The opacity of the stroke. Any values outside the
range 0 (fully transparent) to 1 (fully opaque) must be
clamped to this range.
</dd>
<dt><span class='prop-value'><percentage></span></dt>
<dd>
The opacity of the stroke expressed as a percentage
of the range 0 to 1.
</dd>
</dl>
<p class="note">See also the <a>'opacity'</a> property, which specifies
group opacity.</p>
<h3 id="StrokeWidth">Stroke width: the <span class="property">'stroke-width'</span>
property</h3>
<table class="propdef def">
<tr>
<th>Name:</th>
<td><dfn id="StrokeWidthProperty" data-dfn-type="property" data-export="">stroke-width</dfn></td>
</tr>
<tr>
<th>Value:</th>
<td><a><length-percentage></a> | <a><number></a></td>
</tr>
<tr>
<th>Initial:</th>
<td>1px</td>
</tr>
<tr>
<th>Applies to:</th>
<td><a>shapes</a> and <a>text content elements</a></td>
</tr>
<tr>
<th>Inherited:</th>
<td>yes</td>
</tr>
<tr>
<th>Percentages:</th>
<td>refer to the normalized diagonal of the current SVG viewport (see <a href="coords.html#Units">Units</a>)</td>
</tr>
<tr>
<th>Media:</th>
<td>visual</td>
</tr>
<tr>
<th>Computed value:</th>
<td>an absolute length or percentage, numbers converted to absolute lengths first</td>
</tr>
<tr>
<th><a>Animation type</a>:</th>
<td>by computed value</td>
</tr>
</table>
<p>This property specifies the width of the stroke on the current object.
A zero value causes no stroke to be painted. A negative value
is <a>invalid</a>. A <a><number></a> value represents a value in <a>user units</a>.</p>
<h3 id="LineCaps">Drawing caps at the ends of strokes: the <span class="property">'stroke-linecap'</span>
property</h3>
<table class="propdef def">
<tr>
<th>Name:</th>
<td><dfn id="StrokeLinecapProperty" data-dfn-type="property" data-export="">stroke-linecap</dfn></td>
</tr>
<tr>
<th>Value:</th>
<td>butt | round | square</td>
</tr>
<tr>
<th>Initial:</th>
<td>butt</td>
</tr>
<tr>
<th>Applies to:</th>
<td><a>shapes</a> and <a>text content elements</a></td>
</tr>
<tr>
<th>Inherited:</th>
<td>yes</td>
</tr>
<tr>
<th>Percentages:</th>
<td>N/A</td>
</tr>
<tr>
<th>Media:</th>
<td>visual</td>
</tr>
<tr>
<th>Computed value:</th>
<td>as specified</td>
</tr>
<tr>
<th><a>Animation type</a>:</th>
<td>discrete</td>
</tr>
</table>
<p><a>'stroke-linecap'</a> specifies the shape to be used at the end of
<a>open subpaths</a> when they are stroked, <span class="ready-for-wider-review">
and the shape to be drawn for zero length
subpaths whether they are open or closed.</span> The possible values are:</p>
<dl>
<dt><span class='prop-value'>butt</span></dt>
<dd>This value indicates that the stroke for each subpath does not
extend beyond its two endpoints. A zero length subpath will therefore
not have any stroke.</dd>
<dt><span class='prop-value'>round</span></dt>
<dd>
<p>This value indicates that at each end of each subpath, the shape
representing the stroke will be extended by a half circle with a diameter equal
to the stroke width. If a subpath, <span class="ready-for-wider-review">whether open or closed,</span> has zero length,
then the resulting effect is that the stroke for that subpath consists solely
of a full circle centered at the subpath's point.</p>
</dd>
<dt><span class='prop-value'>square</span></dt>
<dd>
<p>This value indicates that at the end of each subpath, the shape
representing the stroke will be extended by a rectangle with the
same width as the stroke width and whose length is half of the stroke width.
If a subpath, <span class="ready-for-wider-review">whether open or closed,</span> has zero length, then the resulting
effect is that the stroke for that subpath consists solely of a square with
side length equal to the stroke width, centered at the subpath's point, and
oriented such that two of its sides are parallel to the effective tangent
at that subpath's point. See
<a href="paths.html#PathElementImplementationNotes"><span class='element-name'>'path'</span>
element implementation notes</a> for details on how to determine the tangent
at a zero-length subpath.</p>
</dd>
</dl>
<div class="figure">
<img class="bordered" src="images/painting/linecap.svg"
alt="Image showing three paths, each with a different line cap."/>
<p class="caption">The three types of line caps.</p>
</div>
<p>See the definition of the <a>cap shape</a> below for a more precise
description of the shape a line cap will have.</p>
<h3 id="LineJoin">Controlling line joins: the <span class="property">'stroke-linejoin'</span>
and <span class="property">'stroke-miterlimit'</span> properties</h3>
<p class="issue" data-issue="592">
The values <span class="prop-value">miter-clip</span> and <span class="prop-value">arcs</span>
of the <a>'stroke-linejoin'</a> property are at risk. There are no known browser implementations.
See issue <a href="https://github.com/w3c/svgwg/issues/592">GitHub issue #592</a>.</p>
<table class="propdef def">
<tr>
<th>Name:</th>
<td><dfn id="StrokeLinejoinProperty" data-dfn-type="property" data-export="">stroke-linejoin</dfn></td>
</tr>
<tr>
<th>Value:</th>
<td>miter | miter-clip | round | bevel | arcs </td>
</tr>
<tr>
<th>Initial:</th>
<td>miter</td>
</tr>
<tr>
<th>Applies to:</th>
<td><a>shapes</a> and <a>text content elements</a></td>
</tr>
<tr>
<th>Inherited:</th>
<td>yes</td>
</tr>
<tr>
<th>Percentages:</th>
<td>N/A</td>
</tr>
<tr>
<th>Media:</th>
<td>visual</td>
</tr>
<tr>
<th>Computed value:</th>
<td>as specified</td>
</tr>
<tr>
<th>Animation Type:</th>
<td>discrete</td>
</tr>
</table>
<p><a>'stroke-linejoin'</a> specifies the shape to be used at the
corners of paths or basic shapes when they are stroked. For further details see
the <a href="paths.html#PathElementImplementationNotes">path implementation notes</a>.</p>
<dl>
<dt><span class='prop-value'>miter</span></dt>
<dd>This value indicates that a sharp corner is to be used to join path segments.
The corner is formed by extending the outer edges of the stroke at the tangents
of the path segments until they intersect. If the <a>'stroke-miterlimit'</a>
is exceeded, the line join falls back to <span class='prop-value'>bevel</span>
(see below).</dd>
<dt><span class='prop-value'>miter-clip</span></dt>
<dd>This value is the same as <span class='prop-value'>miter</span> but if
the <a>'stroke-miterlimit'</a> is exceeded, the miter is clipped at a
distance equal to half the <a>'stroke-miterlimit'</a> value multiplied
by the stroke width from the intersection of the path segments
(see below).</dd>
<dt><span class='prop-value'>round</span></dt>
<dd>This value indicates that a round corner is to be used to join path segments.
The corner is a circular sector centered on the join point.</dd>
<dt><span class='prop-value'>bevel</span></dt>
<dd>This value indicates that a bevelled corner is to be used to join path segments.
The bevel shape is a triangle that fills the area between the two stroked segments.</dd>
<dt><span class='prop-value'>arcs</span></dt>
<dd>This value indicates that an arcs corner is to be used to join
path segments. The arcs shape is formed by extending the outer
edges of the stroke at the join point with arcs that have the same
curvature as the outer edges at the join point.</dd>
</dl>
<p class="note">
The <span class='prop-value'>miter-clip</span> and
<span class='prop-value'>arcs</span> values are new in SVG 2.
The <span class='prop-value'>miter-clip</span> value offers a more
consistent presentation for a path with multiple joins as well as
better behavior when a path is animated.
The <span class='prop-value'>arcs</span> value provides a better
looking join when the path segments at the join are curved.
</p>
<p class="annotation">
Adding 'arcs' line join was resolved at the
<a href="http://www.w3.org/2012/09/19-svg-minutes.html#item08">Rigi
Kaltbad group meeting</a>.
</p>
<p class="annotation">
Adding 'miter-clip' line join was resolved at the
<a href="http://www.w3.org/2015/02/12-svg-minutes.html#item03">Sydney
(2015) group meeting</a>.
</p>
<div class="figure">
<img class="bordered" src="images/painting/linejoin-four.svg"
alt="Image showing four paths, each with a different line join."/>
<p class="caption">Four types of line joins.</p>
</div>
<table class="propdef def">
<tr>
<th>Name:</th>
<td><dfn id="StrokeMiterlimitProperty" data-dfn-type="property" data-export="">stroke-miterlimit</dfn></td>
</tr>
<tr>
<th>Value:</th>
<td><a><number></a></td>
</tr>
<tr>
<th>Initial:</th>
<td>4</td>
</tr>
<tr>
<th>Applies to:</th>
<td><a>shapes</a> and <a>text content elements</a></td>
</tr>
<tr>
<th>Inherited:</th>
<td>yes</td>
</tr>
<tr>
<th>Percentages:</th>
<td>N/A</td>
</tr>
<tr>
<th>Media:</th>
<td>visual</td>
</tr>
<tr>
<th>Computed value:</th>
<td>as specified</td>
</tr>
<tr>
<th><a>Animation type</a>:</th>
<td>by computed value</td>
</tr>
</table>