Skip to content

Instantly share code, notes, and snippets.

@antonmills
Created October 2, 2012 22:29
Show Gist options
  • Select an option

  • Save antonmills/3823730 to your computer and use it in GitHub Desktop.

Select an option

Save antonmills/3823730 to your computer and use it in GitHub Desktop.
var MapController = (function () {
function MapController(canvas, imagePath) {
this.canvas = canvas;
this.imagePath = imagePath;
this._canvas = canvas;
this._canvas.width = 960;
this._canvas.height = 640;
this._ctx = this._canvas.getContext('2d');
this._that = this;
this._image = new Image();
this._image.onload = (function (parent) {
return function () {
parent.imageReady();
}
})(this);
this._image.src = imagePath;
}
MapController.prototype.imageReady = function () {
console.log("here");
console.log("image w:" + this._image.width + " h:" + this._image.height);
this._ctx.drawImage(this._image, 0, 0, 960, 640);
};
MapController.prototype.sample = function () {
this._ctx.strokeStyle = "#ff0000";
this._ctx.beginPath();
this._ctx.moveTo(25, 25);
this._ctx.lineTo(105, 25);
this._ctx.lineTo(25, 105);
this._ctx.fill();
};
return MapController;
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment