-
Notifications
You must be signed in to change notification settings - Fork 22.4k
/
index.md
86 lines (65 loc) · 1.84 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
---
title: <mpath>
slug: Web/SVG/Element/mpath
page-type: svg-element
browser-compat: svg.elements.mpath
---
{{SVGRef}}
The **`<mpath>`** sub-element for the {{SVGElement("animateMotion")}} element provides the ability to reference an external {{SVGElement("path")}} element as the definition of a motion path.
## Usage context
{{svginfo}}
## Attributes
- {{SVGAttr("xlink:href")}} {{deprecated_inline}}
## DOM Interface
This element implements the {{domxref("SVGMPathElement")}} interface.
## Example
### SVG
```html
<svg
width="100%"
height="100%"
viewBox="0 0 500 300"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<rect
x="1"
y="1"
width="498"
height="298"
fill="none"
stroke="blue"
stroke-width="2" />
<!-- Draw the outline of the motion path in blue, along
with three small circles at the start, middle and end. -->
<path
id="path1"
d="M100,250 C 100,50 400,50 400,250"
fill="none"
stroke="blue"
stroke-width="7.06" />
<circle cx="100" cy="250" r="17.64" fill="blue" />
<circle cx="250" cy="100" r="17.64" fill="blue" />
<circle cx="400" cy="250" r="17.64" fill="blue" />
<!-- Here is a triangle which will be moved about the motion path.
It is defined with an upright orientation with the base of
the triangle centered horizontally just above the origin. -->
<path
d="M-25,-12.5 L25,-12.5 L 0,-87.5 z"
fill="yellow"
stroke="red"
stroke-width="7.06">
<!-- Define the motion path animation -->
<animateMotion dur="6s" repeatCount="indefinite" rotate="auto">
<mpath href="#path1" />
</animateMotion>
</path>
</svg>
```
### Result
{{EmbedLiveSample("Example", 250, 400)}}
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{SVGElement("animateMotion")}}