svg

!DOCTYPE html>
<head>
<meta charset="UTF-8">
</head>
<html>
<body>
<div>
<div>M = 移至</div>
<div>L = 画线</div>
<div>H = 竖画线</div>
<div>V = 垂直画线</div>
<div>C = 曲线</div>
<div>S = 光滑的曲线</div>
<div>Q = 二次贝塞尔曲线</div>
<div>T = 光滑二次贝塞尔曲线</div>
<div>A = 椭圆的弧</div>
<div>Z = 关闭路径</div>
<b style="color: red;">注:以上所有命令均允许小写字母。大写表示绝对定位,小写表示相对定位。</b>
</div>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" height="600" width="450">
<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 d="M 175 200 l 150 0" stroke="green" stroke-width="3" fill="none" />
<path d="M 100 350 q 150 -300 300 0" stroke="blue" stroke-width="5" fill="none" />
<path d="M 100 350 q 150 300 300 0" stroke="pink" 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" />
<circle id="pointD" cx="250" cy="500" 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>
<text x="250" y="500" dY="30">D</text>
</g>
</svg>


<br><br><br><br>
<svg>

<defs>
<linearGradient id="grad1" x1="0%" y1="0%" x2="100%" y2="0%">
<stop offset="0%" style="stop-color:rgb(255,255,0);stop-opacity:1"/>
<stop offset="100%" style="stop-color:rgb(255,0,0);stop-opacity:1"/>
</linearGradient>
</defs>

<ellipse cx="200" cy="70" rx="85" ry="55" fill="url(#grad1)"/>
//在svg内添加文本,
<text fill="#ffffff" font-size="45" font-family="Verdana" x="150" y="86">
SVG
</text>
</svg>
<p>椭圆。rx="85" ry="55":椭圆宽高;cx="200" cy="70":椭圆的起始点位置。</p>
<p>linearGradient:渐变</p>
<em style="color: blue;">在svg标签内部不能添加与svg标签不相关的其他标签,否则不能svg标签没有效果</em>


</body>
</html>
posted on 2018-12-29 11:58  小虾米吖~  阅读(188)  评论(0编辑  收藏  举报