PolygonComponent constructor
PolygonComponent(})
With this constructor you create your PolygonComponent from positions in
anywhere in the 2d-space. It will automatically calculate the size
of
the Polygon (the bounding box) if no size it given.
Implementation
PolygonComponent(
this._vertices, {
super.position,
super.size,
super.scale,
super.angle,
super.anchor,
super.children,
super.priority,
super.paint,
super.paintLayers,
super.key,
bool? shrinkToBounds,
}) : assert(
_vertices.length > 2,
'Number of vertices are too few to create a polygon',
),
shrinkToBounds = shrinkToBounds ?? size == null,
manuallyPositioned = position != null {
refreshVertices(newVertices: _vertices);
final verticesLength = _vertices.length;
_globalVertices = List.generate(
verticesLength,
(_) => Vector2.zero(),
growable: false,
);
_lineSegments = List.generate(
verticesLength,
(_) => LineSegment.zero(),
growable: false,
);
}