brokenRing function
void
brokenRing(])
A ring that breaks into arcs: segs evenly round the ring. brk 0 draws a whole ring th thick; as brk grows each arc shrinks, tapers at both ends into a crescent and drifts out at its own speed. c is the outer edge's color, c2 the inner's; sy squashes it onto a plane; nothing is drawn below maxY (a floor).
Implementation
void brokenRing(
Painter p,
double x,
double y,
double r,
double th,
List<RingSeg> segs,
double brk,
int c, [
int? c2,
double k = 1.0,
double sy = 1.0,
double maxY = double.infinity,
]) {
if (r <= 0.0 || k <= 0.0) return;
final inner = c2 ?? c;
final full = tau / segs.length;
for (final s in segs) {
final span = full * (1.0 - s.gap * brk) + 0.02;
final rr = r * (1.0 + s.dr * brk);
final m = math.max(4, (rr * span * 1.8).ceil());
for (var j = 0; j <= m; j++) {
final u = j / m;
final ang = s.a + (u - 0.5) * span;
final w = math.max(
0.5,
th * s.w * (1.0 - brk * math.pow((2.0 * u - 1.0).abs(), 1.6)),
);
final ca = math.cos(ang);
final sa = math.sin(ang);
for (var o = -w / 2.0; o <= w / 2.0 + 0.01; o += 0.5) {
if (y + sa * (rr + o) * sy < maxY) {
p.dot(
x + ca * (rr + o),
y + sa * (rr + o) * sy,
o > -0.26 ? c : inner,
k,
);
}
}
}
}
}