halo function

void halo(
  1. Painter p,
  2. num x,
  3. num y,
  4. num r0,
  5. num r1,
  6. int col,
  7. num k,
)

A ring of light hugging a black disc: k at radius r0, falling to nothing at r1, and none inside r0.

Implementation

void halo(
  Painter p,
  num x,
  num y,
  num r0,
  num r1,
  int col,
  num k,
) {
  final r0d = r0.toDouble();
  final r1d = r1.toDouble();
  final kd = k.toDouble();
  if (r1d <= r0d || kd <= 0.004) return;
  final w = r1d - r0d;
  _annulus(x.toDouble(), y.toDouble(), math.max(0.0, r0d), r1d, (cx, cy, d) {
    final f = 1 - (d - r0d) / w;
    p.light(cx, cy, col, f * f * kd);
  });
}