SPath.star constructor

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

A star shape

Implementation

SPath.star(
    {double? innerRadius,
    required double radius,
    required Point<double> at,
    int n = 5,
    double startAngle = 0}) {
  var a = -pi / 2 + startAngle;
  final iR = innerRadius ?? radius / 2;
  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 + iR * cos(a + (i - 0.5) * dA),
            at.y + iR * sin(a + (i - 0.5) * dA)));
    line(
        to: Point(at.x + radius * cos(a + i * dA),
            at.y + radius * sin(a + i * dA)));
  }
  line(
      to: Point(
          at.x + iR * cos(a - 0.5 * dA), at.y + iR * sin(a - 0.5 * dA)));
  close();
}