blob: 10a2ca69eb0f0c16b579249c1e207ee5fa5b0fe0 (
plain)
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
|
---
title: mpath
slug: Web/SVG/Element/mpath
tags:
- SVG
- SVG动画
- 元素
- 参考
- 需要兼容性表
- 需要示例
translation_of: Web/SVG/Element/mpath
---
<div>{{SVGRef}}</div>
<p>{{ SVGElement("animateMotion") }} 元素的<code>mpath</code>子元素使{{ SVGElement("animateMotion") }} 元素能够引用一个外部的{{ SVGElement("path") }}元素作为运动路径的定义。</p>
<h2 id="用法">用法</h2>
<p>{{svginfo}}</p>
<h2 id="示例">示例</h2>
<pre class="brush: 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 xlink:href="#path1"/>
</animateMotion>
</path>
</svg>
</pre>
<p>实时输出:</p>
<p>{{EmbedLiveSample("Example",250,165)}}</p>
<h2 id="属性">属性</h2>
<h3 id="全局属性">全局属性</h3>
<ul>
<li><a href="/en/SVG/Attribute#Core" title="en/SVG/Attribute#Core">核心属性</a> »</li>
<li><a href="/en/SVG/Attribute#XLink" title="en/SVG/Attribute#XLink">Xlink属性</a> »</li>
<li>{{ SVGAttr("externalResourcesRequired") }}</li>
</ul>
<h3 id="专有属性">专有属性</h3>
<ul>
<li>{{ SVGAttr("xlink:href") }}</li>
</ul>
<h2 id="DOM_接口">DOM 接口</h2>
<p>该元素实现了<code><a href="/en/DOM/SVGMPathElement" title="en/DOM/SVGMPathElement">SVGMPathElement</a></code>接口。</p>
<h2 id="相关的内容">相关的内容</h2>
<ul>
<li>{{ SVGElement("animateMotion") }}</li>
</ul>
|