mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-22 23:39:59 -05:00
Handle paths as circular lists in CurveLocation.insert() as well.
Relates to #805
This commit is contained in:
parent
0553201de8
commit
2e552853fd
1 changed files with 8 additions and 1 deletions
|
@ -300,7 +300,7 @@ var CurveLocation = Base.extend(/** @lends CurveLocation# */{
|
||||||
// NOTE: We need to compare both by (index + parameter) and by
|
// NOTE: We need to compare both by (index + parameter) and by
|
||||||
// proximity of points, see:
|
// proximity of points, see:
|
||||||
// https://github.com/paperjs/paper.js/issues/784#issuecomment-143161586
|
// https://github.com/paperjs/paper.js/issues/784#issuecomment-143161586
|
||||||
// We need to wrap the diff value around the path beginning / end.
|
// We need to wrap the diff value around the path's beginning / end.
|
||||||
var c1 = this.getCurve(),
|
var c1 = this.getCurve(),
|
||||||
c2 = loc.getCurve();
|
c2 = loc.getCurve();
|
||||||
diff = ((c1.isLast() && c2.isFirst() ? -1 : c1.getIndex())
|
diff = ((c1.isLast() && c2.isFirst() ? -1 : c1.getIndex())
|
||||||
|
@ -488,6 +488,13 @@ new function() { // Scope for statics
|
||||||
break;
|
break;
|
||||||
if (loc.equals(loc2))
|
if (loc.equals(loc2))
|
||||||
return loc2;
|
return loc2;
|
||||||
|
// If we reach the beginning/end of the list, also compare with
|
||||||
|
// the location at the other end, as paths are circular lists.
|
||||||
|
if (i === 0 || i === length - 1) {
|
||||||
|
loc2 = locations[i === 0 ? length - 1 : 0];
|
||||||
|
if (loc.equals(loc2))
|
||||||
|
return loc2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue