koch_flake = function(n) {
let [f0, f1, f2, f3] = curveIFS.affine_function_list.map((af) => af.f);
let step = (pts) =>
pts
.map(f0)
.slice(0, -1)
.concat(pts.map(f1).slice(0, -1))
.concat(pts.map(f2).slice(0, -1))
.concat(pts.map(f3));
let pts = [
[-Math.sqrt(3) / 2, 1 / 2],
[Math.sqrt(3) / 2, 1 / 2]
];
d3.range(n).map(() => (pts = step(pts)));
let pts2 = pts.map(
rotate((-2 * Math.PI) / 3, [Math.sqrt(3) / 2, 1 / 2]).compose(
shift([Math.sqrt(3), 0])
).f
);
let pts3 = pts.map(
rotate((2 * Math.PI) / 3, [0, -1]).compose(
shift([Math.sqrt(3) / 2, -3 / 2])
).f
);
return pts.slice(0, -1).concat(pts2).concat(pts3);
}