mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-01 02:38:43 -05:00
Fix issue with precision and PathItem#getAverageColor() tests.
This commit is contained in:
parent
10c0a44940
commit
495eef2ee4
2 changed files with 6 additions and 6 deletions
|
@ -64,10 +64,10 @@ function compareNumbers(number1, number2, message, precision) {
|
|||
Format.number(number2, precision), message);
|
||||
}
|
||||
|
||||
function compareArrays(array1, array2, message) {
|
||||
function compareArrays(array1, array2, message, precision) {
|
||||
function format(array) {
|
||||
return Base.each(array, function(value, index) {
|
||||
this[index] = Format.number(value);
|
||||
this[index] = Format.number(value, precision);
|
||||
}, []).toString();
|
||||
}
|
||||
equals(format(array1), format(array2), message);
|
||||
|
@ -85,12 +85,12 @@ function compareRectangles(rect1, rect2, message) {
|
|||
compareNumbers(rect1.height, rect2.height, (message || '') + ' height');
|
||||
}
|
||||
|
||||
function compareColors(color1, color2, message) {
|
||||
function compareColors(color1, color2, message, precision) {
|
||||
color1 = new Color(color1);
|
||||
color2 = new Color(color2);
|
||||
equals(color1.type, color2.type, (message || '') + ' type');
|
||||
compareArrays(color1.components, color2.components,
|
||||
(message || '') + ' components');
|
||||
(message || '') + ' components', precision);
|
||||
}
|
||||
|
||||
function comparePathStyles(style, style2, checkIdentity) {
|
||||
|
|
|
@ -131,7 +131,7 @@ test('Raster#getAverageColor(path)', function() {
|
|||
});
|
||||
var raster = paper.project.activeLayer.rasterize();
|
||||
path.scale(0.9);
|
||||
compareColors(raster.getAverageColor(path), new Color(1, 0, 0));
|
||||
compareColors(raster.getAverageColor(path), new Color(1, 0, 0), null, 3);
|
||||
});
|
||||
|
||||
test('Raster#getAverageColor(path) with compound path', function() {
|
||||
|
@ -153,5 +153,5 @@ test('Raster#getAverageColor(path) with compound path', function() {
|
|||
var raster = paper.project.activeLayer.rasterize();
|
||||
path.scale(0.9);
|
||||
path2.scale(1.1);
|
||||
compareColors(raster.getAverageColor(compoundPath), new Color(1, 0, 0));
|
||||
compareColors(raster.getAverageColor(compoundPath), new Color(1, 0, 0), null, 3);
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue