firePuff function
Implementation
void firePuff(
Painter p,
double x,
double y,
double k,
double size,
double seed,
List<int> heat,
) {
final age = 1.0 - k;
final n = heat.length;
final hot = math.min(
0.999,
math.pow(age, 0.62).toDouble() + (seed.remainder(1.0)) * 0.1,
);
final idx = math.min(n - 2, (hot * (n - 1)).floor());
final r = size * (0.55 + 0.45 * math.min(1.0, age * 7.0)) * (1.0 - age * 0.55);
final c = heat[idx];
if (idx >= n - 2) {
p.disc(x, y, r, c, math.min(1.0, k * 3.0) * 0.85);
return;
}
p.circle(x, y, r, heat[math.min(n - 1, idx + 2)]);
p.circle(x - r * 0.16, y - r * 0.22, r * 0.78, c);
if (r > 1.6) p.circle(x, y - r * 0.9, r * 0.42, c);
if (idx <= 3 && r > 1.8) {
p.circle(x - r * 0.28, y - r * 0.34, r * 0.36, heat[math.max(0, idx - 1)]);
}
if (idx < 6) p.glow(x, y, r * 2.4 + 2.0, c, 0.18 * k);
}