Class Path
- Namespace
- SixLabors.ImageSharp.Drawing
- Assembly
- SixLabors.ImageSharp.Drawing.dll
An aggregate of ILineSegments making a single logical path.
public class Path : IPath, ISimplePath
- Inheritance
-
Path
- Implements
- Derived
- Inherited Members
- Extension Methods
Constructors
Path(params ILineSegment[])
Initializes a new instance of the Path class.
public Path(params ILineSegment[] segments)
Parameters
segmentsILineSegment[]The segments.
Path(Path)
Initializes a new instance of the Path class.
public Path(Path path)
Parameters
pathPathThe path.
Path(PointF[])
Initializes a new instance of the Path class.
public Path(PointF[] points)
Parameters
pointsPointF[]The collection of points; processed as a series of linear line segments.
Path(IEnumerable<ILineSegment>)
Initializes a new instance of the Path class.
public Path(IEnumerable<ILineSegment> segments)
Parameters
segmentsIEnumerable<ILineSegment>The segments.
Properties
Bounds
Gets the bounds enclosing the path.
public RectangleF Bounds { get; }
Property Value
Empty
Gets the default empty path.
public static IPath Empty { get; }
Property Value
IsClosed
Gets a value indicating whether this instance is a closed path.
public virtual bool IsClosed { get; }
Property Value
LineSegments
Gets readonly collection of line segments.
public IReadOnlyList<ILineSegment> LineSegments { get; }
Property Value
PathType
Gets a value indicating whether this instance is closed, open or a composite path with a mixture of open and closed figures.
public PathTypes PathType { get; }
Property Value
Points
Gets the points that make this up as a simple linear path.
public ReadOnlyMemory<PointF> Points { get; }
Property Value
Methods
AsClosedPath()
Returns this path with all figures closed.
public IPath AsClosedPath()
Returns
ComputeArea(Vector2)
Calculates the non-negative path area after flattening curves at the supplied scale.
public virtual float ComputeArea(Vector2 scale)
Parameters
scaleVector2The X/Y scale at which curves are flattened for area measurement.
Returns
- float
The path area.
ComputeLength(Vector2)
Calculates the path length after flattening curves at the supplied scale.
public virtual float ComputeLength(Vector2 scale)
Parameters
scaleVector2The X/Y scale at which curves are flattened for length measurement.
Returns
- float
The path length.
Contains(PointF, IntersectionRule, Vector2)
Returns whether the supplied point is inside the path.
public virtual bool Contains(PointF point, IntersectionRule intersectionRule, Vector2 scale)
Parameters
pointPointFThe point to test.
intersectionRuleIntersectionRuleThe fill rule used for containment.
scaleVector2The X/Y scale at which curves are flattened for the containment test.
Returns
Flatten()
Converts the IPath into a simple linear path.
public IEnumerable<ISimplePath> Flatten()
Returns
- IEnumerable<ISimplePath>
Returns the current IPath as simple linear path.
ToLinearGeometry(Vector2)
Converts this path into a retained LinearGeometry, flattening curves at the precision of
the supplied device-space scale.
public virtual LinearGeometry ToLinearGeometry(Vector2 scale)
Parameters
scaleVector2The X/Y scale at which curves are flattened.
Returns
- LinearGeometry
The retained linear geometry.
Transform(Matrix4x4)
Transforms the path using the specified matrix.
public virtual IPath Transform(Matrix4x4 matrix)
Parameters
matrixMatrix4x4The matrix.
Returns
- IPath
A new path with the matrix applied to it.
TryGetPathPointAtDistance(float, Vector2, out PathPoint)
Gets path information at the specified distance along the path.
public virtual bool TryGetPathPointAtDistance(float distance, Vector2 scale, out PathPoint pathPoint)
Parameters
distancefloatThe distance along the path.
scaleVector2The X/Y scale at which curves are flattened for distance measurement.
pathPointPathPointWhen this method returns, contains the path information at
distanceif the distance resolves to a point on the path; otherwise, the default value.
Returns
TryGetPathPointAtDistanceUnbounded(float, Vector2, out PathPoint)
Gets path information at the specified distance along the path, extrapolating along the boundary tangents when the distance falls before the start or beyond the end of an open path.
public virtual bool TryGetPathPointAtDistanceUnbounded(float distance, Vector2 scale, out PathPoint pathPoint)
Parameters
distancefloatThe distance along the path.
scaleVector2The X/Y scale at which curves are flattened for distance measurement.
pathPointPathPointWhen this method returns, contains the path information at
distanceif the path is measurable; otherwise, the default value.
Returns
Remarks
Unlike TryGetPathPointAtDistance(float, Vector2, out PathPoint), out-of-range distances resolve to a point on the virtual straight-line continuation of the path's first or last segment. Text layout uses this to place aligned glyphs that overflow their layout path. The method returns false only when the distance is not a finite number or the path has no measurable length.
TryGetSegment(float, float, bool, Vector2, out IPath)
Creates a path segment between two distances along the path.
public virtual bool TryGetSegment(float startDistance, float stopDistance, bool startOnBeginFigure, Vector2 scale, out IPath path)
Parameters
startDistancefloatThe segment start distance.
stopDistancefloatThe segment stop distance.
startOnBeginFigureboolWhether the returned segment starts a new figure at the first segment point.
scaleVector2The X/Y scale at which curves are flattened for segment extraction.
pathIPathWhen this method returns, contains the segment path if one was created; otherwise, an empty path.
Returns
TryParseSvgPath(ReadOnlySpan<char>, out IPath?)
Converts an SVG path string into an IPath.
public static bool TryParseSvgPath(ReadOnlySpan<char> svgPath, out IPath? value)
Parameters
svgPathReadOnlySpan<char>The string containing the SVG path data.
valueIPathWhen this method returns, contains the logic path converted from the given SVG path string; otherwise, null. This parameter is passed uninitialized.
Returns
TryParseSvgPath(string, out IPath?)
Converts an SVG path string into an IPath.
public static bool TryParseSvgPath(string svgPath, out IPath? value)
Parameters
svgPathstringThe string containing the SVG path data.
valueIPathWhen this method returns, contains the logic path converted from the given SVG path string; otherwise, null. This parameter is passed uninitialized.