Published
Edited
May 26, 2022
Insert cell
Insert cell
Insert cell
Insert cell
mutable frameCount = 0
Insert cell
mutable frameCountPostInc = 0
Insert cell
{
const context = DOM.context2d(width, height);
while (true) {
mutable frameCount = frameCount + 1;
mutable frameCountPostInc++; // this increments by 2 for some reason
const x =
((Math.sin(Date.now() / 1000) + 1) / 2) * (width - 2 * radius) + radius;
context.clearRect(0, 0, width, height);
context.beginPath();
context.arc(x, height / 2, radius, 0, 2 * Math.PI);
context.fill();
yield context.canvas;
}
}
Insert cell
height = 33
Insert cell
radius = height / 2 - 5
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