{
const terminate = observer(draw);
invalidation.then(terminate);
const context = DOM.context2d(width, height);
return context.canvas;
replay;
function draw(data) {
context.clearRect(0, 0, width, height);
if (data.progress > 0) {
context.fillStyle = "red";
context.fillRect(0, 0, data.progress, 2);
}
context.save();
context.translate(width / 2, height / 2);
context.globalAlpha = Math.exp(-data.progress / 200);
context.beginPath();
for (const c of data.links) {
context.moveTo(c.source.x, c.source.y);
context.lineTo(c.target.x, c.target.y);
}
context.lineWidth = 0.25;
context.stroke();
context.beginPath();
for (const c of data.nodes) {
context.moveTo(c.x, c.y);
context.arc(c.x, c.y, 1.5, 0, tau);
}
context.fillStyle = "#000";
context.fill();
context.restore();
}
}