pathLength - SVG 编辑

The pathLength attribute lets authors specify a total length for the path, in user units. This value is then used to calibrate the browser's distance calculations with those of the author, by scaling all distance computations using the ratio pathLength/(computed value of path length).

This can affect the actual rendered lengths of paths; including text paths, animation paths, and various stroke operations. Basically, all computations that require the length of the path. stroke-dasharray, for example, will assume the start of the path being 0 and the end point the value defined in the pathLength attribute.

Seven elements are using this attribute: <circle>, <ellipse>, <line>, <path>, <polygon>, <polyline>, and <rect>

html,body,svg { height:100% }
<svg viewBox="0 0 100 60" xmlns="http://www.w3.org/2000/svg">
  <style>
  path {
    fill: none;
    stroke: black;
    stroke-width: 2;
    stroke-dasharray: 10;
  }
  </style>

  <!-- No pathLength, the real length of the path is used. In that case, 100 user units -->
  <path d="M 0,10 h100"/>

  <!-- compute everything like if the path length was 90 user units long -->
  <path d="M 0,20 h100" pathLength="90"/>

  <!-- compute everything like if the path length was 50 user units long -->
  <path d="M 0,30 h100" pathLength="50"/>

  <!-- compute everything like if the path length was 30 user units long -->
  <path d="M 0,40 h100" pathLength="30"/>

  <!-- compute everything like if the path length was 10 user units long -->
  <path d="M 0,50 h100" pathLength="10"/>
</svg>

circle

For <circle>, pathLength lets authors specify a total length for the circle, in user units.

Value<number>
Default valuenone
AnimatableYes

ellipse

For <ellipse>, pathLength lets authors specify a total length for the ellipse, in user units.

Value<number>
Default valuenone
AnimatableYes

line

For <line>, pathLength lets authors specify a total length for the line, in user units.

Value<number>
Default valuenone
AnimatableYes

path

For <path>, pathLength lets authors specify a total length for the path, in user units.

Value<number>
Default valuenone
AnimatableYes

polygon

For <polygon>, pathLength lets authors specify a total length for the shape, in user units.

Value<number>
Default valuenone
AnimatableYes

polyline

For <polyline>, pathLength lets authors specify a total length for the shape, in user units.

Value<number>
Default valuenone
AnimatableYes

rect

For <circle>, pathLength lets authors specify a total length for the rectangle, in user units.

Value<number>
Default valuenone
AnimatableYes

Specification

SpecificationStatusComment
Scalable Vector Graphics (SVG) 2
pathLength
Candidate Recommendation 
Scalable Vector Graphics (SVG) 1.1 (Second Edition)
pathLength
RecommendationInitial definition

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

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

发布评论

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

词条统计

浏览:65 次

字数:9895

最后编辑:7 年前

编辑次数:0 次

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