data = Array.from({ length: numPoints }).map(() => {
const p1 = [rnd(), rnd()]
const p2 = [rnd(), rnd()]
const cp1 = [rnd(), rnd()]
const cp2 = [rnd(), rnd()]
const precision = d3.randomUniform(0.0001, 0.1)();
const path = [p1];
for (let t = precision; t < 1 - precision / 2; t += precision) {
const x = (1 - t) ** 3 * p1[0] +
3 * (1 - t) ** 2 * t * cp1[0] +
3 * (1 - t) * t ** 2 * cp2[0] +
t ** 3 * p2[0];
const y = (1 - t) ** 3 * p1[1] +
3 * (1 - t) ** 2 * t * cp1[1] +
3 * (1 - t) * t ** 2 * cp2[1] +
t ** 3 * p2[1];
path.push([x, y]);
}
path.push(p2);
return { p1, p2, path }
})