frontCrescent function
void
frontCrescent(])
A standing crescent shock front on the floor (y = 0): it leans back from a leading edge low at x, dir 1
racing right ")", -1 left "(". h tall, w thick at its widest; cols edge, body, back bright to dark; k dithers it out.
Implementation
void frontCrescent(
Painter p,
double x,
int dir,
double h,
double w,
List<int> cols, [
double k = 1.0,
]) {
if (h < 1.0 || w < 0.3 || k <= 0.0) return;
final ry = h * 0.8;
final cy = -h * 0.2;
final rx = math.max(2.0, h * 0.55);
final x0 = dir > 0 ? x - rx - w - 1.0 : x - 1.0;
final x1 = dir > 0 ? x + 1.0 : x + rx + w + 1.0;
p.shade(x0, -h - 1.0, x1, 0.0, (px, py, out) {
if (py > 0.0) return null;
final ey = (py - cy) / ry;
if (ey <= -1.0 || ey >= 1.0) return null;
final e2 = 1.0 - ey * ey;
final edge = rx * math.sqrt(e2) - rx;
final wt = w * math.pow(e2, 0.45);
final q = (edge - (px - x) * dir) / math.max(0.5, wt);
if (q < 0.0 || q > 1.0) return null;
out.c = q < 0.28 ? cols[0] : (q < 0.62 ? cols[1] : cols[2]);
out.a = k * (ey < -0.8 ? 0.7 : 1.0) * (q > 0.7 ? 1.25 - q * 0.8 : 1.0);
return null;
});
}