Polygon class final

A convex polygon with at most maxVertices vertices, with an optional rounding radius.

Mirrors the native b2Polygon type. The native library computes the convex hull of the given points at shape creation time; creating a shape from points whose hull is degenerate (fewer than three distinct, non-collinear points) throws an ArgumentError.

Inheritance

Constructors

Polygon(List<Vector2> points, {double radius = 0})
Creates a polygon from the convex hull of points.
Polygon.box(double halfWidth, double halfHeight, {double radius = 0})
Creates an axis-aligned box with half-width halfWidth and half-height halfHeight, centered on the body origin.
Polygon.offsetBox(double halfWidth, double halfHeight, {required Vector2 center, double? rotation = 0})
Creates a box that is offset by center and rotated by rotation radians relative to the body origin.
Polygon.square(double halfExtent, {double radius = 0})
Creates a square with half-extent halfExtent, centered on the body origin.

Properties

center → Vector2?
The local center offset for offset boxes.
final
halfHeight → double?
The half-height for box polygons, or null for point-based polygons.
final
halfWidth → double?
The half-width for box polygons, or null for point-based polygons.
final
hashCode → int
The hash code for this object.
no setterinherited
points → List<Vector2>?
The points whose convex hull forms the polygon, or null for boxes.
final
radius → double
The rounding radius applied to the polygon.
final
rotation → double?
The local rotation in radians for offset boxes.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Constants

maxVertices → const int
The maximum number of vertices a polygon can have.