Donner
C++20 SVG rendering library
Loading...
Searching...
No Matches
Data formats

SVG data is specified using many different micro-syntaxes such as Path data syntax and Polyline/polygon points list.

Donner implements a collection of parsers for these micro-syntaxes:

Additionally, Donner includes a standalone CSS parser, donner::css::CSS.

Path data syntax

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::Builder::moveTo (x y)+ Start a new sub-path at (x, y). If additional coordinates follow, they are treated as PathSpline::Builder::lineTo.
Z PathSpline::Builder::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::Builder::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::Builder::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::Builder::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.
See also
https://www.w3.org/TR/SVG2/paths.html#PathData

Polyline/polygon points list

The points attribute is used to specify line paths for "<polyline>" and "<polygon>".It specifies a list of numbers separated by whitespace or commas, for example: "10,20 30,40". Numbers are the same as the CSS number type: "... an integer, or zero or more decimal digits followed by a dot (.) followed by one or more decimal digits and optionally an exponent composed of "e" or "E" and an integer".To parse a points list, use PointsListParser::Parse.