Skip to content

Instantly share code, notes, and snippets.

@caubry
Last active January 3, 2016 12:39
Show Gist options
  • Save caubry/8463948 to your computer and use it in GitHub Desktop.
Save caubry/8463948 to your computer and use it in GitHub Desktop.
var canvas = null;
var ctx = null;
var img = null;
var onImageLoad = function(){
console.log("Image Loaded");
ctx.drawImage(img, 192, 192);
canvas.appendChild(img);
};
var setup = function() {
var body = document.getElementById("body");
canvas = document.createElement("canvas");
ctx = canvas.getContext('2d');
canvas.setAttribute('width', 500);
canvas.setAttribute('height', 700);
body.appendChild(canvas);
img = new Image();
img.onload = onImageLoad;
img.src = "/media/img/gamedev/ralphyrobot.png";
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment