2011-05-05 08:38:20 -04:00
|
|
|
// Let's be strict
|
|
|
|
equals = strictEqual;
|
|
|
|
|
2011-02-13 10:48:20 -05:00
|
|
|
function compareNumbers(number1, number2, message) {
|
2011-05-03 03:55:01 -04:00
|
|
|
if (number1 !== 0)
|
2011-03-08 20:25:38 -05:00
|
|
|
number1 = Math.round(number1 * 100) / 100;
|
2011-05-03 03:55:01 -04:00
|
|
|
if (number2 !== 0)
|
2011-03-08 20:25:38 -05:00
|
|
|
number2 = Math.round(number2 * 100) / 100;
|
|
|
|
equals(number1, number2, message);
|
2011-02-13 10:48:20 -05:00
|
|
|
}
|
|
|
|
|
2011-02-07 13:28:09 -05:00
|
|
|
function comparePoints(point1, point2, message) {
|
2011-05-05 08:05:39 -04:00
|
|
|
compareNumbers(point1.x, point2.x,
|
|
|
|
(message || '') + ' x');
|
|
|
|
compareNumbers(point1.y, point2.y,
|
|
|
|
(message || '') + ' y');
|
2011-02-13 09:35:48 -05:00
|
|
|
}
|
|
|
|
|
2011-02-13 10:48:20 -05:00
|
|
|
function compareRectangles(rect1, rect2, message) {
|
2011-05-05 08:05:39 -04:00
|
|
|
compareNumbers(rect1.x, rect2.x,
|
|
|
|
(message || '') + ' x');
|
|
|
|
compareNumbers(rect1.y, rect2.y,
|
|
|
|
(message || '') + ' y');
|
2011-02-13 10:48:20 -05:00
|
|
|
compareNumbers(rect1.width, rect2.width,
|
2011-05-05 08:05:39 -04:00
|
|
|
(message || '') + ' width');
|
2011-02-13 10:48:20 -05:00
|
|
|
compareNumbers(rect1.height, rect2.height,
|
2011-05-05 08:05:39 -04:00
|
|
|
(message || '') + ' height');
|
2011-02-13 10:48:20 -05:00
|
|
|
}
|
2011-02-19 11:11:17 -05:00
|
|
|
|
|
|
|
function compareRGBColors(color1, color2, message) {
|
|
|
|
color1 = new RGBColor(color1);
|
|
|
|
color2 = new RGBColor(color2);
|
|
|
|
|
2011-03-08 20:25:38 -05:00
|
|
|
compareNumbers(color1.red, color2.red,
|
2011-05-05 08:05:39 -04:00
|
|
|
(message || '') + ' red');
|
2011-03-08 20:25:38 -05:00
|
|
|
compareNumbers(color1.green, color2.green,
|
2011-05-05 08:05:39 -04:00
|
|
|
(message || '') + ' green');
|
2011-03-08 20:25:38 -05:00
|
|
|
compareNumbers(color1.blue, color2.blue,
|
2011-05-05 08:05:39 -04:00
|
|
|
(message || '') + ' blue');
|
2011-03-08 20:25:38 -05:00
|
|
|
compareNumbers(color1.alpha, color2.alpha,
|
2011-05-05 08:05:39 -04:00
|
|
|
(message || '') + ' alpha');
|
2011-03-08 20:25:38 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
function compareHSBColors(color1, color2, message) {
|
|
|
|
color1 = new HSBColor(color1);
|
|
|
|
color2 = new HSBColor(color2);
|
|
|
|
|
|
|
|
compareNumbers(color1.hue, color2.hue,
|
2011-05-05 08:05:39 -04:00
|
|
|
(message || '') + ' hue');
|
2011-03-08 20:25:38 -05:00
|
|
|
compareNumbers(color1.saturation, color2.saturation,
|
2011-05-05 08:05:39 -04:00
|
|
|
(message || '') + ' saturation');
|
2011-03-08 20:25:38 -05:00
|
|
|
compareNumbers(color1.brightness, color2.brightness,
|
2011-05-05 08:05:39 -04:00
|
|
|
(message || '') + ' brightness');
|
2011-03-08 20:25:38 -05:00
|
|
|
compareNumbers(color1.alpha, color2.alpha,
|
2011-05-05 08:05:39 -04:00
|
|
|
(message || '') + ' alpha');
|
2011-03-08 20:25:38 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
function compareGrayColors(color1, color2, message) {
|
|
|
|
color1 = new GrayColor(color1);
|
|
|
|
color2 = new GrayColor(color2);
|
|
|
|
|
|
|
|
compareNumbers(color1.gray, color2.gray,
|
2011-05-05 08:05:39 -04:00
|
|
|
(message || '') + ' gray');
|
2011-02-19 11:11:17 -05:00
|
|
|
}
|