//select the canvas // https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API var canvas = document.querySelector('canvas'); //get the drawing context var ctx = canvas.getContext('2d'); var X = 0; function update(dt){ //Clear: ctx.clearRect(0, 0, canvas.width, canvas.height); //Draw square ctx.fillStyle = "rgb(200,0,0)"; ctx.arc(100,75,50,0,2*Math.PI); ctx.fill() X+=1; //Make it loop window.requestAnimationFrame(update); } update()