Created
October 2, 2012 22:29
-
-
Save antonmills/3823730 to your computer and use it in GitHub Desktop.
compiled JS from: https://gist.github.com/3818959
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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