Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / chrome / test / data / third_party / spaceport / js / sprites / sources / image.js
blob146022836606b84d808b6b00aa1f86bc0665534d
1 define([ 'util/ensureCallback' ], function (ensureCallback) {
2 var IMAGE_SRC = 'assets/html5-logo.png';
4 function ImageSource(img) {
5 this.img = img;
7 this.frameInfo = {
8 x: 0,
9 y: 0,
10 width: img.width,
11 height: img.height,
12 image: img,
13 sheetImage: img
17 ImageSource.prototype.getImage = function getImage(frameIndex) {
18 return this.img;
21 ImageSource.prototype.drawToCanvas = function drawToCanvas(context, dx, dy, frameIndex) {
22 context.drawImage(this.img, dx, dy);
25 ImageSource.prototype.getFrameInfo = function getFrameInfo(frameIndex) {
26 return this.frameInfo;
29 return function image(callback) {
30 callback = ensureCallback(callback);
32 var img = new window.Image();
33 img.onload = function () {
34 var imageSource = new ImageSource(img);
35 callback(null, imageSource);
37 img.src = IMAGE_SRC;
39 });