burnTrail function
void
burnTrail(])
A burning thing's trail: pts (oldest first) at time t, drawn as a ribbon.
Implementation
void burnTrail(
Painter p,
List<({double x, double y, double t})> pts,
double t,
List<int> fr,
List<int> sm, [
double life = 0.5,
double w = 1.0,
double heat = 1.0,
]) {
var lx = double.nan;
var ly = double.nan;
for (var i = pts.length - 1; i >= 0; i--) {
final q = pts[i];
final age = (t - q.t) / life;
if (age >= 1.0) break;
if (hypot(q.x - lx, q.y - ly) < 1.6) continue;
lx = q.x;
ly = q.y;
final r = w * (0.7 + age * 2.6);
if (age < 0.12 * heat) {
p.circle(q.x, q.y - age * 6.0, r * 0.8, fr[age < 0.05 ? 3 : 5]);
} else {
p.disc(
q.x,
q.y - age * 6.0,
r,
sm[math.min(sm.length - 1, 1 + (age * 3.0).floor())],
0.55 * (1.0 - age),
);
}
}
}