Public
Edited
May 10
Insert cell
Insert cell
// Nome da célula: animacao
{
const canvas = DOM.canvas(400, 200);
const ctx = canvas.getContext("2d");
let t = 0;

function desenhar() {
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.beginPath();
for (let x = 0; x < canvas.width; x++) {
const y = 100 + 50 * Math.sin((x + t) * 0.05);
ctx.lineTo(x, y);
}
ctx.strokeStyle = "blue";
ctx.lineWidth = 2;
ctx.stroke();
t += 2;
requestAnimationFrame(desenhar);
}

desenhar();
return canvas;
}

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