createStarPath function

Path createStarPath(
  1. double outerRadius,
  2. double innerRadius,
  3. int points
)

Implementation

Path createStarPath(double outerRadius, double innerRadius, int points) {
  final path = Path();
  final angle = (pi * 2) / points;

  for (int i = 0; i < points; i++) {
    final isOuterPoint = i % 2 == 0;
    final radius = isOuterPoint ? outerRadius : innerRadius;
    final x = radius * cos(i * angle);
    final y = radius * sin(i * angle);
    if (i == 0) {
      path.moveTo(x, y);
    } else {
      path.lineTo(x, y);
    }
  }
  path.close();
  return path;
}