Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save lnanek/905029 to your computer and use it in GitHub Desktop.
Save lnanek/905029 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<style>
/* doesn't work */
img, canvas {
image-rendering: optimizeQuality;
}
canvas {
width: 50px;
height: 50px;
}
</style>
</head>
<script>
function onload() {
var img = document.getElementsByTagName('img')[0];
var canvas = document.getElementsByTagName('canvas')[0];
var ctx = canvas.getContext('2d');
ctx.drawImage(img, 0, 0, 300, 300, 0, 0, 300, 300);
}
</script>
<body onload="onload()">
<img src="http://www.droiddog.com/wp-content/uploads/2011/04/google-icon.png">
<canvas width="300" height="300">
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment