Polygon Class
A convex clockwise Polygon.
Constructor
Polygon
-
x
-
y
-
points
-
scale
Parameters:
-
x
NumberThe X origin of the polygon, all X coords for all points are relative to this
-
y
NumberThe Y origin of the polygon, all Y coords for all points are relative to this
-
points
Array| Array This can be an array of Vectors that form the polygon, a flat array of numbers that will be interpreted as [x,y, x,y, ...]
-
scale
NumberThe scale of the polygon
Item Index
Methods
contains
-
x
-
y
Checks if the x, and y coords passed to this function are contained within this polygon
Parameters:
-
x
NumberThe X coord of the point to test
-
y
NumberThe Y coord of the point to test
Returns:
if the x/y coords are within this polygon
copy
-
polygon
Copies the values from another polygon to this one
Parameters:
-
polygon
PolygonThe polygon to copy vlaues from
Returns:
Returns itself.
equals
-
polygon
Checks if this polygon's values are equal to anothers
Parameters:
-
polygon
PolygonThe polygon to check against
Returns:
True if they are equal
Properties
_points
ArrayThe unscaled points of the polygon, the X & Y values here should be relative to the origin X & Y.
Default: []
edges
ArrayThese vectors are calculated by this.recalc()
and represent the edges
of the polygon defined by it's points.
Default: []
normals
ArrayThese vectors are calculated by this.recalc()
and represent the normals
of the polygon edges defined by it's points.
Default: []
points
ArrayThe points of the polygon, the X & Y values here should be relative to the origin X & Y values.
Default: []
x
Number
The origin X coord of the polygon
Default: 0
x
Number
The origin Y coord of the polygon
Default: 0