{
const width = 600,
height = 200,
amplitude = 100,
period = 120;
function clear(app) {
app.append(cm.clear, { fill: cm.rgb(255) });
}
function draw(app) {
const frameCount = app.prop("frameCount");
const x = amplitude * Math.cos((cm.TWO_PI * frameCount) / period);
const y = 0;
const group = app.append(cm.group, {
x: width / 2,
y: height / 2
});
group.append(cm.link, { x: 0, y: 0, x1: x, y1: y });
group.append(cm.circle, { x, y, r: 10, fill: "black" });
}
function dispose(app) {
invalidation.then(() => app.dispose());
}
return cm
.app({ width, height })
.on("update", clear)
.on("update", draw)
.call(dispose)
.call(frame)
.start()
.node();
}