RoundedPolygon.star constructor
RoundedPolygon.star({
- required int numVerticesPerRadius,
- double radius = 1.0,
- double innerRadius = 0.5,
- CornerRounding rounding = .unrounded,
- CornerRounding? innerRounding,
- List<
CornerRounding> ? perVertexRounding, - double centerX = 0.0,
- double centerY = 0.0,
Implementation
factory RoundedPolygon.star({
required int numVerticesPerRadius,
double radius = 1.0,
double innerRadius = 0.5,
CornerRounding rounding = .unrounded,
CornerRounding? innerRounding,
List<CornerRounding>? perVertexRounding,
double centerX = 0.0,
double centerY = 0.0,
}) {
if (radius <= 0.0) {
throw ArgumentError.value(
radius,
"radius",
"Star radii must both be greater than 0.",
);
}
if (innerRadius <= 0.0) {
throw ArgumentError.value(
innerRadius,
"innerRadius",
"Star radii must both be greater than 0.",
);
}
if (innerRadius >= radius) {
throw ArgumentError("innerRadius must be less than radius");
}
var pvRounding = perVertexRounding;
// If no per-vertex rounding supplied and caller asked for inner rounding,
// create per-vertex rounding list based on supplied outer/inner rounding parameters
if (pvRounding == null && innerRounding != null) {
// TODO: consider reverting back to the original flattening implementation
pvRounding = .generate(
numVerticesPerRadius * 2,
(index) => index.isEven ? rounding : innerRounding,
);
}
// Star polygon is just a polygon with all vertices supplied (where we generate
// those vertices to be on the inner/outer radii)
return .fromVertices(
vertices: _starVerticesFromNumVerts(
numVerticesPerRadius,
radius,
innerRadius,
centerX,
centerY,
),
rounding: rounding,
perVertexRounding: pvRounding,
centerX: centerX,
centerY: centerY,
);
}