SVG <polyline>元素

<polyline>元素用于绘制连接的直线。

声明

以下是<polyline>元素的语法声明。这里只显示了一些主要属性。

<polyline
   points="list of points" >  
</polyline>

属性

编号 属性 描述
1 points 组成折线的点列表。

示例

文件:testSVG.html -

<html>
   <title>SVG折线</title>
   <body>

      <h1>简单SVG折线图片</h1>

      <svg width="800" height="800">
         <g>
            <text x="0" y="15" fill="black" >Polyline #1: Without opacity.</text>

            <polyline points="150,75 258,137.5 258,262.5 150,325 42,262.6 42,137.5"
            stroke="black" stroke-width="3" fill="none"></polyline>
         </g>
      </svg>

   </body>
</html>

在Chrome网络浏览器中打开testSVG.html。 您可以使用Chrome/Firefox/Opera直接查看SVG图像,无需任何插件。 Internet Explorer 9及更高版本还支持SVG图像呈现。

使用opacity示例

<html>
   <title>SVG折线</title>
   <body>

      <h1>简单SVG折线图片</h1>

      <svg width="800" height="800">
         <g>
            <text x="0" y="15" fill="black" >Polyline #2: With opacity </text>

            <polyline points="150,75 258,137.5 258,262.5 150,325 42,262.6 42,137.5"
            style="fill:none;stroke-width:3;
            stroke:rgb(0,0,0);stroke-opacity:0.5;"></polyline>
         </g>
      </svg>

   </body>
</html>

在浏览器中打开上述代码,显示效果如下 -


上一篇: SVG形状 下一篇: SVG文本