mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-01 02:38:43 -05:00
Add compareNumbers() method, to compare with same tolerance in Rectangles as in Points.
This commit is contained in:
parent
e08359f49d
commit
5234c5624c
1 changed files with 16 additions and 11 deletions
|
@ -19,16 +19,21 @@ function compareSegments(segment1, segment2) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function comparePoints(point1, point2, message) {
|
function compareNumbers(number1, number2, message) {
|
||||||
equals(Math.round(point1.x * 100), Math.round(point2.x * 100),
|
equals(Math.round(number1 * 100) / 100, Math.round(number2 * 100) / 100,
|
||||||
message ? message + ' x' : undefined);
|
message);
|
||||||
equals(Math.round(point1.y * 100), Math.round(point2.y * 100),
|
|
||||||
message ? message + ' y' : undefined);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function compareRectangles(rect1, rect2) {
|
function comparePoints(point1, point2, message) {
|
||||||
equals(rect1.x, rect2.x);
|
compareNumbers(point1.x, point2.x, message ? message + ' x' : undefined);
|
||||||
equals(rect1.y, rect2.y);
|
compareNumbers(point1.y, point2.y, message ? message + ' y' : undefined);
|
||||||
equals(rect1.width, rect2.width);
|
}
|
||||||
equals(rect1.height, rect2.height);
|
|
||||||
}
|
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);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue