softDisc function
Implementation
void softDisc(Painter p, double x, double y, double r, int c, double a) {
if (a <= 0.004) return;
if (r < 0.5) {
p.blend(x, y, c, a);
return;
}
final cx = p.toX(x, y);
final cy = p.toY(x, y);
final r2 = r * r;
final y0 = (cy - r).floor();
final y1 = (cy + r).ceil();
for (var sy = y0; sy <= y1; sy++) {
final dy = sy + 0.5 - cy;
final s2 = r2 - dy * dy;
if (s2 < 0.0) continue;
final s = math.sqrt(s2);
final x0 = (cx - s - 0.5).ceil();
final x1 = (cx + s - 0.5).floor();
for (var sx = x0; sx <= x1; sx++) {
p.blendPx(sx, sy, c, a);
}
}
}