generatePath method
Implementation
Path generatePath({bool? useBezier, required Rect rect}) {
final height = rect.height;
final width = rect.width;
final double section = (2.0 * pi / numberOfSides);
final double polygonSize = min(width, height);
final double radius = polygonSize / 2;
final double centerX = width / 2;
final double centerY = height / 2;
final Path polygonPath = new Path();
polygonPath.moveTo(
(centerX + radius * cos(0)),
(centerY + radius * sin(0)),
);
for (int i = 1; i < numberOfSides; i++) {
polygonPath.lineTo(
(centerX + radius * cos(section * i)),
(centerY + radius * sin(section * i)),
);
}
polygonPath.close();
return polygonPath;
}