Published
Edited
Jan 28, 2021
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
{
const height = 200;

// canvas setup
const context = DOM.context2d(width, height, 1);

// animation loop
let frame = 0,
x = 0,
y = 0;

while (true) {
frame += 1;

// position
x = width;
y = height / 2;

// movement
x += frame * 4;
y += Math.cos(frame / 4) * 40;

// draw
context.fillText('🚲', x % width, y);

// observable animation pattern
yield context.canvas;
}
}
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