lines = {
const minLineLength = 1 / linesPerRow;
const maxLineLength = Math.max(minLineLength, growthScale);
const gap = minLineLength * 5 * lineGap;
const easeFn = d3[ease];
const firstSet = math
.linspace(linesPerRow, true)
.map((u) => [
u,
0,
u,
math.clamp01(math.lerp(minLineLength, maxLineLength, easeFn(u)))
]);
let lines = [firstSet];
let canAddMore = true;
while (canAddMore) {
const lastLine = lines[lines.length - 1];
const nextLine = lastLine
.map(([u1, v1, u2, v2], i) => {
const currentLength = v2 - v1;
if (v2 + currentLength + gap < 1) {
return [u1, v1 + gap + currentLength, u2, v2 + gap + currentLength];
}
})
.filter(Boolean);
lines.push(nextLine);
if (nextLine.length < Math.round(linesPerRow * 0.33)) {
canAddMore = false;
}
}
lines = lines.flat();
return lines.map(([u1, v1, u2, v2]) => [u1, 1 - v1, u2, 1 - v2]);
}