Creates a Polygon with the given coordinates.
an array that contains either 'Point' instances or alternating 'x' and 'y' coordinates.
Calculates the total area of the polygon.
Indicates if the polygon is convex. In a convex polygon, the vector between any two points inside the polygon lies inside it, as well.
Indicates if the polygon's line segments are not self-intersecting.
Beware: this is a brute-force implementation with O(n^2)
.
Returns the number of triangles that will be required when triangulating the polygon.
Returns the total number of vertices spawning up the polygon. Assigning a value that's smaller than the current number of vertices will crop the path; a bigger value will fill up the path with zeros.
Adds vertices to the polygon. Pass either a list of 'Point' instances or alternating 'x' and 'y' coordinates.
Creates a clone of this polygon.
Figures out if the given coordinates lie within the polygon.
Figures out if the given point lies within the polygon.
Copies all vertices to a 'VertexData' instance, beginning at a certain target index.
Returns the coordinates of a certain vertex.
Reverses the order of the vertices. Note that some methods of the Polygon class require the vertices in clockwise order.
Moves a given vertex to a certain position or adds a new vertex at the end.
Creates a string that contains the values of all included points.
Calculates a possible representation of the polygon via triangles. The resulting IndexData instance will reference the polygon vertices as they are saved in this Polygon instance, optionally incremented by the given offset.
If you pass an indexData object, the new indices will be appended to it. Otherwise, a new instance will be created.
Creates a circle with optimized implementations of triangulation, hitTest, etc.
Creates an ellipse with optimized implementations of triangulation, hitTest, etc.
Creates a rectangle with optimized implementations of triangulation, hitTest, etc.
Generated using TypeDoc
A polygon describes a closed two-dimensional shape bounded by a number of straight line segments.
The vertices of a polygon form a closed path (i.e. the last vertex will be connected to the first). It is recommended to provide the vertices in clockwise order. Self-intersecting paths are not supported and will give wrong results on triangulation, area calculation, etc.