SPath.regularPolygon constructor

SPath.regularPolygon({
  1. required double radius,
  2. required Point<double> at,
  3. int n = 5,
  4. double startAngle = 0,
})

A regular polygon shape

Implementation

SPath.regularPolygon(
    {required double radius,
    required Point<double> at,
    int n = 5,
    double startAngle = 0}) {
  var a = -pi / 2 + startAngle;
  final dA = (pi * 2) / n;
  currentPoint = Point(at.x + radius * cos(a), at.y + radius * sin(a));
  for (var i = 1; i < n; i++) {
    line(
        to: Point(at.x + radius * cos(a + i * dA),
            at.y + radius * sin(a + i * dA)));
  }
  close();
}