RoundedPolygon.regular constructor
- required int numVertices,
- double radius = 1.0,
- double centerX = 0.0,
- double centerY = 0.0,
- CornerRounding rounding = .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.
@param numVertices The number of vertices in this polygon.
@param radius 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.
@param centerX The X coordinate of the center of the polygon, around which all vertices will be
placed. The default center is at (0,0).
@param centerY The Y coordinate of the center of the polygon, around which all vertices will be
placed. The default center is at (0,0).
@param rounding 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.
@param perVertexRounding 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 IllegalArgumentException If perVertexRounding is not null and its size is not equal to
numVertices.
@throws IllegalArgumentException numVertices must be at least 3.
Implementation
factory RoundedPolygon.regular({
required int numVertices,
double radius = 1.0,
double centerX = 0.0,
double centerY = 0.0,
CornerRounding rounding = .unrounded,
List<CornerRounding>? perVertexRounding,
}) {
if (numVertices < 3) {
throw RangeError.range(numVertices, 3, null, "numVertices");
}
return .fromVertices(
vertices: _verticesFromNumVerts(numVertices, radius, centerX, centerY),
rounding: rounding,
perVertexRounding: perVertexRounding,
centerX: centerX,
centerY: centerY,
);
}