<mpath> - SVG: Scalable Vector Graphics 编辑
The <mpath>
sub-element for the <animateMotion>
element provides the ability to reference an external <path>
element as the definition of a motion path.
Usage context
Categories | Animation element |
---|---|
Permitted content | Any number of the following elements, in any order: Descriptive elements |
Attributes
Global attributes
Specific attributes
DOM Interface
This element implements the SVGMPathElement
interface.
Example
SVG
<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>
Result
Specifications
Specification | Status | Comment |
---|---|---|
SVG Animations Level 2 The definition of '<mpath>' in that specification. | Editor's Draft | No change |
Scalable Vector Graphics (SVG) 1.1 (Second Edition) The definition of '<mpath>' in that specification. | Recommendation | Initial definition |
Browser compatibility
BCD tables only load in the browser
See also
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论