<canvas width="600" height="400"> </canvas>
<script>
var pantalla = document.querySelector("canvas");
var pincel = pantalla.getContext("2d");
pincel.fillStyle = "grey";
pincel.fillRect(0,0,600,400);
function dibujarCirculo(evento){
var x = evento.pageX - pantalla.offsetLeft;
var y = evento.pageY - pantalla.offsetTop;
pincel.fillStyle = color[i];
//coloco el parámetro color[i], inicialianzo a i=0=blue
pincel.beginPath();
pincel.arc(x,y,10,0,2*3.14);
pincel.fill();
console.log(x + "," + y);
}
pantalla.onclick = dibujarCirculo;
function alterarColor() {
for (i = 0; i < color.length; i++){
dibujarCirculo()
}
return false; //menú contextual padrón de `canvas` no sea exhibido
}
pantalla.oncontextmenu = alterarColor;
var color = ["blue","red","green"];
var i = 0
alterarColor();
</script>;