const pantalla = document.querySelector("canvas"); const pincel = pantalla.getContext("2d"); pincel.fillStyle = "lightgray"; pincel.fillRect(0, 0, 600, 400);
const colores = ["blue", "red", "green"] let i = 0;
// function escribirAlerta(evento){ // let x = evento.pageX; pantalla.offsetLeft; // let y = evento.pageY; pantalla.offsetTop; // console.log(evento); // alert(x+","+y); // }
function dibularCirculo(evento){ let x = evento.pageX; pantalla.offsetLeft; let y = evento.pageY; pantalla.offsetTop; pincel.fillStyle = colores[i]; pincel.beginPath(); pincel.arc(x,y,10,0,2*3.14); pincel.fill(); console.log(x+","+y) }
//pantalla.onclick = escribirAlerta; pantalla.onclick = dibularCirculo;
function alterarColor() { i++; if(i>=colores.length){ i=0 } return false; }
pantalla.oncontextmenu = alterarColor;