Class Polygon
Represents a polygon of points. Provides methods for generating bounding boxes and translating polygons using a specified transform.
Implements
Inherited Members
Namespace: OpenSvg
Assembly: OpenSvg.dll
Syntax
public class Polygon : PointList, IReadOnlyList<Vector2>, IReadOnlyCollection<Vector2>, IEnumerable<Vector2>, IEnumerable, IEquatable<PointList>, IEquatable<Polygon>
Constructors
| Edit this page View SourcePolygon(IEnumerable<Vector2>)
Initializes a new instance of the Polygon class with the specified collection of points.
Declaration
public Polygon(IEnumerable<Vector2> points)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<Vector2> | points | The collection of points. |
Properties
| Edit this page View SourceBoundingBox
Declaration
public BoundingBox BoundingBox { get; }
Property Value
Type | Description |
---|---|
BoundingBox |
ConvexHull
Declaration
public ConvexHull ConvexHull { get; }
Property Value
Type | Description |
---|---|
ConvexHull |
Empty
Returns an empty polygon.
Declaration
public static Polygon Empty { get; }
Property Value
Type | Description |
---|---|
Polygon |
Methods
| Edit this page View SourceEquals(Polygon?)
Determines whether the specified object is equal to the current object.
Declaration
public bool Equals(Polygon? other)
Parameters
Type | Name | Description |
---|---|---|
Polygon | other | The object to compare with the current object. |
Returns
Type | Description |
---|---|
bool | true if the specified object is equal to the current object; otherwise, false. |
Equals(object?)
Determines whether the specified object is equal to the current object.
Declaration
public override bool Equals(object? obj)
Parameters
Type | Name | Description |
---|---|---|
object | obj | The object to compare with the current object. |
Returns
Type | Description |
---|---|
bool | true if the specified object is equal to the current object; otherwise, false. |
Overrides
| Edit this page View SourceFromXmlString(string)
Declaration
public static Polygon FromXmlString(string xmlString)
Parameters
Type | Name | Description |
---|---|---|
string | xmlString |
Returns
Type | Description |
---|---|
Polygon |
GetHashCode()
Serves as the default hash function.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
int | A hash code for the current object. |
Overrides
| Edit this page View SourceIsOnEdge(Vector2)
Determines if the given point is on the edge of this polygon.
Declaration
public bool IsOnEdge(Vector2 point)
Parameters
Type | Name | Description |
---|---|---|
Vector2 | point | The point to check. |
Returns
Type | Description |
---|---|
bool | True if the point is on the edge of this polygon, false otherwise. |
RelationTo(Polygon)
Determines the relationship between two polygons.
Declaration
public PolygonRelation RelationTo(Polygon target)
Parameters
Type | Name | Description |
---|---|---|
Polygon | target | The target polygon. |
Returns
Type | Description |
---|---|
PolygonRelation | A PolygonRelation value indicating the relationship between the polygons. |
RelationTo(Vector2)
Calculates the PointRelation of a point to a polygon.
Declaration
public PointRelation RelationTo(Vector2 target)
Parameters
Type | Name | Description |
---|---|---|
Vector2 | target | The point to check. |
Returns
Type | Description |
---|---|
PointRelation | The PointRelation of the point to the polygon. Either Inside or Disjoint. |
ToPath()
Declaration
public Path ToPath()
Returns
Type | Description |
---|---|
Path |
ToSvgPolygon()
Declaration
public SvgPolygon ToSvgPolygon()
Returns
Type | Description |
---|---|
SvgPolygon |