SVG: Scalable Vector Graphics(可伸缩矢量图形)
它使用XML格式来定义图形,例如:
<svg>
<rect width="100" height="100" x="0" y="0"
style="fill:red; stroke:black; stroke-width:5">
</svg>
优点:
1、SVG图片它在放大或缩小时不会像图片一样失真;
2、SVG图片可以被搜索、索引、加载脚步和压缩;
3、SVG图片它可扩展;
4、SVG是开放的标准;
5、SVG是纯XML文件。
DEMO:
————————————————————————————————————————————————
1、rectangle矩形
<svg>
<rect x="50" y="20" rx="50" ry="50" width="200" height="200"
style="fill:red;stroke:black;stroke-width:5;opacity:0.5" />
</svg>
————————————————————————————————————————————————
2、Circle圆形
<svg>
<circle cx="100" cy="50" r="40" fill="red" stroke="black" stroke-width="20"
fill-opacity="0.8" stroke-opacity="0.5" />
</svg>
————————————————————————————————————————————————
3、Ellipse椭圆
<svg>
<ellipse cx="300" cy="80" rx="100" ry="50" style="fill:yellow; stroke:purple; stroke-width:2" />
</svg>
————————————————————————————————————————————————
4、Line线
<svg>
<line x1="0" y1="0" x2="200" y2="50" stroke-width="5" stroke="black" />
</svg>
————————————————————————————————————————————————
5、Polygon多边形
<svg>
<polygon points="100,10 40,180 190,60 10,60 160,180" style="fill:lime;stroke:purple;stroke-width:5;fill-rule:evenodd"/>
</svg>
————————————————————————————————————————————————
6、Polyline折线
<svg>
<polyline points="0,40 40,40 40,80 80,80 80,120 120,120 120,160"
style="fill:yellow;stroke:red;stroke-width:4"/>
</svg>
————————————————————————————————————————————————
7、Path路劲
<svg>
<path id="lineAB" d="M 100 350 l 150 -300" stroke="red" stroke-width="3" fill="none" />
<path id="lineBC" d="M 250 50 l 150 300" stroke="red" stroke-width="3" fill="none" />
<path id="lineBC" d="M 175 200 l 150 0" stroke="red" stroke-width="3" fill="none" />
<path id="quadcurveABC" d="M 100 350 q 150 -300 300 0" stroke="blue" stroke-width="5" fill="none" />
<!-- Mark relevant points -->
<g stroke="black" stroke-width="3" fill="black">
<circle id="pointA" cx="100" cy="350" r="3" />
<circle id="pointB" cx="250" cy="50" r="3" />
<circle id="pointC" cx="400" cy="350" r="3" />
</g>
<!-- Label the points -->
<g font-size="30" font="sans-serif" fill="black" stroke="none" text-anchor="middle">
<text x="100" y="350" dx="-30">A</text>
<text x="250" y="50" dy="-10">B</text>
<text x="400" y="350" dx="30">C</text>
</g>
</svg>
————————————————————————————————————————————————
8、Text文字
<svg>
<text x="0" y="15" fill="red" transform="rotate(30 20,40)">I Love SVG</text>
</svg>
————————————————————————————————————————————————
9、Stroke描边
<svg>
<g fill="none" stroke="black" stroke-width="4">
<path stroke-dasharray="5,5" d="M5 20 l215 0" />
<path stroke-dasharray="10,10" d="M5 40 l215 0" />
<path stroke-dasharray="20,10,5,5,5,10" d="M5 60 l215 0" />
</g>
</svg>
————————————————————————————————————————————————
————————————————————————————————————————————————