An abstract around an Array of IPoints that define a polygonal shape that can be collision-tested against.

See also:

Static variables

staticread onlylength:Int

The amount of vertices in the polygon.

staticread onlypoints:Array<IPoint>

The underlying Array of vertices.

Static methods

staticarea(this:Array<IPoint>):Float

Calculates total area of the IPolygon.

@:value({ isConvex : false })staticcontains(this:Array<IPoint>, p:Point, isConvex:Bool = false):Bool

Tests if Point p is inside this IPolygon.

Parameters:

p

The point to test against.

isConvex

Use simplified collision test suited for convex polygons. Results are undefined if polygon is concave.

staticconvexHull(this:Array<IPoint>):Array<IPoint>

Returns a new IPolygon containing a convex hull of this IPolygon. See Monotone chain algorithm for more details.

staticgetBounds(this:Array<IPoint>, ?b:IBounds):IBounds

Returns the bounding box of the IPolygon.

@:value({ withHoles : true })staticinlineintersection(this:Array<IPoint>, p:IPolygon, withHoles:Bool = true):IPolygons

Calculates an intersection areas between this IPolygon and a given IPolygon p and returns the resulting IPolygons.

Parameters:

p

The IPolygon to intersect with.

withHoles

When enabled, keeps the holes in resulting polygons as a separate IPolygon.

staticisClockwise(this:Array<IPoint>):Bool

Tests if polygon points are in the clockwise order.

staticisConvex(this:Array<IPoint>):Bool

Tests if the polygon is convex or concave.

@:value({ withHoles : true })staticoffset(this:Array<IPoint>, delta:Float, kind:OffsetKind, withHoles:Bool = true):IPolygons

Offsets the polygon edges by specified amount and returns the resulting IPolygons.

Parameters:

delta

The offset amount.

kind

The corner rounding method.

withHoles

When enabled, keeps the holes in resulting polygons as a separate IPolygon.

staticoptimize(this:Array<IPoint>, epsilon:Float):IPolygon

Creates a new optimized polygon by eliminating almost colinear edges according to the epsilon distance.

staticreverse(this:Array<IPoint>):Void

Reverses the IPolygon points ordering. Can be used to change polygon from anti-clockwise to clockwise.

@:value({ withHoles : true })staticinlinesubtraction(this:Array<IPoint>, p:IPolygon, withHoles:Bool = true):IPolygons

Subtracts the area of a given IPolygon p from this IPolygon and returns the resulting IPolygons.

Parameters:

p

The IPolygon to subtract with.

withHoles

When enabled, keeps the holes in resulting polygons as a separate IPolygon.

@:value({ scale : 1. })statictoPolygon(this:Array<IPoint>, scale:Float = 1.):Polygon

Converts this IPolygon into a floating point-based Polygon.

@:value({ withHoles : true })staticunion(this:Array<IPoint>, p:IPolygon, withHoles:Bool = true):IPolygons

Combines this IPolygon and a given IPolygon p and returns the resulting IPolygons.

Parameters:

p

The IPolygon to union with.

withHoles

When enabled, keeps the holes in resulting polygons as a separate IPolygon.