Polygon subtype of Shape.

Can be used to simulate any convex polygon.

### Static methods

`staticbox(width:Float, height:Float, weak:Bool = false):Array<Vec2>`

Construct a polygon representing an origin centred box.

This method is equivalent to calling: `Polygon.rect(-width/2,-height/2,width,height)`

Parameters:

`width` | The width of the box (This value may be negative but will make no difference). |
---|---|

`height` | The height of the box (This value may be negative but will make no difference). |

`weak` | If true, the generated list of vertices will be allocated as weak Vec2s so that when this list is passed to a Nape function these Vec2s will be automatically sent back to object pool. (default false) |

Returns:

An array of Vec2 representing the given box.

`staticrect(x:Float, y:Float, width:Float, height:Float, weak:Bool = false):Array<Vec2>`

Construct a polygon representing a rectangle.

For a dynamic object, you may consider use of the box method instead
as dynamic bodies will only respond as expected if their centre of mass
is equal to the origin.

The generate polygon will have coordinates equal to:

(x, y) -> (x + width, y + height)Negative values of width/height are permitted so that the given x/y values may not necessarigly be the top-left corner of rectangle.

Parameters:

`x` | The x coordinate of rectangle. |
---|---|

`y` | The y coordinate of rectangle. |

`width` | The width of the ractangle. This value may be negative. |

`height` | The height of the rectangle This value may be negative. |

`weak` | If true, the generated list of vertices will be allocated as weak Vec2s so that when this list is passed to a Nape function these Vec2s will be automatically sent back to object pool. (default false) |

Returns:

An array of Vec2 representing the given rectangle.

`staticregular(xRadius:Float, yRadius:Float, edgeCount:Int, angleOffset:Float = 0.0, weak:Bool = false):Array<Vec2>`

Construct a regular polygon centred at origin.

Vertices are created at positions on the edge of an ellipsoid of given
radii, when radii are not equal the vertices will not have an equal
angle between them; it will be as though an actual regular polygon were
created, and then squashed to conform to the input radii.

Parameters:

`xRadius` | The x radius of polygon before angleOffset rotation. |
---|---|

`yRadius` | The y radius of polygon before angleOffset rotation. |

`edgeCount` | The number of edges/vertices in polygon. |

`angleOffset` | The clockwise angular offset to generate vertices at in radians. (default 0.0) |

`weak` | If true, the generated list of vertices will be allocated as weak Vec2s so that when this list is passed to a Nape function these Vec2s will be automatically sent back to object pool. (default false) |

Returns:

An array of Vec2 representing the polygon.

### Constructor

`new(localVerts:Dynamic, ?material:Material, ?filter:InteractionFilter)`

Construct a new Polygon.

The localVerts parameter is typed Dynamic and may be one of:
`Array<Vec2>, flash.Vector<Vec2>, Vec2List, GeomPoly`

Parameters:

`localVerts` | The local vertices of polygon. |
---|---|

`material` | The material for this polygon. (default new Material()) |

`filter` | The interaction filter for this polygon. (default new InteractionFilter()) |

Returns:

The constructed Polygon.

Throws:

`#` | If localVerts is null, or not of the expected Type. |
---|---|

`#` | If localVerts contains any disposed or null Vec2. |

### Variables

`read onlylocalVerts:Vec2List`

Local coordinates of vertices.

This list can be modified, but modifications to a Polygon that is
part of a static Body inside of a Space will given an error in
debug builds.

`read onlyworldVerts:Vec2List`

World coordinates of vertices.

This list can be accessed, but any queries of values will result
in an error in debug builds unless this Polygon is part of a Body.

This list is immutable.