arcaneArc function
Implementation
List<ArcaneArcPath> arcaneArc(
Rng r,
double x0,
double y0,
double x1,
double y1, {
double jag = 0.3,
int forks = 1,
double forkLen = 0.5,
}) {
final l = hypot(x1 - x0, y1 - y0);
final depth = math.max(
1, math.min(5, (math.log(math.max(1e-6, l / 1.5)) / math.ln2).round()));
final main = bolt(r, x0, y0, x1, y1, jag: jag, depth: depth);
final out = <ArcaneArcPath>[ArcaneArcPath(main, 1.0)];
for (var k = 0; k < forks && main.length > 3; k++) {
if (r.next() > 0.7) continue;
final i = 1 + (r.next() * (main.length - 2)).floor();
final (x, y) = main[i];
final (px, py) = main[i - 1];
final a = math.atan2(y - py, x - px) +
(r.next() < 0.5 ? -1.0 : 1.0) * (0.4 + r.next() * 0.6);
final fl = l * forkLen * (0.4 + 0.6 * r.next()) * (1.0 - i / main.length);
if (fl > 1.5) {
out.add(ArcaneArcPath(
bolt(r, x, y, x + math.cos(a) * fl, y + math.sin(a) * fl,
jag: jag * 1.1, depth: math.max(1, depth - 2)),
0.55,
));
}
}
return out;
}