mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-08-28 22:08:54 -04:00
Streamline PathItem_Contains tests and add more tests.
This commit is contained in:
parent
e6b7e9b2eb
commit
f6061905be
1 changed files with 21 additions and 15 deletions
|
@ -12,9 +12,9 @@
|
|||
|
||||
module('PathItem Contains');
|
||||
|
||||
function testPoint(item, point, inside) {
|
||||
equals(item.contains(point), inside, 'The point ' + point
|
||||
+ ' should be ' + (inside ? 'inside' : 'outside') + '.');
|
||||
function testPoint(item, point, inside, message) {
|
||||
equals(item.contains(point), inside, message || ('The point ' + point
|
||||
+ ' should be ' + (inside ? 'inside' : 'outside') + '.'));
|
||||
}
|
||||
|
||||
test('Path#contains() (Regular Polygon)', function() {
|
||||
|
@ -96,29 +96,35 @@ test('CompoundPath#contains() (Donut)', function() {
|
|||
new Path.Circle([0, 0], 25)
|
||||
]);
|
||||
|
||||
equals(path.contains(new Point(0, 0)), false,
|
||||
testPoint(path, new Point(0, -50), true,
|
||||
'The top center point of the outer circle should be inside the donut.');
|
||||
testPoint(path, new Point(0, 0), false,
|
||||
'The center point should be outside the donut.');
|
||||
equals(path.contains(new Point(-35, 0)), true,
|
||||
testPoint(path, new Point(-35, 0), true,
|
||||
'A vertically centered point on the left side should be inside the donut.');
|
||||
equals(path.contains(new Point(35, 0)), true,
|
||||
testPoint(path, new Point(35, 0), true,
|
||||
'A vertically centered point on the right side should be inside the donut.');
|
||||
equals(path.contains(new Point(0, 49)), true,
|
||||
testPoint(path, new Point(0, 49), true,
|
||||
'The near bottom center point of the outer circle should be inside the donut.');
|
||||
equals(path.contains(new Point(0, 50)), true,
|
||||
testPoint(path, new Point(0, 50), true,
|
||||
'The bottom center point of the outer circle should be inside the donut.');
|
||||
equals(path.contains(new Point(0, 51)), false,
|
||||
testPoint(path, new Point(0, 51), false,
|
||||
'The near bottom center point of the outer circle should be outside the donut.');
|
||||
equals(path.contains(new Point({ length: 50, angle: 30 })), true,
|
||||
testPoint(path, new Point({ length: 50, angle: 30 }), true,
|
||||
'A random point on the periphery of the outer circle should be inside the donut.');
|
||||
equals(path.contains(new Point(0, 25)), false,
|
||||
testPoint(path, new Point(0, 25), false,
|
||||
'The bottom center point of the inner circle should be outside the donut.');
|
||||
equals(path.contains(new Point({ length: 25, angle: 30 })), false,
|
||||
testPoint(path, new Point({ length: 25, angle: 30 }), false,
|
||||
'A random point on the periphery of the inner circle should be outside the donut.');
|
||||
equals(path.contains(new Point(-50, -50)), false,
|
||||
testPoint(path, new Point(-50, -50), false,
|
||||
'The top left point of bounding box should be outside the donut.');
|
||||
equals(path.contains(new Point(-50, 50)), false,
|
||||
testPoint(path, new Point(50, -50), false,
|
||||
'The top right point of the bounding box should be inside the donut.');
|
||||
testPoint(path, new Point(-50, 50), false,
|
||||
'The bottom left point of bounding box should be outside the donut.');
|
||||
equals(path.contains(new Point(-45, 45)), false,
|
||||
testPoint(path, new Point(50, 50), false,
|
||||
'The bottom right point of the bounding box should be inside the donut.');
|
||||
testPoint(path, new Point(-45, 45), false,
|
||||
'The near bottom left point of bounding box should be outside the donut.');
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue