Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created March 6, 2023 00:28
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/2fda5ff300e1c1a8f3b27dd7ef957c42 to your computer and use it in GitHub Desktop.
Save parzibyte/2fda5ff300e1c1a8f3b27dd7ef957c42 to your computer and use it in GitHub Desktop.
const imagen = new Image();
imagen.src = "http://localhost/pusheen.png";
imagen.crossOrigin = "anonymous";
imagen.onload = () => {
let medidaMayor = imagen.width;
if (imagen.height > medidaMayor) {
medidaMayor = imagen.height;
}
$canvas.width = medidaMayor;
$canvas.height = medidaMayor;
context.drawImage(imagen, 0, 0);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment