点
points 属性定义了一组点。每个点由一对数字定义,代表用户坐标系中的 X 和 Y 坐标。如果属性包含奇数个坐标,最后一个将被忽略。
你可以将此属性与以下 SVG 元素一起使用
示例
html
<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 usually 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
对于 <polyline>,points 定义了一个点列表,每个点代表要绘制线条的顶点。每个点都由用户坐标系中的 X 和 Y 坐标定义。
注意: 折线是一种开放形状,意味着最后一个点不与第一个点连接。
| 值 | [ <number>+ ]# |
|---|---|
| 默认值 | none |
| 可动画的 | 是 |
html
<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
对于 <polygon>,points 定义了一个点列表,每个点代表要绘制形状的顶点。每个点都由用户坐标系中的 X 和 Y 坐标定义。
注意: 多边形是一种闭合形状,意味着最后一个点与第一个点连接。
| 值 | [ <number>+ ]# |
|---|---|
| 默认值 | none |
| 可动画的 | 是 |
html
<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>
规范
| 规范 |
|---|
| Scalable Vector Graphics (SVG) 2 # PolygonElementPointsAttribute |
| Scalable Vector Graphics (SVG) 2 # PolylineElementPointsAttribute |