PathData Class
The geometry of a ScenePath: a list of commands, as in SVG.
public sealed class PathDataProperties
| Name | Description |
|---|---|
| Commands | Gets the commands of the path. |
| IsEmpty | Gets a value that indicates whether the path has no commands. |
Commands
PathData.csIsEmpty
PathData.csMethods
| Name | Description |
|---|---|
| GetLength() | Gets the length of the path: the lengths of its subpaths, without the moves between them. |
| GetPointAtLength(double) | Gets the point at a distance along the path, and the direction of the path there, as SVG getPointAtLength. |
| GetVertices() | Gets the vertices of the path, where its markers are drawn (ScenePath.MarkerStart, ScenePath.MarkerMid, ScenePath.MarkerEnd), with the direction of the path there, as SVG computes them for orient="auto". |
| Reverse() | Returns the path drawn backwards: its subpaths in the reverse order, each from its end to its start, as SVG 2 reverses the path of a textPath whose side is right. |
| ToCubicCurves() | Returns the path with its quadratic curves and its arcs converted to cubic Bézier curves, for the formats that have no other curve, such as PDF and PostScript. The other commands are kept. |
| ToString() | Returns the path as the value of the d attribute of an SVG path. |
| Translate(double, double) | Returns the path moved by an offset. The radii and the rotations of the arcs do not change. |
GetLength()
PathData.csGetPointAtLength(double)
PathData.csGets the point at a distance along the path, and the direction of the path there, as SVG getPointAtLength.
Parameters
distancedouble- The distance from the start of the path. It is clamped to the path; a value that is not a number is 0.
Returns
PathPoint The point. At the end of a segment, the direction is the one of the next segment; at the end of the path, the one of its last segment. A path without length gives its first point, with a direction of 0.
Exceptions
InvalidOperationException- The path is empty.
GetVertices()
PathData.csGets the vertices of the path, where its markers are drawn (ScenePath.MarkerStart, ScenePath.MarkerMid, ScenePath.MarkerEnd), with the direction of the path there, as SVG computes them for orient="auto".
public IReadOnlyList<PathPoint> GetVertices()Returns
IReadOnlyList<PathPoint> One vertex per command: the end point of each command, and the start of its subpath for a PathCommandKind.Close command. A path whose first command is not a move starts with a vertex at the origin. The start marker is on the first vertex, the end marker on the last one, the middle marker on the others.
Remarks
The direction at a vertex is halfway between the directions of the segment that ends there and of the one that starts there, or the direction of the only one; the tangents of the curves and the arcs. A closed subpath joins its last segment and its first one at its start. A segment without length keeps the direction of the previous one.
Reverse()
PathData.csReturns the path drawn backwards: its subpaths in the reverse order, each from its end to its start, as SVG 2 reverses the path of a textPath whose side is right.
public PathData Reverse()Returns
PathData The reversed path, which covers the same points.
Remarks
Each subpath starts with a move to its last point, then follows its segments back: the control points of the curves are swapped, and the arcs turn the other way (their PathCommand.Sweep flag is inverted). A closed subpath starts at the end of its last segment and closes at the same point. A path that does not start with a move starts at the origin, and a segment that follows a PathCommandKind.Close command starts at the start of the closed subpath, as in SVG: the reversed path has explicit moves to these points. Reversing the reversed path gives the original geometry.
ToCubicCurves()
PathData.csReturns the path with its quadratic curves and its arcs converted to cubic Bézier curves, for the formats that have no other curve, such as PDF and PostScript. The other commands are kept.
public PathData ToCubicCurves()Returns
PathData The path, made of PathCommandKind.MoveTo, PathCommandKind.LineTo, PathCommandKind.CubicTo and PathCommandKind.Close commands.
Remarks
A quadratic curve becomes the cubic curve of the same shape. An arc is resolved as SVG resolves it (SVG 1.1, appendix F.6): a radius of 0 gives a line, radii too small for the end points are scaled up, and an arc that ends where it starts is omitted. It is approximated by one cubic curve per quarter of a turn at most.