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