mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-05 20:32:00 -05:00
Remove includeOverlaps parameter from getCrossings()
And write better comments about how overlaps should be dealt with ideally.
This commit is contained in:
parent
2fc7684efb
commit
af797df5ba
2 changed files with 11 additions and 10 deletions
|
@ -92,9 +92,8 @@ PathItem.inject(new function() {
|
||||||
_path2.reverse();
|
_path2.reverse();
|
||||||
// Split curves at crossings on both paths. Note that for self-
|
// Split curves at crossings on both paths. Note that for self-
|
||||||
// intersection, path2 is null and getIntersections() handles it.
|
// intersection, path2 is null and getIntersections() handles it.
|
||||||
var crossings = divideLocations(CurveLocation.expand(
|
var crossings = divideLocations(
|
||||||
// Only handle overlaps when not self-intersecting
|
CurveLocation.expand(_path1.getCrossings(_path2))),
|
||||||
_path1.getCrossings(_path2, !!_path2))),
|
|
||||||
segments = [],
|
segments = [],
|
||||||
// Aggregate of all curves in both operands, monotonic in y.
|
// Aggregate of all curves in both operands, monotonic in y.
|
||||||
monoCurves = [],
|
monoCurves = [],
|
||||||
|
@ -156,7 +155,7 @@ PathItem.inject(new function() {
|
||||||
return null;
|
return null;
|
||||||
var _path1 = preparePath(path1, false),
|
var _path1 = preparePath(path1, false),
|
||||||
_path2 = preparePath(path2, false),
|
_path2 = preparePath(path2, false),
|
||||||
crossings = _path1.getCrossings(_path2, true),
|
crossings = _path1.getCrossings(_path2),
|
||||||
sub = operator.subtract,
|
sub = operator.subtract,
|
||||||
paths = [];
|
paths = [];
|
||||||
|
|
||||||
|
|
|
@ -146,16 +146,18 @@ var PathItem = Item.extend(/** @lends PathItem# */{
|
||||||
* crossing each other, as opposed to simply touching.
|
* crossing each other, as opposed to simply touching.
|
||||||
*
|
*
|
||||||
* @param {PathItem} path the other item to find the crossings with
|
* @param {PathItem} path the other item to find the crossings with
|
||||||
* @param {Boolean} includeOverlaps whether to also count overlaps as
|
|
||||||
* crossings
|
|
||||||
* @see #getIntersections(path)
|
* @see #getIntersections(path)
|
||||||
*/
|
*/
|
||||||
getCrossings: function(path, includeOverlaps) {
|
getCrossings: function(path) {
|
||||||
return this.getIntersections(path, function(inter) {
|
return this.getIntersections(path, function(inter) {
|
||||||
// TODO: Only return overlaps that are actually crossings! For this
|
// TODO: Only return overlaps that are actually crossings! For this
|
||||||
// we need proper overlap range detection first.
|
// we need proper overlap range detection / merging first...
|
||||||
// Check overlap first since it's the cheaper test between the two.
|
// But as we call #resolveCrossings() first in boolean operations,
|
||||||
return includeOverlaps && inter._overlap || inter.isCrossing();
|
// removing all self-touching areas in paths, this currently works
|
||||||
|
// as it should in the known use cases.
|
||||||
|
// The ideal implementation would deal with it in a way outlined in:
|
||||||
|
// https://github.com/paperjs/paper.js/issues/874#issuecomment-168332391
|
||||||
|
return inter._overlap || inter.isCrossing();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue