chart = {
const context = DOM.context2d(width, height);
const set = new Uint8Array(delaunay.points.length / 2);
const heap = new FlatQueue();
const tree = [];
function renderEdges(edges) {
for (const [i, j] of edges) {
context.moveTo(points[i * 2], points[i * 2 + 1]);
context.lineTo(points[j * 2], points[j * 2 + 1]);
}
}
function render() {
context.clearRect(0, 0, width, height);
context.beginPath(), renderEdges(heap.ids), context.strokeStyle = "#ccc", context.stroke();
context.beginPath(), renderEdges(tree), context.strokeStyle = "#f00", context.stroke();
context.beginPath(), delaunay.renderPoints(context), context.fill();
return context.canvas;
}
set[0] = 1;
for (const i of delaunay.neighbors(0)) {
heap.push([0, i], distance2(0, i));
}
let edge;
while (edge = heap.pop()) {
const [i, j] = edge;
yield render();
if (set[j]) continue;
set[j] = 1;
tree.push(edge);
for (const k of delaunay.neighbors(j)) {
if (set[k]) continue;
heap.push([j, k], distance2(j, k));
}
}
yield render();
replay;
}