Table of Contents

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

path IPath

The 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

paths IPathCollection

A 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

path IPath

The 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

path IPath

The path to rotate.

radians float

The radians to rotate the path.

Returns

IPath

A IPath with a rotate transform applied.

Rotate(IPathCollection, float)

Creates a path rotated by the specified radians around its center.

public static IPathCollection Rotate(this IPathCollection path, float radians)

Parameters

path IPathCollection

The path to rotate.

radians float

The 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

shape IPath

The path to rotate.

degree float

The degree to rotate the path.

Returns

IPath

A IPath with a rotate transform applied.

RotateDegree(IPathCollection, float)

Creates a path rotated by the specified degrees around its center.

public static IPathCollection RotateDegree(this IPathCollection shape, float degree)

Parameters

shape IPathCollection

The path to rotate.

degree float

The 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

path IPath

The path to translate.

scale float

The amount to scale along both the x and y axis.

Returns

IPath

A IPath with a translate transform applied.

Scale(IPath, float, float)

Creates a path translated by the supplied position

public static IPath Scale(this IPath path, float scaleX, float scaleY)

Parameters

path IPath

The path to translate.

scaleX float

The amount to scale along the X axis.

scaleY float

The amount to scale along the Y axis.

Returns

IPath

A IPath with a translate transform applied.

Scale(IPathCollection, float)

Creates a path translated by the supplied position

public static IPathCollection Scale(this IPathCollection path, float scale)

Parameters

path IPathCollection

The path to translate.

scale float

The 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

path IPathCollection

The path to translate.

scaleX float

The amount to scale along the X axis.

scaleY float

The 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

path IPath

The path to translate.

position PointF

The translation position.

Returns

IPath

A IPath with a translate transform applied.

Translate(IPath, float, float)

Creates a path translated by the supplied position

public static IPath Translate(this IPath path, float x, float y)

Parameters

path IPath

The path to translate.

x float

The amount to translate along the X axis.

y float

The amount to translate along the Y axis.

Returns

IPath

A IPath with a translate transform applied.

Translate(IPathCollection, PointF)

Creates a path translated by the supplied position

public static IPathCollection Translate(this IPathCollection path, PointF position)

Parameters

path IPathCollection

The path to translate.

position PointF

The 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

path IPathCollection

The path to translate.

x float

The amount to translate along the X axis.

y float

The amount to translate along the Y axis.

Returns

IPathCollection

A IPath with a translate transform applied.