Skip to content

Instantly share code, notes, and snippets.

@0xlkda
Created June 22, 2020 12:17
Show Gist options
  • Save 0xlkda/81be5bd6614fd8c9f91e86c7e25be90e to your computer and use it in GitHub Desktop.
Save 0xlkda/81be5bd6614fd8c9f91e86c7e25be90e to your computer and use it in GitHub Desktop.
const canvas = document.getElementById('canvas');
const ctx = canvas.getContext('2d');
const image = new Image(60, 150);
image.onload = drawImageActualSize;
image.src = 'https://mdn.mozillademos.org/files/5397/rhino.jpg';
function drawImageActualSize() {
canvas.width = this.naturalWidth;
canvas.height = this.naturalHeight;
ctx.drawImage(image, 0, 0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment