<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);
colores= ["blue","red","green"]
function exibirAlerta(evento){
var x = evento.pageX - pantalla.offsetLeft;
var y = evento.pageY - pantalla.offsetTop;
console.log(evento);
alert(x + ","+y)
}
pincel.fillStyle = colores[0];
function dibujarCirculo(evento){
var x = evento.pageX - pantalla.offsetLeft;
var y = evento.pageY - pantalla.offsetTop;
pincel.beginPath();
pincel.arc(x,y,10,0,2*3.14); pincel.fill();
}
pantalla.onclick = dibujarCirculo;
i=1
function alterarColor() {
pincel.fillStyle=colores[i]
i++
if(i==3){i=0}
return false;
}
pantalla.oncontextmenu = alterarColor;
</script>