SVG绘制线段

SVG绘制线段

<svg xmlns="http://www.w3.org/2000/svg"
     width="200px" height="200px" viewBox="0 0 200 200">
    <!--画笔颜色-->
    <line x1="10" y1="10" x2="50" y2="10" style="stroke: red;stroke-width: 5;"/>
    <line x1="10" y1="20" x2="50" y2="20" style="stroke: #9f9;stroke-width: 5;"/>
    <line x1="10" y1="30" x2="50" y2="30" style="stroke: #9999ff;stroke-width: 5;"/>
    <line x1="10" y1="40" x2="50" y2="40" style="stroke: rgb(255,128,65);stroke-width: 5;"/>
    <line x1="10" y1="50" x2="50" y2="50" style="stroke: rgb(60%,20%,60%);stroke-width: 5;"/>
    <!--画笔透明度-->
    <line x1="10" y1="60" x2="50" y2="60" style="stroke: red;stroke-width: 5;stroke-opacity:0.2"/>
    <line x1="10" y1="70" x2="50" y2="70" style="stroke: red;stroke-width: 5;stroke-opacity:0.4"/>
    <line x1="10" y1="80" x2="50" y2="80" style="stroke: red;stroke-width: 5;stroke-opacity:0.6"/>
    <line x1="10" y1="90" x2="50" y2="90" style="stroke: red;stroke-width: 5;stroke-opacity:0.8"/>
    <line x1="10" y1="100" x2="50" y2="100" style="stroke: red;stroke-width: 5;stroke-opacity:1"/>

    <!--画笔点线或虚线-->
    <!--9个像素的实线,5个像素的空隙-->
    <line x1="10" y1="110" x2="100" y2="110" style="stroke-dasharray:9,5;stroke:black;stroke-width:2" />
    <!--5个像素的实线,3个像素的空隙,9个像素的实线,2个像素的空隙-->
    <line x1="10" y1="120" x2="100" y2="120" style="stroke-dasharray:5,3,9,2;stroke:black;stroke-width:2" />
    <!--复制奇数个数,这等价于:9个像素的实线,3个像素的空隙,5个像素的实线,9个像素的空隙,3个像素的实线,5个像素的空隙-->
    <line x1="10" y1="130" x2="100" y2="130" style="stroke-dasharray:9,3,5;stroke:black;stroke-width:2" />
</svg>
上一篇:SVG绘制矩形


下一篇:svg简单使用