ringLight function

void ringLight(
  1. Painter p,
  2. num x,
  3. num y,
  4. num R,
  5. num w,
  6. int col,
  7. num k, [
  8. bool keep(
    1. double x,
    2. double y
    )?,
])

Light hugging a circle of radius R at (x, y), falling off over w either side, only where keep returns true.

Implementation

void ringLight(
  Painter p,
  num x,
  num y,
  num R,
  num w,
  int col,
  num k, [
  bool Function(double x, double y)? keep,
]) {
  final wd = w.toDouble();
  final kd = k.toDouble();
  if (wd < 1 || kd <= 0.004) return;
  final rd = R.toDouble();
  _annulus(x.toDouble(), y.toDouble(), math.max(0.0, rd - wd), rd + wd, (cx, cy, d) {
    if (keep != null && !keep(cx, cy)) return;
    final f = 1 - (d - rd).abs() / wd;
    p.light(cx, cy, col, f * f * kd);
  });
}