paper.js/test/lib/helpers.js

57 lines
2 KiB
JavaScript
Raw Normal View History

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