<canvas width="600" height="400"></canvas>
<script>
var pantalla = document.querySelector("canvas")
var pincel = pantalla.getContext("2d")
pincel.fillStyle = "#333"
pincel.fillRect(0,0,600,400)
function circulo(x,y,radio){
pincel.fillStyle = "blue"
pincel.beginPath()
pincel.arc(x,y,radio,0,2*Math.PI)
pincel.fill()
}
function limpiarPantalla(){
pincel.clearRect(0,0,600,400)
}
var x = 0
function actualizarPantalla(){
limpiarPantalla()
setInterval(circulo(x,20,10))
setInterval(circulo(x,-20,10))
x++
}
setInterval(actualizarPantalla,5)
</script>