|
1 |
| -/*! imagediff.js 1.0.1 |
| 1 | +/*! imagediff.js 1.0.2 |
2 | 2 | * (c) 2011 Carl Sutherland, Humble Software Development
|
3 | 3 | * imagediff.js is freely distributable under the MIT license.
|
4 | 4 | * Thanks to Jacob Thornton for the node/amd integration bits.
|
|
29 | 29 | imagediff, jasmine;
|
30 | 30 |
|
31 | 31 | // Creation
|
32 |
| - function getCanvas () { |
| 32 | + function getCanvas (width, height) { |
33 | 33 | var
|
34 | 34 | canvas = document.createElement('canvas');
|
| 35 | + if (width) canvas.width = width; |
| 36 | + if (height) canvas.height = height; |
35 | 37 | return canvas;
|
36 | 38 | }
|
37 | 39 | function getImageData (width, height) {
|
|
108 | 110 | width = canvas.width;
|
109 | 111 | return context.getImageData(0, 0, width, height);
|
110 | 112 | }
|
| 113 | + function toCanvas (object) { |
| 114 | + var |
| 115 | + data = toImageData(object), |
| 116 | + canvas = getCanvas(data.width, data.height), |
| 117 | + context = canvas.getContext('2d'); |
| 118 | + |
| 119 | + context.putImageData(data, 0, 0); |
| 120 | + return canvas; |
| 121 | + } |
111 | 122 |
|
112 | 123 |
|
113 | 124 | // ImageData Equality Operators
|
|
262 | 273 | context = canvas.getContext('2d');
|
263 | 274 | context.putImageData(diff, 0, 0);
|
264 | 275 |
|
265 |
| - a.appendChild(this.actual); |
266 |
| - b.appendChild(expected); |
| 276 | + a.appendChild(toCanvas(this.actual)); |
| 277 | + b.appendChild(toCanvas(expected)); |
267 | 278 | c.appendChild(canvas);
|
268 | 279 |
|
269 | 280 | div.appendChild(a);
|
|
0 commit comments