mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -05:00
Partly revert "Treat overlaps as crossings as well."
This partly reverts commit deafacdad0
and closes #868
This commit is contained in:
parent
a7a07fb6d5
commit
32cf1ba69e
2 changed files with 12 additions and 9 deletions
|
@ -92,7 +92,9 @@ PathItem.inject(new function() {
|
|||
_path2.reverse();
|
||||
// Split curves at crossings on both paths. Note that for self-
|
||||
// intersection, path2 is null and getIntersections() handles it.
|
||||
var crossings = CurveLocation.expand(_path1.getCrossings(_path2));
|
||||
var crossings = CurveLocation.expand(_path1.getCrossings(_path2,
|
||||
// Only handle overlaps when not self-intersecting
|
||||
!!_path2));
|
||||
divideLocations(crossings);
|
||||
|
||||
var segments = [],
|
||||
|
@ -140,7 +142,7 @@ PathItem.inject(new function() {
|
|||
return null;
|
||||
var _path1 = preparePath(path1, false),
|
||||
_path2 = preparePath(path2, false),
|
||||
crossings = _path1.getCrossings(_path2),
|
||||
crossings = _path1.getCrossings(_path2, true),
|
||||
sub = operation === 'subtract',
|
||||
paths = [];
|
||||
|
||||
|
|
|
@ -140,19 +140,20 @@ var PathItem = Item.extend(/** @lends PathItem# */{
|
|||
},
|
||||
|
||||
/**
|
||||
* Returns all crossings between two {@link PathItem} items as an array
|
||||
* of {@link CurveLocation} objects. {@link CompoundPath} items are also
|
||||
* supported.
|
||||
* Crossings are intersections where the paths actually are crossing each
|
||||
* other, as opposed to simply touching.
|
||||
* Returns all crossings between two {@link PathItem} items as an array of
|
||||
* {@link CurveLocation} objects. {@link CompoundPath} items are also
|
||||
* supported. Crossings are intersections where the paths actually are
|
||||
* crossing each other, as opposed to simply touching.
|
||||
*
|
||||
* @param {PathItem} path the other item to find the crossings with
|
||||
* @param {Boolean} includeOverlaps whether to also count overlaps as
|
||||
* crossings
|
||||
* @see #getIntersections(path)
|
||||
*/
|
||||
getCrossings: function(path) {
|
||||
getCrossings: function(path, includeOverlaps) {
|
||||
return this.getIntersections(path, function(inter) {
|
||||
// Check overlap first since it's the cheaper test between the two.
|
||||
return inter.isOverlap() || inter.isCrossing();
|
||||
return includeOverlaps && inter.isOverlap() || inter.isCrossing();
|
||||
});
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in a new issue