path - SVG: Scalable Vector Graphics 编辑

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.

Two elements are using this attribute: <animateMotion> and <textPath>

html, body, svg {
  height: 100%;
}
<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>

animateMotion

For <animateMotion>, path defines the motion path, expressed in the same format and interpreted the same way as the d geometric property for the <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.

Value<path-data>
Default valueNone
AnimatableNo
<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.

textPath

For <textPath>, path defines the path onto which the glyphs of a <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 href is used instead.

Value<path-data>
Default valuePath specified in href
AnimatableYes
<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.

Specifications

SpecificationStatusComment
Scalable Vector Graphics (SVG) 2
The definition of 'path for <textPath>' in that specification.
Candidate RecommendationInitial definition for <textPath>
SVG Animations Level 2
The definition of 'path for <animateMotion>' in that specification.
Editor's DraftNo change
Scalable Vector Graphics (SVG) 1.1 (Second Edition)
The definition of 'path for <animateMotion>' in that specification.
RecommendationInitial definition for <animateMotion>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:80 次

字数:5514

最后编辑:6 年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文