<meta charset="UFT-8">
<canvas width="600" height="400"></canvas>
<script>
var tela = document.querySelector('canvas');
var pincel = tela.getContext('2d');
pincel.fillStyle = 'grey';
pincel.fillRect(0, 0, 600, 400);
function circulo(x, y, r) {
pincel.fillStyle = 'red';
pincel.beginPath();
pincel.arc(x, y, r, 0, 2 * Math.PI);
pincel.fill();
}
function limpa() {
pincel.clearRect(0, 0, 600, 400);
}
var x = 20;
function atualizaTela() {
limpa();
circulo(x, 20, 10);
x++;
if( x == 600) {
x = 0;
}
}
setInterval(atualizaTela, 1);
</script>