SVG Learning - 2
SVG 学习第二部分,包括<path>图形元素。简单罗列,英文为主。
References
SVG graphics elements
<path><line><rect><circle><line><polyline><polygon><image><use>
<path>
M & L
M x y: Move pen to (x,y)M x1,y1[ x2,y2[…]]: Move pen to (x1,y1), then (x2,y2), …M x1 y1 L x2 y2[ x3 y3[…]],M x1 y1 L x2,y2[ x3,y3[…]]: Draw linearly from (x1,y1) to (x2,y2), then (x3,y3), …
SVG Code
1 | <path stroke="black" d="M 100 100 L 200 200"/> |
Illustration

SVG Code
1 | <path d="M 100 100 L 200 200 100 150"/> |
Illustration

SVG Code
1 | <path d="M 50,100 150,200 50,150"/> |

z: Close path
SVG Code
1 | <path d="M 100,50 200,150 100,100" fill="none" stroke="black"/> |
fill-rule="even-odd"
SVG Code
1 | <path d="M 70,290 L 150,150 200,250 40,250 100,150 170,290"/> |


Combine multiple path segments
SVG Code
1 | <path fill="orange" |

Q: Quadratic Bézier curves
M x1 y1 Q x2,y2 x3,y3: Draw quadratically from (x1,y1), then (x2,y2), towards (x3,y3)
SVG Code
1 | <path d="M 100 200 Q 200,400 300,200" fill="none" stroke="blue" /> |
Illustration

SVG Code
1 | <path fill-rule="evenodd" |
Illustration

C: Cubic Bézier curves
M x1 y1 C xt1,yt1[ xt2,yt2[…]] x2,y2: Draw cubically from (x1,y1) to (x2,y2), with control points (xt1,yt1), (xt2,yt2), …




SVG Code
1 | <path stroke="black" stroke-width="3" fill="#eec1c2" |
Illustration

A: Elliptical arc
