ember function

void ember(
  1. Painter p,
  2. double x,
  3. double y,
  4. double u,
  5. List<int> e,
  6. double ph, [
  7. double k = 1.0,
])

An ember at age u: hot and flickering, cooling to a dim red that blinks out.

Implementation

void ember(
  Painter p,
  double x,
  double y,
  double u,
  List<int> e,
  double ph, [
  double k = 1.0,
]) {
  final left = 1.0 - u;
  if (left < 0.22 && math.sin(ph * 40.0) < 0.0) return;
  final c = left > 0.5
      ? (math.sin(ph * 22.0) > -0.2 ? e[0] : e[1])
      : (left > 0.22 ? e[1] : e[2]);
  p.px(x, y, c);
  p.glow(x, y, 3.0, c, 0.32 * left * k);
}