bubble function
void
bubble(])
A bubble of radius r centered at (x, y): a 1 px skin, a translucent belly, a white glint.
Implementation
void bubble(
Painter p,
double x,
double y,
double r,
int c1,
int c2,
int fill, [
double a = 1.0,
bool dome = false,
]) {
final rad = r.ceil() + 1;
final cx = (x + 0.5).floor();
final cy = (y + 0.5).floor();
final jMax = dome ? 0 : rad;
for (var j = -rad; j <= jMax; j++) {
for (var i = -rad; i <= rad; i++) {
final d = hypot(i.toDouble(), j.toDouble());
if (d > r + 0.45) continue;
if (d > r - 0.6) {
p.dot(cx + i, cy + j, i < 0 && j < -r * 0.2 ? c1 : c2, a);
} else {
p.blend(cx + i, cy + j, fill, 0.3 * a);
}
}
}
if (r >= 1.5) {
p.dot(
cx - (r * 0.45 + 0.5).floor(),
cy - (r * 0.5 + 0.5).floor(),
kWhite,
a,
);
}
}