haze function

void haze(
  1. Painter p,
  2. double x,
  3. double y,
  4. double rx,
  5. double ry,
  6. int c(
    1. double d
    ),
  7. double a(
    1. double d
    ),
)

A translucent ellipse (blended, never dithered): c and a may depend on d (0 centre .. 1 rim).

Implementation

void haze(
  Painter p,
  double x,
  double y,
  double rx,
  double ry,
  int Function(double d) c,
  double Function(double d) a,
) {
  if (rx < 0.5 || ry < 0.5) return;
  p.each(x - rx, y - ry, x + rx, y + ry, (lx, ly, sx, sy) {
    final dx = (lx - x) / rx;
    final dy = (ly - y) / ry;
    final d2 = dx * dx + dy * dy;
    if (d2 > 1.0) return;
    final d = math.sqrt(d2);
    p.blendPx(sx, sy, c(d), a(d));
  });
}