Draw Path

November 22, 2024 · View on GitHub

A few svg path commands

(in the following rel. means relative and abs. means absolute.

LetterMeaningSampleParamsNote
MMove toM 10 30(X,Y)+set current point to abs. (10,30)
mmove deltam 1 2(dx,dy)+change current point by rel. (1,2)
LLine toL 10 20(dx,dy)+line from current point, to rel. (10,20)
L 10 20 30 40(dx,dy)+line from current point to rel. (10,20) and line from there to rel. (30,40)
HHoriz Line toH 10x+horiz line from current point to abs. x of 10
hHoriz Line deltah 10dx+horiz line from current point to rel. x of x + 10
h -10dx+horiz line from current point to rel. x of x - 10
VVert Line toV 10y+vertical from current point to y of 10
vVert Line deltav 10dy+vertical from current point to rel. y of y + 10
v -10dy+vertical from current point to rel. y of y - 10
CCubic BézierC 30,90 25,10 50,10(x1,y1, x2,y2, x,y)+from current point to end point x,y with control points at x1,y1 and x2,y2
C 30,90 25,10 50,10 10,25 90,30 10,50(x1,y1, x2,y2, x,y)+subsequent triplets of pairs continue the curve
crelative Cubic BézierC 30,90 25,10 50,10(dx1,dy1, dx2,dy2, dx,dy)+from current point to relative end point x,y with relative control points at dx1,dy1 and dx2,dy2
CCubic BézierC 30,90 25,10 50,10(x1,y1, x2,y2, x,y)+from current point to end point x,y with control points at x1,y1 and x2,y2
C 30,90 25,10 50,10 10,25 90,30 10,50(x1,y1, x2,y2, x,y)+subsequent triplets of pairs continue the curve
SSmooth Cubic BézierS 20,50 80,110(x2, y2, x, y)+from current point to end point x,y with end control point x2, y2 and start control point of previous control point or current point if previous curve wasn't a cubic bézier
QQuadratic Bézier
qRelative Quad Béz
TSmooth Quad Béz
tRealitve smooth quad Béz
AArc curve
aRelative Arc curve
ZClose path
<svg width="190" height="210" xmlns="http://www.w3.org/2000/svg">
  <path d="M 10 10 20 20" stroke="red" fill="transparent"/>
  <path d="M 40 20 50 10" stroke="red" fill="transparent"/>
  <path d="M 10 10 C 20 20, 40 20, 50 10" stroke="black" fill="transparent"/>
	  <path d="M 70 10 70 20" stroke="red" fill="transparent"/>
	  <path d="M 110 20 110 10" stroke="red" fill="transparent"/>
	  <path d="M 70 10 C 70 20, 110 20, 110 10" stroke="black" fill="transparent"/>
		  <path d="M 130 10 120 20" stroke="red" fill="transparent"/>
		  <path d="M 180 20 170 10" stroke="red" fill="transparent"/>
		  <path d="M 130 10 C 120 20, 180 20, 170 10" stroke="black" fill="transparent"/>
  <path d="M 10 60 20 80" stroke="red" fill="transparent"/>
  <path d="M 40 80 50 60" stroke="red" fill="transparent"/>
  <path d="M 10 60 C 20 80, 40 80, 50 60" stroke="black" fill="transparent"/>
	  <path d="M 70 60 70 80" stroke="red" fill="transparent"/>
	  <path d="M 110 80 110 60" stroke="red" fill="transparent"/>
	  <path d="M 70 60 C 70 80, 110 80, 110 60" stroke="black" fill="transparent"/>
		  <path d="M 130 60 120 80" stroke="red" fill="transparent"/>
		  <path d="M 180 80 170 60" stroke="red" fill="transparent"/>
		  <path d="M 130 60 C 120 80, 180 80, 170 60" stroke="black" fill="transparent"/>
  <path d="M 10 110 20 140" stroke="red" fill="transparent"/>
  <path d="M 40 140 50 110" stroke="red" fill="transparent"/>
  <path d="M 10 110 C 20 140, 40 140, 50 110" stroke="black" fill="transparent"/>
	  <path d="M 70 110 70 140" stroke="red" fill="transparent"/>
	  <path d="M 110 140 110 110" stroke="red" fill="transparent"/>
	  <path d="M 70 110 C 70 140, 110 140, 110 110" stroke="black" fill="transparent"/>
		  <path d="M 130 110 120 140" stroke="red" fill="transparent"/>
		  <path d="M 180 140 170 110" stroke="red" fill="transparent"/>
		  <path d="M 130 110 C 120 140, 180 140, 170 110" stroke="black" fill="transparent"/>
  <!-- recreate that first line... but using relative coords, l and c -->
  <path d="M 10 160 l 10 10" stroke="pink" fill="transparent"/>
  <path d="M 50 160 l -10 10" stroke="pink" fill="transparent"/>
  <path d="M 10 160 c 10 10, 30 10, 40 0" stroke="blue" fill="transparent"/>
</svg>

See also