Published
Edited
May 10, 2020
1 star
Insert cell
Insert cell
Insert cell
canvas = {
var ctx;
if (this) {
ctx = this.getContext('2d');
} else {
ctx = DOM.context2d(width, height);
ctx.fillStyle = "black";
ctx.canvas.onmousemove = (e) => {
mutable mousePos = {x: e.offsetX, y: e.offsetY};
}
}
while (true) {
const x = Math.sin(Date.now() / 400) * (width/4.0 - 2 * radius) + radius;
ctx.clearRect(0, 0, width, height);
ctx.beginPath();
ctx.arc(mousePos.x + x, mousePos.y, 20, 0, 2 * Math.PI);
ctx.fill();
yield ctx.canvas;
}
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
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