generatePath method
Implementation
Path generatePath({bool? useBezier, required Rect rect}) {
final height = rect.height;
final width = rect.width;
final int vertices = noOfPoints * 2;
final double alpha = (2 * pi) / vertices;
final double radius = (height <= width ? height : width) / 2.0;
final double centerX = width / 2;
final double centerY = height / 2;
final Path path = Path();
for (int i = vertices + 1; i != 0; i--) {
final double r = radius * (i % 2 + 1) / 2;
final double omega = alpha * i;
final double x = (r * sin(omega)) + centerX;
final double y = (r * cos(omega)) + centerY;
// Start at the first point; a lineTo here would start from (0, 0).
if (i == vertices + 1) {
path.moveTo(x, y);
} else {
path.lineTo(x, y);
}
}
path.close();
return path;
}