SPath.spiral constructor

SPath.spiral({
  1. required Point<double> at,
  2. required int n,
  3. required double l,
  4. dynamic startAngle = 0,
  5. double rate = 20,
})

A spiral shape made up of lines

Implementation

SPath.spiral(
    {required Point<double> at,
    required int n,
    required double l,
    startAngle = 0,
    double rate = 20}) {
  var a = startAngle;
  var r = l;

  currentPoint = at + Point(r * cos(a), r * sin(a));
  for (var i = 0; i < n; i++) {
    final dA = 2 * asin(l / (r * 2));
    r += rate * dA;
    a += dA;
    line(to: at + Point(r * cos(a), r * sin(a)));
  }
}