RoundedPolygon constructor
RoundedPolygon(
- int numVertices, {
- double radius = 1.0,
- Offset center = .zero,
- CornerRounding rounding = .unrounded,
- List<
CornerRounding> ? perVertexRounding,
Creates a regular polygon with numVertices vertices, equally spaced
around a circle of the given radius about center.
The default radius of 1 puts the vertices on the unit circle, giving a shape 2 wide and 2 high, which will usually need normalized to fit the unit square a shape border expects.
rounding rounds every vertex the same way. perVertexRounding
overrides it, and must have numVertices elements when it is not null.
The default leaves the corners sharp and the edges straight.
Throws ArgumentError if numVertices is less than 3, or if
perVertexRounding has the wrong number of elements.
Implementation
factory(
int numVertices, {
double radius = 1.0,
Offset center = .zero,
CornerRounding rounding = .unrounded,
List<CornerRounding>? perVertexRounding,
}) {
if (numVertices < 3) {
throw ArgumentError("numVertices must be at least 3.");
}
return .fromVertices(
_verticesFromNumVerts(numVertices, radius, center),
rounding: rounding,
perVertexRounding: perVertexRounding,
center: center,
);
}