Fix issue with precision and PathItem#getAverageColor() tests.

This commit is contained in:
Jürg Lehni 2013-04-09 08:40:41 -07:00
parent 10c0a44940
commit 495eef2ee4
2 changed files with 6 additions and 6 deletions

View file

@ -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) {

View file

@ -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);
});