|
|
Donner
C++20 SVG rendering library
|
The d attribute of a "<path>" element defines the shape of the path. It is a sequence of commands, each of which is a single letter followed by a sequence of numbers, such as M 40 50. To parse the d attribute, use PathParser::Parse.
If the letter is uppercase, the coordinates that follow are absolute coordinates. If the letter is lowercase, the coordinates are relative to the current point.
| Command | Function | Parameters | Description |
|---|---|---|---|
| M | PathSpline::moveTo | (x y)+ | Start a new sub-path at (x, y). If additional coordinates follow, they are treated as PathSpline::Builder::lineTo. |
| Z | PathSpline::closePath | Close the current sub-path by drawing a line from the current point to the starting point of the sub-path. | |
| Line commands | |||
| L | PathSpline::lineTo | (x y)+ | Draw a line from the current point to (x, y). |
| H | Horizontal line to | x+ | Draw a horizontal line from the current point to (x, currentY). |
| V | Vertical line to | y+ | Draw a vertical line from the current point to (currentX, y). |
| Cubic Bezier curve commands | |||
| C | PathSpline::curveTo | (x1 y1 x2 y2 x y)+ | Draw a cubic Bezier curve from the current point to (x, y), using (x1, y1) and (x2, y2) as the control points. |
| S | Smooth curve to | (x2 y2 x y)+ | Draw a cubic Bezier curve from the current point to (x, y), using a reflection of the previous command's control point and (x2, y2) as the control points, creating a smooth curve. |
| Quadratic Bezier curve commands | |||
| Q | Quadratic curve to | (x1 y1 x y)+ | Draw a quadratic Bezier curve from the current point to (x, y), using (x1, y1) as the control point. |
| T | Smooth quadratic curve to | (x y)+ | Draw a quadratic Bezier curve from the current point to (x, y), using a reflection of the previous command's control point as the control point, creating a smooth curve. |
| Elliptical arc commands | |||
| A | PathSpline::arcTo | (rx ry x-axis-rotation large-arc-flag sweep-flag x y)+ | Draw an elliptical arc from the current point to (x, y), using (rx, ry) as the radii of the ellipse, and x-axis-rotation as the rotation of the ellipse. The large-arc-flag and sweep-flag parameters control the size and orientation of the arc. |