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/a4c3cdefed0912d5f836578d39ef35bc to your computer and use it in GitHub Desktop.
Save parzibyte/a4c3cdefed0912d5f836578d39ef35bc to your computer and use it in GitHub Desktop.
$canvas.addEventListener("mousemove", (evento) => {
if (!haComenzadoDibujo) {
return;
}
// El mouse se está moviendo y el usuario está presionando el botón, así que dibujamos todo
xAnterior = xActual;
yAnterior = yActual;
xActual = obtenerXReal(evento.clientX);
yActual = obtenerYReal(evento.clientY);
contexto.beginPath();
contexto.moveTo(xAnterior, yAnterior);
contexto.lineTo(xActual, yActual);
contexto.strokeStyle = COLOR;
contexto.lineWidth = GROSOR;
contexto.stroke();
contexto.closePath();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment