Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created September 8, 2021 15:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/fb91e32a1d577997866f285c414c158b to your computer and use it in GitHub Desktop.
Save parzibyte/fb91e32a1d577997866f285c414c158b to your computer and use it in GitHub Desktop.
$canvas.addEventListener("mousedown", evento => {
// En este evento solo se ha iniciado el clic, así que dibujamos un punto
xAnterior = xActual;
yAnterior = yActual;
xActual = obtenerXReal(evento.clientX);
yActual = obtenerYReal(evento.clientY);
contexto.beginPath();
contexto.fillStyle = COLOR;
contexto.fillRect(xActual, yActual, GROSOR, GROSOR);
contexto.closePath();
// Y establecemos la bandera
haComenzadoDibujo = true;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment