Class PathExtensions
- Namespace
- SixLabors.ImageSharp.Drawing
- Assembly
- SixLabors.ImageSharp.Drawing.dll
Convenience methods that can be applied to shapes and paths.
public static class PathExtensions
- Inheritance
-
PathExtensions
- Inherited Members
Methods
ComputeArea(IPath)
Calculates the total area represented by the specified path.
public static float ComputeArea(this IPath path)
Parameters
pathIPathThe path for which to compute the area.
Returns
- float
The total path area, in square units.
ComputeArea(IPathCollection)
Calculates the total area of all paths in the specified collection.
public static float ComputeArea(this IPathCollection paths)
Parameters
pathsIPathCollectionA collection of paths for which to compute the combined area. Cannot be null.
Returns
- float
The total area, in square units, represented by all paths in the collection.
ComputeLength(IPath)
Calculates the path length after flattening curves at local-space precision.
public static float ComputeLength(this IPath path)
Parameters
pathIPathThe path to compute the length for.
Returns
- float
The path length.
Contains(IPath, PointF, IntersectionRule)
Returns whether the supplied point is inside the path.
public static bool Contains(this IPath path, PointF point, IntersectionRule intersectionRule)
Parameters
pathIPathThe path to test.
pointPointFThe point to test.
intersectionRuleIntersectionRuleThe fill rule used for containment.
Returns
Rotate(IPath, float)
Creates a path rotated by the specified radians around its center.
public static IPath Rotate(this IPath path, float radians)
Parameters
Returns
Rotate(IPathCollection, float)
Creates a path collection rotated by the specified radians around its center.
public static IPathCollection Rotate(this IPathCollection path, float radians)
Parameters
pathIPathCollectionThe path collection to rotate.
radiansfloatThe radians to rotate the paths.
Returns
- IPathCollection
An IPathCollection with a rotate transform applied.
RotateDegree(IPath, float)
Creates a path rotated by the specified degrees around its center.
public static IPath RotateDegree(this IPath shape, float degree)
Parameters
Returns
RotateDegree(IPathCollection, float)
Creates a path collection rotated by the specified degrees around its center.
public static IPathCollection RotateDegree(this IPathCollection shape, float degree)
Parameters
shapeIPathCollectionThe path collection to rotate.
degreefloatThe degree to rotate the paths.
Returns
- IPathCollection
An IPathCollection with a rotate transform applied.
Scale(IPath, float)
Creates a path scaled by the supplied amount around its center.
public static IPath Scale(this IPath path, float scale)
Parameters
Returns
Scale(IPath, float, float)
Creates a path scaled by the supplied amounts around its center.
public static IPath Scale(this IPath path, float scaleX, float scaleY)
Parameters
pathIPathThe path to scale.
scaleXfloatThe amount to scale along the X axis.
scaleYfloatThe amount to scale along the Y axis.
Returns
Scale(IPathCollection, float)
Creates a path collection scaled by the supplied amount around its center.
public static IPathCollection Scale(this IPathCollection path, float scale)
Parameters
pathIPathCollectionThe path collection to scale.
scalefloatThe amount to scale along both the x and y axis.
Returns
- IPathCollection
An IPathCollection with a scale transform applied.
Scale(IPathCollection, float, float)
Creates a path collection scaled by the supplied amounts around its center.
public static IPathCollection Scale(this IPathCollection path, float scaleX, float scaleY)
Parameters
pathIPathCollectionThe path collection to scale.
scaleXfloatThe amount to scale along the X axis.
scaleYfloatThe amount to scale along the Y axis.
Returns
- IPathCollection
An IPathCollection with a scale transform applied.
Translate(IPath, PointF)
Creates a path translated by the supplied position.
public static IPath Translate(this IPath path, PointF position)
Parameters
Returns
Translate(IPath, float, float)
Creates a path translated by the supplied position.
public static IPath Translate(this IPath path, float x, float y)
Parameters
pathIPathThe path to translate.
xfloatThe amount to translate along the X axis.
yfloatThe amount to translate along the Y axis.
Returns
Translate(IPathCollection, PointF)
Creates a path collection translated by the supplied position.
public static IPathCollection Translate(this IPathCollection path, PointF position)
Parameters
pathIPathCollectionThe path collection to translate.
positionPointFThe translation position.
Returns
- IPathCollection
An IPathCollection with a translate transform applied.
Translate(IPathCollection, float, float)
Creates a path collection translated by the supplied position.
public static IPathCollection Translate(this IPathCollection path, float x, float y)
Parameters
pathIPathCollectionThe path collection to translate.
xfloatThe amount to translate along the X axis.
yfloatThe amount to translate along the Y axis.
Returns
- IPathCollection
An IPathCollection with a translate transform applied.
TryGetPathPointAtDistance(IPath, float, out PathPoint)
Gets path information at the specified distance along the path.
public static bool TryGetPathPointAtDistance(this IPath path, float distance, out PathPoint pathPoint)
Parameters
pathIPathThe path to measure.
distancefloatThe distance along the path.
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(IPath, float, 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 static bool TryGetPathPointAtDistanceUnbounded(this IPath path, float distance, out PathPoint pathPoint)
Parameters
pathIPathThe path to measure.
distancefloatThe distance along the path.
pathPointPathPointWhen this method returns, contains the path information at
distanceif the path is measurable; otherwise, the default value.
Returns
Remarks
Unlike TryGetPathPointAtDistance(IPath, float, 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(IPath, float, float, bool, out IPath)
Creates a path segment between two distances along the path.
public static bool TryGetSegment(this IPath path, float startDistance, float stopDistance, bool startOnBeginFigure, out IPath segment)
Parameters
pathIPathThe path to measure.
startDistancefloatThe segment start distance.
stopDistancefloatThe segment stop distance.
startOnBeginFigureboolWhether the returned segment starts a new figure at the first segment point.
segmentIPathWhen this method returns, contains the segment path if one was created; otherwise, an empty path.