NaN
Challenge
And that's all I have to say about SVG paths! To summarize, SVG paths are constructed with a series of path commands, each of which is followed by a series of coordinates. Path commands are grouped into three categories:
- Move commands, which move the path's cursor to a new location without drawing anything;
- Line commands, which draw straight lines from the cursor's current position to a new location, and;
- Curve commands, which draw various types of curves starting from the cursor's current position.
Animations
One thing I didn't touch on in this guide is how to animate paths. I initially had animations in the first draft of the guide, but as I started writing it, I realized there was a lot to cover.
In the end, I decided to split off animations into a course called Interactive SVG Animations. If you enjoyed the teaching style of this guide, consider checking it out!
Challenges
The rest of this guide will be a leetcode-esque series of challenges - tracing over eight beautiful icons courtesy of Iconist's Central icon system. Massive kudos to them for allowing me to use their icons in this guide!
Note: While these icons were originally designed by Iconist's team, I've re-traced them to make them simpler to hand-code. As a result, they may not look 1-1 with the original!
Cursors & Lines
M x yMoves the cursor to the position (x, y).
L x yDraws a line from the current position to (x, y).
H xDraws a horizontal line from the current position to x.
V yDraws a vertical line from the current position to y.
ZDraws a line from the current position to the start position.
Curves
C x1 y1, x2 y2, x yDraws a cubic bezier curve from the current position to (x, y), using (x1, y1) and (x2, y2) as control points.
S x2 y2, x yDraws a cubic bezier curve from the current position to (x, y), using the previous control point's reflection and (x2, y2) as control points.
Q x1 y1, x yDraws a quadratic bezier curve from the current position to (x, y), using (x1, y1) as a control point.
T x yDraws a quadratic bezier curve from the current position to (x, y), using the previous control point's reflection as a control point.
A rx ry x-axis-rotation large-arc sweep x yDraws an elliptical arc from the current position to (x, y).
Cursors & Lines
M x yMoves the cursor to the position (x, y).
L x yDraws a line from the current position to (x, y).
H xDraws a horizontal line from the current position to x.
V yDraws a vertical line from the current position to y.
ZDraws a line from the current position to the start position.
Curves
C x1 y1, x2 y2, x yDraws a cubic bezier curve from the current position to (x, y), using (x1, y1) and (x2, y2) as control points.
S x2 y2, x yDraws a cubic bezier curve from the current position to (x, y), using the previous control point's reflection and (x2, y2) as control points.
Q x1 y1, x yDraws a quadratic bezier curve from the current position to (x, y), using (x1, y1) as a control point.
T x yDraws a quadratic bezier curve from the current position to (x, y), using the previous control point's reflection as a control point.
A rx ry x-axis-rotation large-arc sweep x yDraws an elliptical arc from the current position to (x, y).
Cursors & Lines
M x yMoves the cursor to the position (x, y).
L x yDraws a line from the current position to (x, y).
H xDraws a horizontal line from the current position to x.
V yDraws a vertical line from the current position to y.
ZDraws a line from the current position to the start position.
Curves
C x1 y1, x2 y2, x yDraws a cubic bezier curve from the current position to (x, y), using (x1, y1) and (x2, y2) as control points.
S x2 y2, x yDraws a cubic bezier curve from the current position to (x, y), using the previous control point's reflection and (x2, y2) as control points.
Q x1 y1, x yDraws a quadratic bezier curve from the current position to (x, y), using (x1, y1) as a control point.
T x yDraws a quadratic bezier curve from the current position to (x, y), using the previous control point's reflection as a control point.
A rx ry x-axis-rotation large-arc sweep x yDraws an elliptical arc from the current position to (x, y).
Cursors & Lines
M x yMoves the cursor to the position (x, y).
L x yDraws a line from the current position to (x, y).
H xDraws a horizontal line from the current position to x.
V yDraws a vertical line from the current position to y.
ZDraws a line from the current position to the start position.
Curves
C x1 y1, x2 y2, x yDraws a cubic bezier curve from the current position to (x, y), using (x1, y1) and (x2, y2) as control points.
S x2 y2, x yDraws a cubic bezier curve from the current position to (x, y), using the previous control point's reflection and (x2, y2) as control points.
Q x1 y1, x yDraws a quadratic bezier curve from the current position to (x, y), using (x1, y1) as a control point.
T x yDraws a quadratic bezier curve from the current position to (x, y), using the previous control point's reflection as a control point.
A rx ry x-axis-rotation large-arc sweep x yDraws an elliptical arc from the current position to (x, y).
Cursors & Lines
M x yMoves the cursor to the position (x, y).
L x yDraws a line from the current position to (x, y).
H xDraws a horizontal line from the current position to x.
V yDraws a vertical line from the current position to y.
ZDraws a line from the current position to the start position.
Curves
C x1 y1, x2 y2, x yDraws a cubic bezier curve from the current position to (x, y), using (x1, y1) and (x2, y2) as control points.
S x2 y2, x yDraws a cubic bezier curve from the current position to (x, y), using the previous control point's reflection and (x2, y2) as control points.
Q x1 y1, x yDraws a quadratic bezier curve from the current position to (x, y), using (x1, y1) as a control point.
T x yDraws a quadratic bezier curve from the current position to (x, y), using the previous control point's reflection as a control point.
A rx ry x-axis-rotation large-arc sweep x yDraws an elliptical arc from the current position to (x, y).
Cursors & Lines
M x yMoves the cursor to the position (x, y).
L x yDraws a line from the current position to (x, y).
H xDraws a horizontal line from the current position to x.
V yDraws a vertical line from the current position to y.
ZDraws a line from the current position to the start position.
Curves
C x1 y1, x2 y2, x yDraws a cubic bezier curve from the current position to (x, y), using (x1, y1) and (x2, y2) as control points.
S x2 y2, x yDraws a cubic bezier curve from the current position to (x, y), using the previous control point's reflection and (x2, y2) as control points.
Q x1 y1, x yDraws a quadratic bezier curve from the current position to (x, y), using (x1, y1) as a control point.
T x yDraws a quadratic bezier curve from the current position to (x, y), using the previous control point's reflection as a control point.
A rx ry x-axis-rotation large-arc sweep x yDraws an elliptical arc from the current position to (x, y).
Cursors & Lines
M x yMoves the cursor to the position (x, y).
L x yDraws a line from the current position to (x, y).
H xDraws a horizontal line from the current position to x.
V yDraws a vertical line from the current position to y.
ZDraws a line from the current position to the start position.
Curves
C x1 y1, x2 y2, x yDraws a cubic bezier curve from the current position to (x, y), using (x1, y1) and (x2, y2) as control points.
S x2 y2, x yDraws a cubic bezier curve from the current position to (x, y), using the previous control point's reflection and (x2, y2) as control points.
Q x1 y1, x yDraws a quadratic bezier curve from the current position to (x, y), using (x1, y1) as a control point.
T x yDraws a quadratic bezier curve from the current position to (x, y), using the previous control point's reflection as a control point.
A rx ry x-axis-rotation large-arc sweep x yDraws an elliptical arc from the current position to (x, y).
Cursors & Lines
M x yMoves the cursor to the position (x, y).
L x yDraws a line from the current position to (x, y).
H xDraws a horizontal line from the current position to x.
V yDraws a vertical line from the current position to y.
ZDraws a line from the current position to the start position.
Curves
C x1 y1, x2 y2, x yDraws a cubic bezier curve from the current position to (x, y), using (x1, y1) and (x2, y2) as control points.
S x2 y2, x yDraws a cubic bezier curve from the current position to (x, y), using the previous control point's reflection and (x2, y2) as control points.
Q x1 y1, x yDraws a quadratic bezier curve from the current position to (x, y), using (x1, y1) as a control point.
T x yDraws a quadratic bezier curve from the current position to (x, y), using the previous control point's reflection as a control point.
A rx ry x-axis-rotation large-arc sweep x yDraws an elliptical arc from the current position to (x, y).