canvas = {
const context = DOM.context2d(width, height);
let polygons = Array.from(new d3.Delaunay(points).voronoi([0, 0, width, height]).cellPolygons());
context.globalAlpha = 0.15;
context.lineWidth = 0.45;
while (polygons.length) {
context.beginPath();
polygons = polygons.filter(P => {
context.moveTo(...P[0]);
for (let j = 1, m = P.length; j < m; ++j) context.lineTo(...P[j]);
context.closePath();
const p0 = P.shift();
const p1 = P[0];
const dx = p1[0] - p0[0];
const dy = p1[1] - p0[1];
const l = Math.hypot(dx, dy);
const t = Math.min(0.5, 4 / l);
const p2 = [p0[0] + dx * t - dy / (l * 2), p0[1] + dy * t + dx / (l * 2)];
if (Math.hypot(p2[0] - p1[0], p2[1] - p1[1]) > 1) P.push(p2);
return -d3.polygonArea(P) > 1;
});
context.stroke();
yield context.canvas;
}
}