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 represented by the specified path.

public static float ComputeArea(this IPath path)

Parameters

path IPath

The 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

paths IPathCollection

A 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

path IPath

The 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

path IPath

The path to test.

point PointF

The point to test.

intersectionRule IntersectionRule

The fill rule used for containment.

Returns

bool

true when the point is inside or on the path boundary.

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

An IPath with a rotate transform applied.

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

path IPathCollection

The path collection to rotate.

radians float

The 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

shape IPath

The path to rotate.

degree float

The degree to rotate the path.

Returns

IPath

An IPath with a rotate transform applied.

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

shape IPathCollection

The path collection to rotate.

degree float

The 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

path IPath

The path to scale.

scale float

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

Returns

IPath

An IPath with a scale transform applied.

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

path IPath

The path to scale.

scaleX float

The amount to scale along the X axis.

scaleY float

The amount to scale along the Y axis.

Returns

IPath

An IPath with a scale transform applied.

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

path IPathCollection

The path collection to scale.

scale float

The 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

path IPathCollection

The path collection to scale.

scaleX float

The amount to scale along the X axis.

scaleY float

The 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

path IPath

The path to translate.

position PointF

The translation position.

Returns

IPath

An 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

An IPath with a translate transform applied.

Translate(IPathCollection, PointF)

Creates a path collection translated by the supplied position.

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

Parameters

path IPathCollection

The path collection to translate.

position PointF

The 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

path IPathCollection

The path collection to translate.

x float

The amount to translate along the X axis.

y float

The 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

path IPath

The path to measure.

distance float

The distance along the path.

pathPoint PathPoint

When this method returns, contains the path information at distance if the distance resolves to a point on the path; otherwise, the default value.

Returns

bool

true if distance resolves to a point on the path; otherwise, false.

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

path IPath

The path to measure.

distance float

The distance along the path.

pathPoint PathPoint

When this method returns, contains the path information at distance if the path is measurable; otherwise, the default value.

Returns

bool

true if the point could be resolved; otherwise, false.

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

path IPath

The path to measure.

startDistance float

The segment start distance.

stopDistance float

The segment stop distance.

startOnBeginFigure bool

Whether the returned segment starts a new figure at the first segment point.

segment IPath

When this method returns, contains the segment path if one was created; otherwise, an empty path.

Returns

bool

true when a segment path was created.