ledgerDashed function
path cut into an SVG dash pattern (on, off, ...), the pattern running
on along the whole path from its start.
Implementation
Path ledgerDashed(Path path, List<double> pattern) {
final out = Path();
for (final metric in path.computeMetrics()) {
var d = 0.0;
var i = 0;
while (d < metric.length) {
final len = pattern[i % pattern.length];
if (i.isEven) {
out.addPath(
metric.extractPath(d, math.min(d + len, metric.length)),
Offset.zero,
);
}
d += len;
i++;
}
}
return out;
}