Skip to content

Commit

Permalink
Clean-up unit test for paperjs#943 and add edge case from paperjs#944
Browse files Browse the repository at this point in the history
  • Loading branch information
lehni committed Feb 5, 2016
1 parent ffe42a0 commit a59a535
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 14 deletions.
36 changes: 24 additions & 12 deletions test/tests/PathItem_Contains.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,19 +266,31 @@ test('Path#contains() (straight curves with zero-winding)', function() {
for (var i = 0; i < pointData.length; i++) {
points.push(pointData[i][0]);
}
var path = new paper.Path({segments: points, closed: true});
path.setWindingRule("evenodd");

var offsetPoint = function(p, xOffs, yOffs) {
return new paper.Point(p.x + xOffs, p.y + yOffs);
}
var path = new Path({
segments: points,
fillRule: 'evenodd',
closed: true
});

for (var i = 0; i < pointData.length; i++) {
var p = new paper.Point(points[i]);
var p = new Point(points[i]);
testPoint(path, p, true); // point is a segment of the path, must be inside
testPoint(path, offsetPoint(p, 10, 0), pointData[i][1]);
testPoint(path, offsetPoint(p, -10, 0), pointData[i][2]);
testPoint(path, offsetPoint(p, 0, 10), pointData[i][3]);
testPoint(path, offsetPoint(p, 0, -10), pointData[i][4]);
testPoint(path, p.add(10, 0), pointData[i][1]);
testPoint(path, p.add(-10, 0), pointData[i][2]);
testPoint(path, p.add(0, 10), pointData[i][3]);
testPoint(path, p.add(0, -10), pointData[i][4]);
}
})
});

test('CompoundPath#contains() (nested touching circles)', function() {
var c1 = new Path.Circle({
center: [200, 200],
radius: 100
});
var c2 = new Path.Circle({
center: [150, 200],
radius: 50
});
var cp = new CompoundPath([c1, c2]);
testPoint(cp, new Point(100, 200), true);
});
2 changes: 0 additions & 2 deletions test/tests/Path_Intersections.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ test('#571', function() {
]);
});


test('overlapping circles', function() {
var path1 = new Path.Circle(new paper.Point(50, 50), 50);
var path2 = new Path.Circle(new paper.Point(100, 100), 50);
Expand All @@ -96,7 +95,6 @@ test('overlapping circles', function() {
]);
});


test('circle and square (existing segments overlaps on curves)', function() {
var path1 = new Path.Circle(new Point(110, 110), 80);
var path2 = new Path.Rectangle(new Point(110, 110), [100, 100]);
Expand Down

0 comments on commit a59a535

Please sign in to comment.