Class Contour
- Namespace
- SixLabors.PolygonClipper
- Assembly
- SixLabors.PolygonClipper.dll
Represents a single polygon ring (outer contour or hole).
public sealed class Contour : IReadOnlyCollection<Vertex>, IEnumerable<Vertex>, IEnumerable
- Inheritance
-
Contour
- Implements
- Inherited Members
Remarks
A contour is treated as implicitly closed: an edge is always considered between the last vertex and the first vertex. A duplicated terminal closing vertex is optional on input but not required.
Constructors
Contour()
Initializes a new instance of the Contour class.
public Contour()
Contour(int)
Initializes a new instance of the Contour class with a vertex capacity.
public Contour(int capacity)
Parameters
capacityintThe initial vertex capacity.
Properties
Count
Gets the number of stored vertices.
public int Count { get; }
Property Value
Depth
Gets or sets the depth of the contour.
public int Depth { get; set; }
Property Value
HoleCount
Gets the number of holes.
public int HoleCount { get; }
Property Value
IsExternal
Gets a value indicating whether the contour is external (not a hole).
public bool IsExternal { get; }
Property Value
this[int]
Gets the vertex at the specified index.
public Vertex this[int index] { get; }
Parameters
indexintThe index of the vertex.
Property Value
ParentIndex
Gets or sets the index of the parent contour in the polygon if this contour is a hole.
public int? ParentIndex { get; set; }
Property Value
- int?
Methods
Add(in Vertex)
Adds a vertex to the end of the vertices collection.
public void Add(in Vertex vertex)
Parameters
vertexVertexThe vertex to add.
AddHoleIndex(int)
Adds a hole index to the contour.
public void AddHoleIndex(int index)
Parameters
indexintThe index of the hole to add.
Clear()
Clears all vertices and holes from the contour.
public void Clear()
ClearHoles()
Clears all holes from the contour.
public void ClearHoles()
DeepClone()
Creates a deep copy of this contour.
public Contour DeepClone()
Returns
- Contour
A detached contour copy.
GetBoundingBox()
Gets the bounding box of the contour.
public Box2 GetBoundingBox()
Returns
GetEnumerator()
Returns an enumerator that iterates through the collection.
public IEnumerator<Vertex> GetEnumerator()
Returns
- IEnumerator<Vertex>
An enumerator that can be used to iterate through the collection.
GetHoleIndex(int)
Gets the hole index at the specified position in the contour.
public int GetHoleIndex(int index)
Parameters
indexintThe index of the hole.
Returns
- int
The hole index.
GetLastVertex()
Gets the last vertex in the contour.
public Vertex GetLastVertex()
Returns
IsClockwise()
Gets a value indicating whether the contour is clockwise oriented
public bool IsClockwise()
Returns
IsCounterClockwise()
Gets a value indicating whether the contour is counterclockwise oriented
public bool IsCounterClockwise()
Returns
RemoveVertexAt(int)
Removes the vertex at the specified index from the contour.
public void RemoveVertexAt(int index)
Parameters
indexintThe index of the vertex to remove.
Reverse()
Reverses the orientation of the contour.
public void Reverse()
SetClockwise()
Sets the contour to clockwise orientation.
public void SetClockwise()
SetCounterClockwise()
Sets the contour to counterclockwise orientation.
public void SetCounterClockwise()
Translate(double, double)
Translates the contour by the specified x and y values.
public void Translate(double x, double y)