Table of Contents

Class Polygon

Namespace
SixLabors.PolygonClipper
Assembly
SixLabors.PolygonClipper.dll

Represents a complex polygon.

public sealed class Polygon : IReadOnlyCollection<Contour>, IEnumerable<Contour>, IEnumerable
Inheritance
Polygon
Implements
Inherited Members

Constructors

Polygon()

Initializes a new instance of the Polygon class.

public Polygon()

Polygon(int)

Initializes a new instance of the Polygon class with a contour capacity.

public Polygon(int capacity)

Parameters

capacity int

The initial contour capacity.

Properties

Count

Gets the number of contours in the polygon.

public int Count { get; }

Property Value

int

this[int]

Gets the contour at the specified index.

public Contour this[int index] { get; }

Parameters

index int

The index of the contour.

Property Value

Contour

The Contour at the given index.

VertexCount

Gets the total number of vertices across all contours in the polygon.

public int VertexCount { get; }

Property Value

int

The total vertex count.

Methods

Add(Contour)

Adds a contour to the end of the contour collection.

public void Add(Contour contour)

Parameters

contour Contour

The contour to add.

Clear()

Clears all contours from the polygon.

public void Clear()

DeepClone()

Creates a deep copy of this polygon and all of its contours.

public Polygon DeepClone()

Returns

Polygon

A detached polygon copy.

GetBoundingBox()

Gets the bounding box.

public Box2 GetBoundingBox()

Returns

Box2

The Box2.

GetEnumerator()

Returns an enumerator that iterates through the collection.

public IEnumerator<Contour> GetEnumerator()

Returns

IEnumerator<Contour>

An enumerator that can be used to iterate through the collection.

GetLastContour()

Gets the last contour in the polygon.

public Contour GetLastContour()

Returns

Contour

The last Contour in the collection.

Join(Polygon)

Joins another polygon to this instance.

public void Join(Polygon polygon)

Parameters

polygon Polygon

The polygon to join.

ToDebugString()

Creates a string useful for debugging.

public string ToDebugString()

Returns

string

The string.

Translate(double, double)

Translates the polygon by the specified x and y values.

public void Translate(double x, double y)

Parameters

x double

The x-coordinate offset.

y double

The y-coordinate offset.