-
Notifications
You must be signed in to change notification settings - Fork 22.4k
/
index.md
98 lines (79 loc) · 3.11 KB
/
index.md
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
---
title: path
slug: Web/SVG/Attribute/path
page-type: svg-attribute
spec-urls:
- https://svgwg.org/svg2-draft/text.html#TextPathElementPathAttribute
- https://svgwg.org/specs/animations/#AnimateMotionElementPathAttribute
---
{{SVGRef}}
The **`path`** attribute has two different meanings, either it defines a text path along which the characters of a text are rendered, or a motion path along which a referenced element is animated.
You can use this attribute with the following SVG elements:
- {{SVGElement("animateMotion")}}
- {{SVGElement("textPath")}}
## Example
```css hidden
html,
body,
svg {
height: 100%;
}
```
```html
<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
<path
id="MyPath"
fill="none"
stroke="silver"
d="M10,90 Q90,90 90,45 Q90,10 50,10 Q10,10 10,40 Q10,70 45,70 Q70,70 75,50" />
<text>
<textPath
path="M10,90 Q90,90 90,45 Q90,10 50,10 Q10,10 10,40 Q10,70 45,70 Q70,70 75,50">
Quick brown fox jumps over the lazy dog.
</textPath>
</text>
</svg>
```
{{EmbedLiveSample("Example", "420", "220")}}
## animateMotion
For {{SVGElement("animateMotion")}}, `path` defines the motion path, expressed in the same format and interpreted the same way as the {{SVGAttr("d")}} geometric property for the {{SVGElement("path")}} element. The effect of a motion path animation is a translation along the x- and y-axes of the current user coordinate system by the x and y values computed over time.
<table class="properties">
<tbody>
<tr>
<th scope="row">Value</th>
<td><code><path-data></code></td>
</tr>
<tr>
<th scope="row">Default value</th>
<td><em>None</em></td>
</tr>
<tr>
<th scope="row">Animatable</th>
<td>No</td>
</tr>
</tbody>
</table>
- `<path-data>`
- : This value defines the motion path along which the referenced element is animated. For detailed information about the commands that can be used, see the [explanation for the `d` attribute](/en-US/docs/Web/SVG/Attribute/d#path_commands).
## textPath
For {{SVGElement("textPath")}}, `path` defines the path onto which the {{Glossary("glyph", "glyphs")}} of a {{SVGElement("text")}} element will be rendered. An empty string indicates that there is no path data for the element. This means that the text within the `<textPath>` element does not render or contribute to the bounding box of the `<text>` element. If the attribute is not specified, the path specified in {{SVGAttr("href")}} is used instead.
<table class="properties">
<tbody>
<tr>
<th scope="row">Value</th>
<td><code><path-data></code></td>
</tr>
<tr>
<th scope="row">Default value</th>
<td><em>Path specified in {{SVGAttr("href")}}</em></td>
</tr>
<tr>
<th scope="row">Animatable</th>
<td>Yes</td>
</tr>
</tbody>
</table>
- `<path-data>`
- : This value defines the text path along which the glyphs of the `<text>` element are aligned. For detailed information about the commands that can be used, see the [explanation for the `d` attribute](/en-US/docs/Web/SVG/Attribute/d#path_commands).
## Specifications
{{Specifications}}