mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-01 02:38:43 -05:00
Improve compareColors() helper.
This commit is contained in:
parent
0b42d594de
commit
b512532d23
2 changed files with 10 additions and 8 deletions
|
@ -103,11 +103,15 @@ function compareRectangles(rect1, rect2, 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', precision);
|
||||
color1 = color1 && new Color(color1);
|
||||
color2 = color2 && new Color(color2);
|
||||
if (color1 && color2) {
|
||||
equals(color1.type, color2.type, (message || '') + ' type');
|
||||
compareArrays(color1.components, color2.components,
|
||||
(message || '') + ' components', precision);
|
||||
} else {
|
||||
equals(color1, color2, message);
|
||||
}
|
||||
}
|
||||
|
||||
function compareStyles(style, style2, checkIdentity) {
|
||||
|
|
|
@ -161,9 +161,7 @@ test('setting group styles 2', function() {
|
|||
|
||||
// By appending a path with a different fillcolor,
|
||||
// the group's fillColor should return undefined:
|
||||
equals(function() {
|
||||
return group.fillColor;
|
||||
}, undefined);
|
||||
equals(group.fillColor, undefined, 'group.fillColor');
|
||||
|
||||
// But, both paths have a red strokeColor, so:
|
||||
compareColors(group.strokeColor, 'red', 'group.strokeColor');
|
||||
|
|
Loading…
Reference in a new issue