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 enclosed by the specified path.
public static float ComputeArea(this IPath path)
Parameters
pathIPathThe path for which to compute the enclosed area. Must contain at least one subpath with three or more points to contribute to the area calculation.
Returns
- float
The total area, in square units, enclosed by all subpaths of the path. Returns 0 if the path does not contain any subpaths with at least three points.
Remarks
This method sums the areas of all subpaths within the path. Subpaths with fewer than three points are ignored, as they do not form a closed region. The result is always non-negative, regardless of the winding direction of the subpaths.
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, enclosed by all paths in the collection.
ComputeLength(IPath)
Calculates the approximate length of the path as though each segment were unrolled into a line.
public static float ComputeLength(this IPath path)
Parameters
pathIPathThe path to compute the length for.
Returns
- float
The float representing the unrolled length. For closed paths, the length includes an implicit closing segment.
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 rotated by the specified radians around its center.
public static IPathCollection Rotate(this IPathCollection path, float radians)
Parameters
pathIPathCollectionThe path to rotate.
radiansfloatThe radians to rotate the path.
Returns
- IPathCollection
A IPath 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 rotated by the specified degrees around its center.
public static IPathCollection RotateDegree(this IPathCollection shape, float degree)
Parameters
shapeIPathCollectionThe path to rotate.
degreefloatThe degree to rotate the path.
Returns
- IPathCollection
A IPath with a rotate transform applied.
Scale(IPath, float)
Creates a path translated by the supplied position
public static IPath Scale(this IPath path, float scale)
Parameters
Returns
Scale(IPath, float, float)
Creates a path translated by the supplied position
public static IPath Scale(this IPath path, float scaleX, float scaleY)
Parameters
pathIPathThe path to translate.
scaleXfloatThe amount to scale along the X axis.
scaleYfloatThe amount to scale along the Y axis.
Returns
Scale(IPathCollection, float)
Creates a path translated by the supplied position
public static IPathCollection Scale(this IPathCollection path, float scale)
Parameters
pathIPathCollectionThe path to translate.
scalefloatThe amount to scale along both the x and y axis.
Returns
- IPathCollection
A IPath with a translate transform applied.
Scale(IPathCollection, float, float)
Creates a path translated by the supplied position
public static IPathCollection Scale(this IPathCollection path, float scaleX, float scaleY)
Parameters
pathIPathCollectionThe path to translate.
scaleXfloatThe amount to scale along the X axis.
scaleYfloatThe amount to scale along the Y axis.
Returns
- IPathCollection
A IPath with a translate 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 translated by the supplied position
public static IPathCollection Translate(this IPathCollection path, PointF position)
Parameters
pathIPathCollectionThe path to translate.
positionPointFThe translation position.
Returns
- IPathCollection
A IPath with a translate transform applied.
Translate(IPathCollection, float, float)
Creates a path translated by the supplied position
public static IPathCollection Translate(this IPathCollection path, float x, float y)
Parameters
pathIPathCollectionThe path to translate.
xfloatThe amount to translate along the X axis.
yfloatThe amount to translate along the Y axis.
Returns
- IPathCollection
A IPath with a translate transform applied.