| OLD | NEW |
| (Empty) | |
| 1 define([ 'util/ensureCallback' ], function (ensureCallback) { |
| 2 var IMAGE_SRC = 'assets/html5-logo.png'; |
| 3 |
| 4 function ImageSource(img) { |
| 5 this.img = img; |
| 6 |
| 7 this.frameInfo = { |
| 8 x: 0, |
| 9 y: 0, |
| 10 width: img.width, |
| 11 height: img.height, |
| 12 image: img, |
| 13 sheetImage: img |
| 14 }; |
| 15 } |
| 16 |
| 17 ImageSource.prototype.getImage = function getImage(frameIndex) { |
| 18 return this.img; |
| 19 }; |
| 20 |
| 21 ImageSource.prototype.drawToCanvas = function drawToCanvas(context, dx, dy,
frameIndex) { |
| 22 context.drawImage(this.img, dx, dy); |
| 23 }; |
| 24 |
| 25 ImageSource.prototype.getFrameInfo = function getFrameInfo(frameIndex) { |
| 26 return this.frameInfo; |
| 27 }; |
| 28 |
| 29 return function image(callback) { |
| 30 callback = ensureCallback(callback); |
| 31 |
| 32 var img = new window.Image(); |
| 33 img.onload = function () { |
| 34 var imageSource = new ImageSource(img); |
| 35 callback(null, imageSource); |
| 36 }; |
| 37 img.src = IMAGE_SRC; |
| 38 }; |
| 39 }); |
| OLD | NEW |