star function
void
star()
An impact star (after Sprite Fusion's impact): tapered spikes around (x, y).
Implementation
void star(
Painter p,
double x,
double y,
List<Spike> spikes,
double sc,
double th,
int core,
int body,
int inner,
int rim,
) {
for (final pass in const [0, 1, 2]) {
for (final s in spikes) {
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) {
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;
if (pass == 2 && d > l * 0.55) break;
for (var o = -hw; o <= hw; o += 0.5) {
p.px(
x + c * d - sn * o,
y + sn * d + c * o,
pass == 0
? rim
: pass == 1
? (d < l * 0.35 ? inner : body)
: core,
);
}
}
}
}
final r = 2.4 * sc * math.sqrt(th);
p.circle(x, y, r + 0.8, inner);
p.circle(x, y, r, core);
}