mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2024-12-29 09:22:22 -05:00
Keep code on 80 chars per line
This commit is contained in:
parent
022a4c9c81
commit
88c4275fa3
1 changed files with 20 additions and 13 deletions
|
@ -201,10 +201,10 @@ var compareImageData = function(imageData1, imageData2, tolerance, diffDetail) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
resemble(imageData1)
|
resemble(imageData1)
|
||||||
.compareTo(imageData2)
|
.compareTo(imageData2)
|
||||||
.ignoreAntialiasing()
|
.ignoreAntialiasing()
|
||||||
// When working with imageData, this call is synchronous:
|
// When working with imageData, this call is synchronous:
|
||||||
.onComplete(function(data) { result = data; });
|
.onComplete(function(data) { result = data; });
|
||||||
// Compare with tolerance in percentage...
|
// Compare with tolerance in percentage...
|
||||||
var fixed = tolerance < 1 ? ((1 / tolerance) + '').length - 1 : 0,
|
var fixed = tolerance < 1 ? ((1 / tolerance) + '').length - 1 : 0,
|
||||||
identical = result ? 100 - result.misMatchPercentage : 0,
|
identical = result ? 100 - result.misMatchPercentage : 0,
|
||||||
|
@ -260,12 +260,12 @@ var comparePixels = function(actual, expected, message, options) {
|
||||||
// bounds of both items before rasterizing.
|
// bounds of both items before rasterizing.
|
||||||
var resolution = options.resolution || 72,
|
var resolution = options.resolution || 72,
|
||||||
actualBounds = actual.strokeBounds,
|
actualBounds = actual.strokeBounds,
|
||||||
expecedBounds = expected.strokeBounds,
|
expectedBounds = expected.strokeBounds,
|
||||||
bounds = actualBounds.isEmpty()
|
bounds = actualBounds.isEmpty()
|
||||||
? expecedBounds
|
? expectedBounds
|
||||||
: expecedBounds.isEmpty()
|
: expectedBounds.isEmpty()
|
||||||
? actualBounds
|
? actualBounds
|
||||||
: actualBounds.unite(expecedBounds);
|
: actualBounds.unite(expectedBounds);
|
||||||
if (bounds.isEmpty()) {
|
if (bounds.isEmpty()) {
|
||||||
QUnit.equal('empty', 'empty', message);
|
QUnit.equal('empty', 'empty', message);
|
||||||
return;
|
return;
|
||||||
|
@ -288,10 +288,15 @@ var comparePixels = function(actual, expected, message, options) {
|
||||||
} else {
|
} else {
|
||||||
// Compare the two rasterized items.
|
// Compare the two rasterized items.
|
||||||
var detail = actual instanceof PathItem && expected instanceof PathItem
|
var detail = actual instanceof PathItem && expected instanceof PathItem
|
||||||
? '\nExpected:\n' + expected.pathData + '\nActual:\n' + actual.pathData
|
? '\nExpected:\n' + expected.pathData +
|
||||||
|
'\nActual:\n' + actual.pathData
|
||||||
: '';
|
: '';
|
||||||
compareImageData(actualRaster.getImageData(),
|
compareImageData(
|
||||||
expectedRaster.getImageData(), options.tolerance, detail);
|
actualRaster.getImageData(),
|
||||||
|
expectedRaster.getImageData(),
|
||||||
|
options.tolerance,
|
||||||
|
detail
|
||||||
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -340,7 +345,8 @@ var compareItem = function(actual, expected, message, options, properties) {
|
||||||
* @param {function} actualCallback the function producing the actual result
|
* @param {function} actualCallback the function producing the actual result
|
||||||
* @param {number} tolerance between 0 and 1
|
* @param {number} tolerance between 0 and 1
|
||||||
*/
|
*/
|
||||||
var compareCanvas = function(width, height, expectedCallback, actualCallback, tolerance) {
|
var compareCanvas = function(width, height, expectedCallback, actualCallback,
|
||||||
|
tolerance) {
|
||||||
function getImageData(width, height, callback) {
|
function getImageData(width, height, callback) {
|
||||||
var canvas = document.createElement('canvas');
|
var canvas = document.createElement('canvas');
|
||||||
canvas.width = width;
|
canvas.width = width;
|
||||||
|
@ -348,7 +354,8 @@ var compareCanvas = function(width, height, expectedCallback, actualCallback, to
|
||||||
var project = new Project(canvas);
|
var project = new Project(canvas);
|
||||||
callback();
|
callback();
|
||||||
project.view.update();
|
project.view.update();
|
||||||
var imageData = canvas.getContext('2d').getImageData(0, 0, width, height);
|
var context = canvas.getContext('2d');
|
||||||
|
var imageData = context.getImageData(0, 0, width, height);
|
||||||
canvas.remove();
|
canvas.remove();
|
||||||
project.remove();
|
project.remove();
|
||||||
return imageData;
|
return imageData;
|
||||||
|
|
Loading…
Reference in a new issue