mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-01 10:48:38 -05:00
See https://github.com/paperjs/paper.js/pull/944#issuecomment-180370569
This commit is contained in:
parent
ffe42a0220
commit
a59a5354fb
2 changed files with 24 additions and 14 deletions
|
@ -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);
|
||||
});
|
||||
|
|
|
@ -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);
|
||||
|
@ -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]);
|
||||
|
|
Loading…
Reference in a new issue