PolygonComponent.regular constructor
PolygonComponent.regular({})
With this constructor you create a regular (equiangular and equilateral)
polygon from number of sides and radius anywhere in the 2d-space. It will
automatically calculate the size of the Polygon (the bounding box) if no
size is given.
Implementation
PolygonComponent.regular({
required int sides,
required double radius,
Vector2? position,
Vector2? size,
Vector2? scale,
double? angle,
Anchor? anchor,
Iterable<Component>? children,
int? priority,
Paint? paint,
List<Paint>? paintLayers,
ComponentKey? key,
bool? shrinkToBounds,
}) : this(
List.generate(sides, (i) {
final angle = tau * i / sides;
return Vector2(radius * cos(angle), radius * sin(angle));
}, growable: false),
position: position,
size: size,
scale: scale,
angle: angle,
anchor: anchor,
children: children,
priority: priority,
paint: paint,
paintLayers: paintLayers,
key: key,
shrinkToBounds: shrinkToBounds,
);