mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -05:00
More cleanup in curve intersection code.
This commit is contained in:
parent
2ead16ca89
commit
1ff4bc9665
1 changed files with 5 additions and 11 deletions
|
@ -2005,10 +2005,6 @@ new function() { // Scope for bezier intersection using fat-line clipping
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCurveIntersections(v1, v2, c1, c2, locations, include) {
|
function getCurveIntersections(v1, v2, c1, c2, locations, include) {
|
||||||
if (!v2) {
|
|
||||||
// If v2 is not provided, search for a self-intersection on v1.
|
|
||||||
return getLoopIntersection(v1, c1, locations, include);
|
|
||||||
}
|
|
||||||
// Avoid checking curves if completely out of control bounds.
|
// Avoid checking curves if completely out of control bounds.
|
||||||
var epsilon = /*#=*/Numerical.EPSILON,
|
var epsilon = /*#=*/Numerical.EPSILON,
|
||||||
c1x0 = v1[0], c1y0 = v1[1],
|
c1x0 = v1[0], c1y0 = v1[1],
|
||||||
|
@ -2128,10 +2124,7 @@ new function() { // Scope for bezier intersection using fat-line clipping
|
||||||
// self-intersection check:
|
// self-intersection check:
|
||||||
if (_returnFirst && locations.length)
|
if (_returnFirst && locations.length)
|
||||||
return locations;
|
return locations;
|
||||||
var curve2 = curves2[j];
|
getCurveIntersections(values1, values2[j], curve1, curves2[j],
|
||||||
// Avoid end point intersections on consecutive curves when
|
|
||||||
// self-intersecting.
|
|
||||||
getCurveIntersections(values1, values2[j], curve1, curve2,
|
|
||||||
locations, include);
|
locations, include);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2252,9 +2245,10 @@ new function() { // Scope for bezier intersection using fat-line clipping
|
||||||
* the curves
|
* the curves
|
||||||
*/
|
*/
|
||||||
getIntersections: function(curve) {
|
getIntersections: function(curve) {
|
||||||
return getCurveIntersections(this.getValues(),
|
var v1 = this.getValues(),
|
||||||
curve && curve !== this ? curve.getValues() : null,
|
v2 = curve && curve !== this && curve.getValues();
|
||||||
this, curve, []);
|
return v2 ? getCurveIntersections(v1, v2, this, curve, [])
|
||||||
|
: getLoopIntersection(v1, this, []);
|
||||||
},
|
},
|
||||||
|
|
||||||
statics: /** @lends Curve */{
|
statics: /** @lends Curve */{
|
||||||
|
|
Loading…
Reference in a new issue