![]( )
<canvas width="600" height="400"> </canvas>
<script>
var colores = ["blue", "red", "green"];
var pantalla = document.querySelector("canvas");
var pincel = pantalla.getContext("2d");
pincel.fillStyle = "grey";
pincel.fillRect(0,0,600,400);
var c = 0;
function dibujarCirculo(evento){
var x = evento.pageX - pantalla.offsetLeft;
var y = evento.pageY - pantalla.offsetTop;
pincel.fillStyle = colores[c];
c = c+1;
if(c == 3){
c = 0;
}
pincel.beginPath();
pincel.arc(x,y,10,0,2*3.14);
pincel.fill();
console.log(x + "," + y);
}
pantalla.onclick = dibujarCirculo;
function alterarColor() {
alert("Funcionó");
return false;
}
pantalla.oncontextmenu = alterarColor;
</script>