spikes function
Spikes for a hit star: n of them round the circle, longer towards aim (fwd) and a little behind it (back). len and w: (min, max) base length and root half-width; jag scales every other spike (short teeth between).
Implementation
List<ImpactSpike> spikes(
Rng r,
int n,
double aim, {
(double, double) len = (7.0, 10.0),
(double, double) w = (1.5, 2.1),
double fwd = 1.8,
double back = 0.6,
double jag = 1.0,
double jit = 0.18,
}) {
return List<ImpactSpike>.generate(n, (i) {
final a = aim + (i / n) * tau + r.range(-jit, jit);
final cb = math.cos(a - aim);
final odd = (i & 1) != 0;
final l = r.range(len.$1, len.$2) *
(1.0 +
fwd * math.pow(math.max(0.0, cb), 3) +
back * math.pow(math.max(0.0, -cb), 3)) *
(odd ? jag : 1.0);
return ImpactSpike(
a: a,
len: l,
w: r.range(w.$1, w.$2) * (odd ? math.sqrt(jag) : 1.0),
);
});
}