Skip to content

Instantly share code, notes, and snippets.

@holysheep
Created November 3, 2015 19:35
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 holysheep/2f0f446be6e751b92b0e to your computer and use it in GitHub Desktop.
Save holysheep/2f0f446be6e751b92b0e to your computer and use it in GitHub Desktop.
<canvas id="canvas"></canvas>
<script type="text/javascript">
var canvas = document.getElementById('canvas');
var context = canvas.getContext('2d');
Image img1 = new Image();
Image img2 = new Image();
img1.onload = function() {
canvas.width = img1.width;
canvas.height = img1.height;
img2.src = 'imgfile2.png';
};
img2.onload = function() {
context.drawImage(img1, 0, 0);
context.drawImage(img2, 0, 0);
};
img1.src = 'imgfile1.png';
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment