drawArc function

void drawArc(
  1. Painter p,
  2. List<ArcaneArcPath> paths, {
  3. required int core,
  4. required int body,
  5. required int halo,
  6. required int glow,
  7. double k = 1.0,
  8. double glowK = 0.5,
})

Implementation

void drawArc(
  Painter p,
  List<ArcaneArcPath> paths, {
  required int core,
  required int body,
  required int halo,
  required int glow,
  double k = 1.0,
  double glowK = 0.5,
}) {
  void steps(
    void Function(double x, double y, ArcaneArcPath path, int i, bool first) fn,
  ) {
    for (final path in paths) {
      for (var i = 0; i < path.pts.length - 1; i++) {
        final (ax, ay) = path.pts[i];
        final (bx, by) = path.pts[i + 1];
        final l = math.max(1.0, hypot(bx - ax, by - ay));
        for (var d = 0.0; d <= l; d += 0.5) {
          fn(ax + ((bx - ax) * d) / l, ay + ((by - ay) * d) / l, path, i,
              d == 0.0);
        }
      }
    }
  }

  if (k > 0.45) {
    steps((x, y, path, _, _) {
      if (path.w >= 1.0) {
        for (final (dx, dy) in _cross) {
          p.dot(x + dx * 1.5, y + dy * 1.5, halo, (k - 0.45) * 1.6);
        }
      }
    });
  }
  if (k > 0.25) {
    steps((x, y, path, _, _) {
      if (path.w > 0.4) {
        p.dot(x + 1.0, y, body);
        p.dot(x, y + 1.0, body);
      }
    });
  }
  steps((x, y, path, i, first) {
    p.px(x, y, path.w >= 1.0 && k > 0.3 ? core : body);
    if (first && i % 3 == 0) {
      p.glow(x, y, (path.w >= 1.0 ? 9.0 : 5.0) * (0.5 + k * 0.5), glow,
          glowK * k * path.w);
    }
  });
}