{
const mover = {
location: cm.vec(),
velocity: cm.vec(),
acceleration: cm.vec(),
mass: 1
};
function update(app) {
app.append(cm.clear, { fill: cm.rgb(255) });
app
.datum(mover)
.process(cm.each, toMouse)
.process(cm.each, move)
.process(cm.each, checkEdges)
.append(cm.rect, {
x: (d) => d.location.x,
y: (d) => d.location.y,
width: 30,
height: 10,
fill: cm.rgb(175),
stroke: cm.rgb(0),
rotate: (d) => d.velocity.angle()
});
}
function dispose(app) {
invalidation.then(() => app.dispose());
}
return cm
.app({ width: 600, height: 200 })
.on("update", update)
.call(dispose)
.call(frame)
.start()
.node();
}