Public
Edited
Jan 1, 2024
3 forks
Insert cell
Insert cell
Insert cell
{
replay;

const width = 600,
height = 200,
location = cm.vec(width / 2, height / 2),
velocity = cm.vec(1, 2.3);

function update(app) {
location.add(velocity);
if (!location.inX(app.prop("width"))) velocity.negX();
if (!location.inY(app.prop("height"))) velocity.negY();
app.append(cm.clear, { fill: cm.rgb(255) });
app.append(cm.circle, {
x: location.x,
y: location.y,
r: 16,
stroke: cm.rgb(0),
fill: cm.rgb(175)
});
}

function dispose(app) {
invalidation.then(() => app.dispose());
}

function frame(app) {
app.node().style.border = "solid #000 1px";
}

return cm
.app({ width, height })
.on("update", update)
.call(dispose)
.call(frame)
.start()
.node();
}
Insert cell
cm = require("@charming-art/charming@0.0.6")
Insert cell
import { quote } from "@pearmini/charming-shared"
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more