<canvas width="600" height="400"></canvas>
<script>
var tela = document.querySelector("canvas");
var pincel = tela.getContext("2d");
pincel.fillStyle = "lightgrey";
pincel.fillRect(0,0,600,400);
function desenhaCirculo(x,y,raio){
pincel.fillStyle = "pink";
pincel.beginPath();
pincel.arc(x, y, raio, 0, 2 * Math.PI);
pincel.fill();
}
function apagaFundo(){
pincel.clearRect(0,0,600,400)
}
var x = 20
function animaBolinha(){
apagaFundo();
desenhaCirculo(x,20,10);
x++
if(x >= 600){
x = 0
}
}
setInterval(animaBolinha,1)
</script>