function drawIteration(lines, n, t, context) {
if (n <= 1) return lines;
const c = 100 + (points.length - 1 - n) * points.length;
const color = `rgb(${c}, ${c}, ${c})`;
const p1s = [];
for (let l of lines) {
circle([...l[0], 3], context, { color });
const p1 = pointOnLine(l, t);
circle([...p1, 3], context, { color });
p1s.push(p1);
}
circle([...lines[lines.length - 1][1], 3], context, { color });
const nextLines = [];
for (let i = 0; i < p1s.length - 1; ++i) {
const nl = line(p1s[i], p1s[i + 1], context, { color });
nextLines.push(nl);
}
return drawIteration(nextLines, n - 1, t, context);
}