canvasAnimationTimed = {
let circles = [];
let canvas = html`<canvas width=400 height=400 >`;
let ctx = canvas.getContext("2d");
canvas.onmousedown = canvas.onmousemove = function(e) {
if (e.buttons) circles.push([e.offsetX, e.offsetY, 30]);
};
function draw() {
ctx.fillStyle = 'lightgray';
ctx.fillRect(0, 0, 400, 400);
ctx.fillStyle = 'white';
ctx.strokeStyle = 'black';
let newCircles = [];
for (let [x, y, r] of circles) {
ctx.beginPath();
ctx.arc(x, y, r, 0, Math.PI * 2);
ctx.fill();
ctx.stroke();
r = r * 0.99;
if (r > 1) newCircles.push([x, y, r]);
}
circles = newCircles;
}
let id = setInterval(draw, 1000 / 60);
invalidation.then(() => clearInterval(id));
return canvas;
}