RoundedPolygon.circle constructor

RoundedPolygon.circle({
  1. int numVertices = 8,
  2. double radius = 1,
  3. double centerX = 0,
  4. double centerY = 0,
})

Implementation

factory RoundedPolygon.circle({
  int numVertices = 8,
  double radius = 1,
  double centerX = 0,
  double centerY = 0,
}) {
  if (numVertices < 3) {
    throw ArgumentError('Circle must have at least three vertices.');
  }

  final theta = math.pi / numVertices;
  final polygonRadius = radius / math.cos(theta);
  return RoundedPolygon.fromVerticesNum(
    numVertices,
    radius: polygonRadius,
    centerX: centerX,
    centerY: centerY,
    rounding: CornerRounding(radius: radius),
  );
}