| return; | return; | ||||
| } | } | ||||
| this.__surface = surf; | this.__surface = surf; | ||||
| this.centerSurface(); | |||||
| this.center_surface(); | |||||
| this.render(); | this.render(); | ||||
| }).bind(this); | }).bind(this); | ||||
| GlobalEvents.listen("change_surface", handle_change_surface); | GlobalEvents.listen("change_surface", handle_change_surface); | ||||
| ResizeCanvasImg(canvas.clientWidth, canvas.clientHeight); // A forced "resize". | ResizeCanvasImg(canvas.clientWidth, canvas.clientHeight); // A forced "resize". | ||||
| input.mouseTargetElement = canvas; | input.mouseTargetElement = canvas; | ||||
| this.centerSurface(); | |||||
| this.center_surface(); | |||||
| } | } | ||||
| return this; | return this; | ||||
| } | } | ||||
| return this; | return this; | ||||
| } | } | ||||
| centerSurface(){ | |||||
| center_surface(){ | |||||
| if (canvas === null || this.__surface === null) | if (canvas === null || this.__surface === null) | ||||
| return; | return; | ||||
| // Get the contexts initial fillStyle. Don't want the render operation to override it. | // Get the contexts initial fillStyle. Don't want the render operation to override it. | ||||
| var fillStyle = context.fillStyle; | var fillStyle = context.fillStyle; | ||||
| var ie = this.__offset[0] + this.__surface.width; | |||||
| var je = this.__offset[1] + this.__surface.height; | |||||
| var scalemult = 1.0/this.__scale; | var scalemult = 1.0/this.__scale; | ||||
| // Clearing the context surface... | // Clearing the context surface... |