Polygon constructor

Polygon(
  1. List<Vector2> _vertices, {
  2. bool? convex,
})

Constructs the polygon from the given list of vertices.

If the list is not in the counter-clockwise order, then it will be reversed in-place.

If the convex flag is provided, then it serves as a hint about whether the polygon is convex or not. With this flag the user promises that the vertices are already in the correct CCW order.

Implementation

Polygon(this._vertices, {bool? convex})
    : assert(_vertices.length >= 3, 'At least 3 vertices are required') {
  _initializeEdges();
  if (convex == null) {
    _ensureProperOrientation();
  } else {
    _convex = convex;
  }
}