anim = {
let N = 1000;
let dx = 1 / N;
let pts = d3
.range(0, 1, dx / 2)
.map((x) => [x, Math.cos(n * global.t) * Math.sin(Math.PI * n * x)]);
while (run) {
await Promises.delay(20);
global.t = global.t + 0.05;
pts = d3
.range(0, 1, dx / 2)
.map((x) => [x, Math.cos(n * global.t) * Math.sin(Math.PI * n * x)]);
yield Plot.plot({
y: { domain: [-1.1, 1.1] },
marks: [
Plot.line(pts),
Plot.axisX({ y: 0 }),
Plot.ruleX([0]),
Plot.ruleY([0])
]
});
}
yield Plot.plot({
y: { domain: [-1.1, 1.1] },
marks: [
Plot.line(pts),
Plot.axisX({ y: 0 }),
Plot.ruleX([0]),
Plot.ruleY([0])
]
});
}