Implement Item#intersects(item)

This commit is contained in:
Jürg Lehni 2014-10-20 17:00:18 +02:00
parent b3c7be67fc
commit 5ddbc5b07f
2 changed files with 34 additions and 0 deletions

View file

@ -181,6 +181,22 @@ var PathItem = Item.extend(/** @lends PathItem# */{
return locations;
},
intersects: function(item, _matrix) {
if (!(item instanceof Item))
return false;
var other = item instanceof PathItem
? item
// Create a temporary rectangular path item to check against.
: new Path.Rectangle({
rectangle: item.getInternalBounds(),
insert: false
});
// TODO: Optimize getIntersections(): We don't need all intersections
// when we're just curious about whether they intersect or not. Pass on
// an argument that let's it bail out after the first intersection.
return this.getIntersections(other, _matrix || item._matrix).length > 0;
},
/**
* The path's geometry, formatted as SVG style path data.
*