points - SVG: Scalable Vector Graphics 编辑

The points attribute defines a list of points. Each point is defined by a pair of number representing a X and a Y coordinate in the user coordinate system. If the attribute contains an odd number of coordinates, the last one will be ignored.

Two elements are using this attribute: <polyline>, and <polygon>

html,body,svg { height:100% }
<svg viewBox="-10 -10 220 120" xmlns="http://www.w3.org/2000/svg">
  <!-- polyline is an open shape -->
  <polyline stroke="black" fill="none"
   points="50,0 21,90 98,35 2,35 79,90"/>

  <!-- polygon is a closed shape -->
  <polygon stroke="black" fill="none" transform="translate(100,0)"
   points="50,0 21,90 98,35 2,35 79,90"/>

  <!--
  It is usualy considered best practices to separate a X and Y
  coordinate with a comma and a group of coordinates by a space.
  It makes things more readable for human beings.
  -->
</svg>

polyline

For <polyline>, points defines a list of points, each representing a vertex of the line to be drawn. Each point is define by a X and Y coordinate in the user coordinate system.

Note: A polyline is an open shape, meaning the last point is not connected to the first point.

Value[ <number>+ ]#
Default valuenone
AnimatableYes

Example

html,body,svg { height:100% }
<svg viewBox="-10 -10 120 120" xmlns="http://www.w3.org/2000/svg">
  <!-- polyline is an open shape -->
  <polyline stroke="black" fill="none"
   points="50,0 21,90 98,35 2,35 79,90"/>
</svg>

polygon

For <polygon>, points defines a list of points, each representing a vertex of the shape to be drawn. Each point is define by a X and Y coordinate in the user coordinate system.

Note: A polygon is a closed shape, meaning the last point is connected to the first point.

Value[ <number>+ ]#
Default valuenone
AnimatableYes

Example

html,body,svg { height:100% }
<svg viewBox="-10 -10 120 120" xmlns="http://www.w3.org/2000/svg">
  <!-- polygon is an closed shape -->
  <polygon stroke="black" fill="none"
   points="50,0 21,90 98,35 2,35 79,90" />
</svg>

Specifications

SpecificationStatusComment
Scalable Vector Graphics (SVG) 2
The definition of 'points' in that specification.
Candidate RecommendationDefinition for <polygon>
Scalable Vector Graphics (SVG) 2
The definition of 'points' in that specification.
Candidate RecommendationDefinition for <polyline>
Scalable Vector Graphics (SVG) 1.1 (Second Edition)
The definition of 'points' in that specification.
RecommendationInitial definition for <polygon>
Scalable Vector Graphics (SVG) 1.1 (Second Edition)
The definition of 'points' in that specification.
RecommendationInitial definition for <polyline>

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

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

发布评论

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

词条统计

浏览:118 次

字数:6382

最后编辑:8年前

编辑次数:0 次

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