svg学习入门 Yannis

废话少说,这里直接开始吧:

 至于svg的发展以及优缺点我就不说了,直接说入手。

<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" 
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">

<svg width="100%" height="100%" version="1.1"
xmlns="http://www.w3.org/2000/svg">
<!-- svg画矩形 参数说明 rect 元素的 
width 和 height 属性可定义矩形的高度和宽度 
x 属性定义矩形的左侧位置(例如,x="0" 定义矩形到浏览器窗口左侧的距离是 0px) 
y 属性定义矩形的顶端位置(例如,y="0" 定义矩形到浏览器窗口顶端的距离是 0px) 
-->
<rect x="20" y="20" width="250" height="250" style="fill:blue;stroke:pink;stroke-5;opacity:0.9"/>
<!--
画圆   参数说明:
cx 圆心x坐标    cy   圆心 y坐标  r 自然是半径了
-->
<circle cx="100" cy="50" r="40" stroke="black"
stroke-width="2" fill="red"/>
<!--
椭圆  参数说明
cx 属性定义圆点的 x 坐标
cy 属性定义圆点的 y 坐标
rx 属性定义水平半径
ry 属性定义垂直半径
-->
<ellipse cx="300" cy="150" rx="200" ry="80" style="fill:white"/>
<!--画线   参数说明:
x1 属性在 x 轴定义线条的开始
y1 属性在 y 轴定义线条的开始
x2 属性在 x 轴定义线条的结束
y2 属性在 y 轴定义线条的结束
-->
<line x1="0" y1="0" x2="300" y2="300" style="stroke:rgb(99,99,99);stroke-2"/>
<!--画多边形   参数说明:
points 属性定义多边形每个角的 x 和 y 坐标
-->
<polygon points="220,100 300,210 170,250" style="fill:#cccccc;stroke:#000000;stroke-1"/>
<!--画折线  参数说明:
points 属性定义多边形每个角的 x 和 y 坐标
-->
<polyline points="0,0 0,20 20,20 20,40 40,40 40,60" style="fill:white;stroke:red;stroke-2"/>
<!--路径  参数说明:
M = moveto   L = lineto  H = horizontal lineto   V = vertical lineto   C = curveto  S = smooth curveto  Q = quadratic Belzier curve  
T = smooth quadratic Belzier curveto  A = elliptical Arc  Z = closepath
由于绘制path过于复杂,所以建议最好使用SVG 编辑器来创建复杂的图形
-->
<path d="M250 150 L150 350 L350 350 Z" />
</svg>
一切学习在实践中学习最快。强烈建议,粘下来,自己看看每一个属性都是干嘛的,这样才能更快提高。
人生苦短,我用python
原文地址:https://www.cnblogs.com/pigga/p/2392217.html