Created
November 20, 2022 00:03
-
-
Save greggman/8a8c1fda421809ec50b50eaa82e21faf to your computer and use it in GitHub Desktop.
An image's width and height do not affect its backingstore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pre { margin: 0; } | |
canvas { background: #ddd; border: 1px solid black; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<canvas></canvas> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function main() { | |
const img = new Image(); | |
document.body.appendChild(img); | |
img.src = 'https://greggman.github.io/placeholders/images/200x100.jpg' | |
await img.decode(); | |
img.width = 22; | |
img.height = 11; | |
ctx = document.querySelector('canvas').getContext('2d'); | |
ctx.drawImage(img, 0, 0); | |
}; | |
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"name":"An image's width and height do not affect its backingstore","settings":{},"filenames":["index.html","index.css","index.js"]} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment