Skip to content

Instantly share code, notes, and snippets.

@AmaanC
Created January 3, 2013 22:17
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 AmaanC/4447896 to your computer and use it in GitHub Desktop.
Save AmaanC/4447896 to your computer and use it in GitHub Desktop.
A test to see if the HTML5 canvas element draws part of a big spritesheet on various devices. So far, it's worked for me on Chrome and Firefox, on both desktop, and Android. No luck on iOS.
<canvas id='test' width='400' height='400'></canvas>
<script>
var img = new Image();
img.src = 'http://fc01.deviantart.net/fs70/f/2012/187/b/b/ben_10__my_sprite_sheet_by_pyroman16-d56744g.png';
var ctx = document.getElementById('test').getContext('2d');
img.onload = function() {
ctx.drawImage(img, 0, 0, 300, 300, 0, 0, 300, 300);
};​
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment