RoundedPolygon.fromVerticesNum constructor
- int numVertices, {
- double radius = 1,
- double centerX = 0,
- double centerY = 0,
- CornerRounding rounding = CornerRounding.unrounded,
- List<
CornerRounding> ? perVertexRounding,
This constructor takes the number of vertices in the resulting polygon.
These vertices are positioned on a virtual circle around a given center
with each vertex positioned radius distance from that center, equally
spaced (with equal angles between them). If no radius is supplied, the
shape will be created with a default radius of 1, resulting in a shape
whose vertices lie on a unit circle, with width/height of 2. That default
polygon will probably need to be rescaled using transformed into the
appropriate size for the UI in which it will be drawn.
The rounding and perVertexRounding parameters are optional. If not
supplied, the result will be a regular polygon with straight edges and
unrounded corners.
numVertices is the number of vertices in this polygon.
radius is the radius of the polygon, in pixels. This radius determines
the initial size of the object, but it can be transformed later by using
the transformed function.
centerX is the X coordinate of the center of the polygon, around which
all vertices will be placed. The default center is at (0,0).
centerY is the Y coordinate of the center of the polygon, around which
all vertices will be placed. The default center is at (0,0).
rounding is the CornerRounding properties of all vertices. If some
vertices should have different rounding properties, then use
perVertexRounding instead. The default rounding value is
CornerRounding.unrounded, meaning that the polygon will use the
vertices themselves in the final shape and not curves rounded around the
vertices.
perVertexRounding is the CornerRounding properties of every vertex.
If this parameter is not null, then it must have numVertices elements.
If this parameter is null, then the polygon will use the rounding
parameter for every vertex instead. The default value is null.
Throws ArgumentError if perVertexRounding is not null and its size
is not equal to numVertices.
Throws ArgumentError when numVertices is less than 3.
Implementation
factory RoundedPolygon.fromVerticesNum(
int numVertices, {
double radius = 1,
double centerX = 0,
double centerY = 0,
CornerRounding rounding = CornerRounding.unrounded,
List<CornerRounding>? perVertexRounding,
}) {
if (numVertices < 3) {
throw ArgumentError('numVertices must be at least 3.');
}
return RoundedPolygon.fromVertices(
_verticesFromNumVerts(numVertices, radius, centerX, centerY),
rounding: rounding,
perVertexRounding: perVertexRounding,
centerX: centerX,
centerY: centerY,
);
}