smoke function

void smoke(
  1. Painter p,
  2. double x,
  3. double y,
  4. double size,
  5. double u,
  6. int col, [
  7. double k = 1.0,
  8. int warm = 0,
])

A puff of smoke at age u (0..1), swelling and thinning.

Implementation

void smoke(
  Painter p,
  double x,
  double y,
  double size,
  double u,
  int col, [
  double k = 1.0,
  int warm = 0,
]) {
  final r = size * (0.65 + math.min(1.0, u * 2.5) * 0.45 + u * 0.4);
  final a = math.min(1.0, u * 12.0) * math.min(1.0, (1.0 - u) * 2.4) * 0.58 * k;
  if (a <= 0.01) return;
  final c = col != 0
      ? mix(col, _rampAt(kSmokeRamp, u), u)
      : _rampAt(kSmokeRamp, u * 1.05);
  p.disc(x, y, r, c, a * 0.45);
  p.disc(x + r * 0.05, y + r * 0.06, r * 0.74, c, a * 0.62);
  if (warm != 0 && u < 0.6) {
    p.disc(
      x + r * 0.1,
      y + r * 0.3,
      r * 0.56,
      mix(c, warm, 0.5),
      a * 0.7 * (1.0 - u / 0.6),
    );
  }
  if (u < 0.5) {
    p.disc(
      x - r * 0.22,
      y - r * 0.3,
      r * 0.5,
      mix(c, kWhite, 0.12),
      a * 0.4 * (1.0 - u * 2.0),
    );
  }
}