Implement unit tests for #1116

Closes #1116
This commit is contained in:
Jürg Lehni 2017-01-08 15:07:40 +01:00
parent 0ae2ded9cc
commit 673d157f31
2 changed files with 72 additions and 3 deletions

View file

@ -272,6 +272,8 @@ var PathItem = Item.extend(/** @lends PathItem# */{
this.getBounds({ internal: true, handle: true }))
? this._getWinding(point)
: {};
// See #1116#issuecomment-243794824 for an explanation of the
// winding.onPath check here.
return winding.onPath || !!(this.getFillRule() === 'evenodd'
? winding.windingL & 1 || winding.windingR & 1
: winding.winding);

View file

@ -292,8 +292,7 @@ test('Path#contains() (straight curves with zero-winding: #943)', function() {
}
});
/*
test('CompoundPath#contains() (nested touching circles: #944)', function() {
test('CompoundPath#contains() (nested touching circles and other edge cases: #944)', function() {
var cp = new CompoundPath({
children: [
new Path.Circle({
@ -308,8 +307,76 @@ test('CompoundPath#contains() (nested touching circles: #944)', function() {
fillRule: 'evenodd'
});
testPoint(cp, new Point(100, 200), true);
var cp = new CompoundPath({
children: [
new Path.Circle({
center: [200, 200],
radius: 100
}),
new Path.Circle({
center: [200, 200],
radius: 100,
clockwise: false
}),
new Path.Circle({
center: [200, 200],
radius: 100
}),
new Path.Circle({
center: [150, 200],
radius: 50,
clockwise: false
})
]
});
testPoint(cp, new Point(100, 200), true);
var cp = new CompoundPath({
children: [
new Path.Rectangle({
point: [100, 100],
size: [200, 200]
}),
new Path.Rectangle({
point: [100, 150],
size: [100, 100]
})
],
fillRule: 'evenodd'
});
testPoint(cp, new Point(100, 200), true);
var cp = new CompoundPath({
children: [
new Path.Rectangle({
point: [100, 100],
size: [200, 200]
}),
new Path.Rectangle({
point: [100, 100],
size: [200, 200]
})
],
fillRule: 'nonzero'
});
testPoint(cp, new Point(100, 200), true);
var cp = new CompoundPath({
children: [
new Path.Rectangle({
point: [100, 100],
size: [200, 200]
}),
new Path.Rectangle({
point: [300, 100],
size: [200, 200]
})
],
fillRule: 'evenodd'
});
testPoint(cp, new Point(300, 200), true);
});
*/
test('Path#contains() with Path#interiorPoint: #854, #1064', function() {
var paths = [