puff function

void puff(
  1. Painter p,
  2. double x,
  3. double y,
  4. double r,
  5. double a,
  6. int c, [
  7. double cap = 1,
  8. double warm = 0,
  9. int wc = 0,
  10. double wa = 0,
])

A soft smoke puff with body, lower core, young top cap, and optional fire light.

Implementation

void puff(
  Painter p,
  double x,
  double y,
  double r,
  double a,
  int c, [
  double cap = 1,
  double warm = 0,
  int wc = 0,
  double wa = 0,
]) {
  if (a <= 0.01 || r < 0.5) return;
  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 (cap > 0.02) {
    p.disc(
      x - r * 0.22,
      y - r * 0.3,
      r * 0.5,
      mix(c, kWhite, 0.14),
      a * 0.42 * cap,
    );
  }
  if (warm > 0.02) {
    p.disc(
      x + math.cos(wa) * r * 0.32,
      y + math.sin(wa) * r * 0.32,
      r * 0.55,
      wc,
      a * 0.7 * warm,
    );
  }
}