RoundedPolygon.circle constructor
RoundedPolygon.circle({})
Implementation
factory RoundedPolygon.circle({
int numVertices = 8,
double radius = 1.0,
double centerX = 0.0,
double centerY = 0.0,
}) {
if (numVertices < 3) {
throw RangeError.range(
numVertices,
3,
null,
"numVertices",
"Circle must have at least three vertices.",
);
}
// Half of the angle between two adjacent vertices on the polygon
final theta = math.pi / numVertices;
// Radius of the underlying RoundedPolygon object given the desired radius of the circle
final polygonRadius = radius / math.cos(theta);
return .regular(
numVertices: numVertices,
rounding: .from(radius: radius),
radius: polygonRadius,
centerX: centerX,
centerY: centerY,
);
}