<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
<circle cx="100" cy="50" r="40" stroke="black" stroke-width="2" fill="red" />
svg>
<a href="circle1.svg">查看 SVG 文件a>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
<rect width="300" height="100" style="fill:rgb(0,0,255);stroke-width:1;stroke:rgb(0,0,0)">rect>
svg>

<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
<rect
x="50"
y="20"
width="150"
height="150"
style="fill:blue;stroke:pink;stroke-width:5;stroke-opacity:0.9;fill-opacity:0.1"
>rect>
svg>

<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
<rect
x="30"
y="20"
width="150"
height="150"
stroke-width="5"
style="fill:blue;stroke:pink;opacity:0.5"
/>
svg>

<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
<rect
x="50"
y="20"
rx="20"
ry="20"
width="150"
height="150"
style="fill:red;stroke:black;stroke-width:5;opacity:0.5"
>rect>
svg>

<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
<circle
cx="100"
cy="50"
r="40"
stroke-width="2"
style="fill:red;stroke:black;"
/>
svg>

<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
<ellipse cx="150" cy="100" rx="100" ry="50" style="fill:yellow;stroke:purple;stroke-width:2;"/>
svg>

<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
<ellipse cx="200" cy="100" rx="100" ry="30" style="fill:yellow;" />
<ellipse cx="200" cy="80" rx="80" ry="30" style="fill:purple;" />
<ellipse cx="200" cy="60" rx="60" ry="30" style="fill:pink" />
svg>

<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
<ellipse cx="150" cy="100" rx="100" ry="30" style="fill:yellow;" />
<ellipse cx="150" cy="100" rx="90" ry="20" style="fill:white" />
svg>

<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
<line x1="0" y1="200" x2="200" y2="0" style="stroke:yellow;stroke-width:2" />
svg>

<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
<polygon points="200,15 300,30 150,45" style="fill:lime;stroke-width:1;stroke:purple"/>
svg>

五边形
<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
<polygon points="200,15 150,80 180,150 230,150 250,80" style="fill:lightblue;stroke-width:1;stroke:yellow"/>
svg>

<svg width="500" height="210">
<polygon points="100,10 40,198 190,78 10,78 160,198" style="fill:yellow;stroke-width:5;stroke:mediumpurple;fill-rule:nonzero"/>
svg>

fill-rule:evenodd值时候
<svg width="500" height="210">
<polygon points="100,10 40,198 190,78 10,78 160,198" style="fill:yellow;stroke-width:5;stroke:mediumpurple;fill-rule:evenodd"/>
svg>

| 有效值 | nonzero evenodd inherit |
|---|---|
| 默认值 | nonzero |
| 应用于 | shape形状类元素 和 文字内容类元素 |
| 可继承 | 是 |
| 比例 | 无 |
| 媒体 | 可见 |
| 动画可用 | 是 |
<svg width="500" height="500">
<polyline points="10,15 20,35 40,60 80,100 120,150 150,180" style="fill:none;stroke:mediumpurple;stroke-width:3"/>
svg>

<svg width="300" height="300">
<polyline points="20,20 40,20 40,40 60,40 60,60 80,60 80,80 100,80" style="fill:none;stroke:greenyellow;stroke-width:3" />
svg>

| 命令 | 参数 | 描述 |
|---|---|---|
| M | x y | 移动画笔到给定坐标,即起始点 |
| L | x y | 绘制一条到给定坐标的线,可提供多组坐标绘制折线 |
| H | x | 绘制一条到 x 坐标的横线 |
| V | y | 绘制一条到 y 坐标的竖线 |
| C | x y x1 y1 x2 y2 | 绘制一条从当前点到(x,y)的三次贝塞尔曲线,(x1,y1)为曲线的开始控制点,(x2,y2)为曲线的终点控制点 |
| S | x y x1 y1 | 绘制一条从当前点到(x,y)的三次贝塞尔曲线,(x1,y1)为新端点的控制点 |
| Q | x y x1 y1 | 绘制一条从当前点到(x,y),控制点为(x1,y1)的二次贝塞尔曲线 |
| T | x y | 绘制一条从当前点到(x,y)的二次贝塞尔曲线 |
| A | rx ry x-axis-rotation large-arc-flag sweep-flag x y | 绘制当前点到(x,y)的椭圆弧,椭圆弧的 x,y轴半径分别为 rx,ry。椭圆相对于 x 轴旋转 x-axis-rotation 度。large-arc-flag 等于0表示弧线小于180度,等于1表示弧线大于180度。sweep-flag 等于0 表示弧线逆时针旋转,等于1表示弧线顺时针选装 |
| Z | 闭合路径 |
<svg width="300" height="300">
<path d="M150 0 L75 200 L225 200 Z"/>
svg>

<svg xmlns="http://www.w3.org/2000/svg" version="1.1" height="400" width="450">
<path
id="lineAB"
d="M 100 350 l 150 -300"
style="stroke:red;stroke-width:3;fill:none"
>path>
<path
id="lineBC"
d="M 250 50 l 150 300"
style="stroke:red;stroke-width:3;fill:none"
>path>
<path
d="M 175 200 l 150 0"
style="stroke:green;stroke-width: 3;fill: none"
>path>
<path
d="M 100 350 q 150 -300 300 0"
style="stroke:blue;stroke-width:3;fill:none"
/>
<g stroke-width="3" stroke="black">
<circle cx="100" cy="350" r="3"/>
<circle cx="250" cy="50" r="3"/>
<circle cx="400" cy="350" r="3" />
g>
<g font-size="30" font="sans-serif" stroke="none" fill="black" text-anchor="middle">
<text x="100" y="350" dx="-30">Atext>
<text x="250" y="50" dy="-10">Btext>
<text x="400" y="350" dx="30">Ctext>
g>
svg>

<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
<text x="20" y="20" fill="red">你好我是你爸爸text>
svg>

<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
<text x="20" y="20" fill="red" transform="rotate(30 20,40)">
你好我是你爸爸
text>
svg>

<svg xmlns="http://www.w3.org/2000/svg" version="1.1" height="400"
width="400"
xmlns:xlink="http://www.w3.org/1999/xlink">
<defs>
<path
id="road"
d="M0 80 A 50 50 0 0 0 100 80"
>path>
<path
id="road1"
d="M100 80 A 50 50 0 0 1 200 80"
>path>
<path
id="road2"
d="M200 80 A 50 50 0 0 0 300 80"
>path>
<path
id="road3"
d="M300 80 A 50 50 0 0 1 400 80"
>path>
defs>
<text x="10" y="100" style="fill:red;">
<textPath xlink:href="#road">I love SVG I love SVGtextPath>
<textPath xlink:href="#road1">I love SVG I love SVGtextPath>
<textPath xlink:href="#road2">I love SVG I love SVGtextPath>
<textPath xlink:href="#road3">I love SVG I love SVGtextPath>
text>
svg>

<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
<text x="10" y="20" fill="red">
Dear Bob,
<tspan x="50" y="60" fill="blue">你好Jasontspan>
<tspan x="10" y="100" fill="green">好久不见,你在哪里?tspan>
<tspan>我在江湖tspan>
text>
svg>

<svg
xmlns="http://www.w3.org/2000/svg"
version="1.1"
xmlns:xlink="http://www.w3.org/1999/xlink"
>
<a xlink:href="http://www.baidu.com" target="_blank">
<text x="50" y="50" fill="red">百度一下,你就知道text>
a>
svg>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="500" height="500">
<g fill="none">
<path stroke="red" d="M50 50 1350 50">path>
<path stroke="blue" d="M50 100 1350 100">path>
<path stroke="green" d="M50 150 1350 150">path>
g>
svg>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
<g stroke="black">
<path stroke-width="2" d="M5 10 1250 10">path>
<path stroke-width="4" d="M5 20 1250 20">path>
<path stroke-width="6" d="M5 30 1250 30">path>
g>
svg>
<svg xmlns="http://www.w3.org/2000/svg">
<g stroke="black" stroke-width="6">
<path stroke-linecap="butt" d="M5 10 1250 10"/>
<path stroke-linecap="round" d="M5 30 1250 30"/>
<path stroke-linecap="square" d="M5 50 1250 50"/>
g>
svg>
<svg xmlns="http://www.w3.org/2000/svg">
<g stroke="black" stroke-width="4">
<path stroke-dasharray="10,10" d="M5 10 1250 10">path>
<path stroke-dasharray="20,10" d="M5 30 1250 30">path>
<path stroke-dasharray="20,10,15,10,5,2" d="M5 50 1250 50">path>
g>
svg>
滤镜元素
滤镜元素有很多,每一个元素代表一种功能
SVG滤镜定义在
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="400" height="400">
<defs>
<filter id="f1" x="0" y="0">
<feGaussianBlur in="SourceGraphic" stdDeviation="2">feGaussianBlur>
filter>
defs>
<circle cx="60" cy="60" r="50" style="fill:#00a4ff;stroke-width:2;stroke:pink" filter="url(#f1)">circle>
svg>

第一个例子偏移一个矩形(带
<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
<defs>
<filter id="f2" x="0" y="0" width="200%" height="200%">
<feOffset dx="20" dy="20" in="SourceGraphic" result="offOut"/>
filter>
defs>
<rect width="100" height="100" style="fill:yellow;stroke:green;stroke-width:3;" filter="url(#f2)"/>
svg>

<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
<defs>
<filter id="f2" x="0" y="0" width="200%" height="200%">
<feOffset dx="20" dy="20" in="SourceGraphic" result="offOut"/>
<feBlend in="SourceGraphic" in2="offOut" mode="normal"/>
filter>
defs>
<rect width="100" height="100" style="fill:yellow;stroke:green;stroke-width:3;" filter="url(#f2)"/>
svg>

<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="500" height="500">
<defs>
<filter id="f3" x="0" y="0">
<feOffset in="SourceGraphic" dx="20" dy="20" result="offOut" />
<feGaussianBlur in="offOut" stdDeviation="15" result="gaublur" />
<feBlend in="SourceGraphic" in2="gaublur" mode="normal" />
filter>
defs>
<circle cx="100" cy="100" r="100" style="fill:skyblue;stroke-width: 3;stroke: green;" filter="url(#f3)"/>
svg>

<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="1000" height="1000">
<defs>
<filter id="f4" x="0" y="0">
<feOffset in="SourceAlpha" dx="20" dy="20" result="offOut"/>
<feGaussianBlur in="offOut" stdDeviation="15" result="GauBlur"/>
<feBlend in2="GauBlur" in="SourceGraphic" mode="normal" />
filter>
defs>
<ellipse cx="60" cy="110" rx="50" ry="100" style="fill:yellow;stroke-width: 3;stroke: green" filter="url(#f4)"/>
svg>

<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
<defs>
<filter id="f5" x="0" y="0">
<feOffset in="SourceGraphic" dx="20" dy="20" result="offOut" />
<feColorMatrix in="offOut" types="matrix" result="matrixOut"
values="0.2 0 0 0 0 0 0.2 0 0 0 0 0 0.2 0 0 0 0 0 1 0" />
<feGaussianBlur in="matrixOut" stdDeviation="10" result="gaublur" />
<feBlend in="SourceGraphic" in2="gaublur" mode="normal" />
filter>
defs>
<rect width="100" height="100" style="fill:yellow;stroke-width: 3;stroke: green;" filter="url(#f5)"/>
svg>
