Table of Contents

Class RectanglePolygon

Namespace
SixLabors.ImageSharp.Drawing
Assembly
SixLabors.ImageSharp.Drawing.dll

A closed rectangular path defined by four straight edges.

public sealed class RectanglePolygon : IPath, ISimplePath
Inheritance
RectanglePolygon
Implements
Inherited Members
Extension Methods

Constructors

RectanglePolygon(PointF, PointF)

Initializes a new instance of the RectanglePolygon class.

public RectanglePolygon(PointF topLeft, PointF bottomRight)

Parameters

topLeft PointF

The PointF which specifies the rectangle's top-left point in a two-dimensional plane.

bottomRight PointF

The PointF which specifies the rectangle's bottom-right point in a two-dimensional plane.

RectanglePolygon(PointF, SizeF)

Initializes a new instance of the RectanglePolygon class.

public RectanglePolygon(PointF point, SizeF size)

Parameters

point PointF

The PointF which specifies the rectangle's point in a two-dimensional plane.

size SizeF

The SizeF which specifies the rectangle's height and width.

RectanglePolygon(RectangleF)

Initializes a new instance of the RectanglePolygon class.

public RectanglePolygon(RectangleF rectangle)

Parameters

rectangle RectangleF

The rectangle.

RectanglePolygon(float, float, float, float)

Initializes a new instance of the RectanglePolygon class.

public RectanglePolygon(float x, float y, float width, float height)

Parameters

x float

The horizontal position of the rectangle.

y float

The vertical position of the rectangle.

width float

The width of the rectangle.

height float

The height of the rectangle.

Properties

Bottom

Gets the y-coordinate of the bottom edge.

public float Bottom { get; }

Property Value

float

Bounds

Gets the bounds enclosing the path.

public RectangleF Bounds { get; }

Property Value

RectangleF

Center

Gets the center point.

public PointF Center { get; }

Property Value

PointF

Height

Gets the height.

public float Height { get; }

Property Value

float

IsClosed

Gets a value indicating whether this instance is a closed path.

public bool IsClosed { get; }

Property Value

bool

Left

Gets the x-coordinate of the left edge.

public float Left { get; }

Property Value

float

Location

Gets the top-left location of the rectangle.

public PointF Location { get; }

Property Value

PointF

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

PathTypes

Points

Gets the points that make this up as a simple linear path.

public ReadOnlyMemory<PointF> Points { get; }

Property Value

ReadOnlyMemory<PointF>

Right

Gets the x-coordinate of the right edge.

public float Right { get; }

Property Value

float

Size

Gets the size.

public SizeF Size { get; }

Property Value

SizeF

Top

Gets the y-coordinate of the top edge.

public float Top { get; }

Property Value

float

Width

Gets the width.

public float Width { get; }

Property Value

float

X

Gets the x-coordinate of the top-left corner.

public float X { get; }

Property Value

float

Y

Gets the y-coordinate of the top-left corner.

public float Y { get; }

Property Value

float

Methods

AsClosedPath()

Returns this path with all figures closed.

public IPath AsClosedPath()

Returns

IPath

A new closed IPath.

ComputeArea(Vector2)

Calculates the non-negative path area after flattening curves at the supplied scale.

public float ComputeArea(Vector2 scale)

Parameters

scale Vector2

The 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 float ComputeLength(Vector2 scale)

Parameters

scale Vector2

The 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 bool Contains(PointF point, IntersectionRule intersectionRule, Vector2 scale)

Parameters

point PointF

The point to test.

intersectionRule IntersectionRule

The fill rule used for containment.

scale Vector2

The X/Y scale at which curves are flattened for the containment test.

Returns

bool

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

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 LinearGeometry ToLinearGeometry(Vector2 scale)

Parameters

scale Vector2

The X/Y scale at which curves are flattened.

Returns

LinearGeometry

The retained linear geometry.

Transform(Matrix4x4)

Transforms the path using the specified matrix.

public IPath Transform(Matrix4x4 matrix)

Parameters

matrix Matrix4x4

The 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 bool TryGetPathPointAtDistance(float distance, Vector2 scale, out PathPoint pathPoint)

Parameters

distance float

The distance along the path.

scale Vector2

The X/Y scale at which curves are flattened for distance measurement.

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(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 bool TryGetPathPointAtDistanceUnbounded(float distance, Vector2 scale, out PathPoint pathPoint)

Parameters

distance float

The distance along the path.

scale Vector2

The X/Y scale at which curves are flattened for distance measurement.

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(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 bool TryGetSegment(float startDistance, float stopDistance, bool startOnBeginFigure, Vector2 scale, out IPath path)

Parameters

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.

scale Vector2

The X/Y scale at which curves are flattened for segment extraction.

path 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.

Operators

explicit operator RectanglePolygon(Polygon)

Converts a polygon to a rectangle polygon from its bounds.

public static explicit operator RectanglePolygon(Polygon polygon)

Parameters

polygon Polygon

The polygon to convert.

Returns

RectanglePolygon

The rectangle polygon covering the source polygon's bounds.