star function

void star(
  1. Painter p,
  2. double x,
  3. double y,
  4. List<ImpactSpike> list,
  5. double sc,
  6. double th,
  7. List<int> cols, [
  8. double a = 1.0,
  9. double heart = 2.4,
])

A hit star: tapered spikes in three passes (a rim, a body that's paler near the root, a hot core) round a hot heart. sc stretches the spikes, th thins them, cols rim, body, inner, core, a dithers it out.

Implementation

void star(
  Painter p,
  double x,
  double y,
  List<ImpactSpike> list,
  double sc,
  double th,
  List<int> cols, [
  double a = 1.0,
  double heart = 2.4,
]) {
  final rim = cols[0];
  final body = cols[1];
  final inner = cols[2];
  final core = cols[3];
  for (var pass = 0; pass < 3; pass++) {
    for (final s in list) {
      final c = math.cos(s.a);
      final sn = math.sin(s.a);
      final l = s.len * sc;
      for (var d = 0.0; d <= l; d += 0.5) {
        if (pass == 2 && d > l * 0.55) break;
        final hw0 = s.w * th * (1.0 - d / l) * math.min(1.0, 0.5 + d / 3.0);
        final hw = pass == 0 ? hw0 + 0.8 : (pass == 1 ? hw0 : hw0 * 0.45);
        final col = pass == 0
            ? rim
            : (pass == 1 ? (d < l * 0.35 ? inner : body) : core);
        for (var o = -hw; o <= hw; o += 0.5) {
          p.dot(x + c * d - sn * o, y + sn * d + c * o, col, a);
        }
      }
    }
  }
  final r = heart * sc * math.sqrt(th);
  p.circle(x, y, r + 0.8, inner, a);
  p.circle(x, y, r, core, a);
}