mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-23 07:49:48 -05:00
Prevent detection of tiny overlaps and streamline addOverlap() code.
This commit is contained in:
parent
2bed611648
commit
86b1b74869
1 changed files with 5 additions and 11 deletions
|
@ -1733,12 +1733,11 @@ new function() { // Scope for intersection using bezier fat-line clipping
|
||||||
v[i][t1 === 0 ? 1 : 7]);
|
v[i][t1 === 0 ? 1 : 7]);
|
||||||
if (t2 != null) { // If point is on curve
|
if (t2 != null) { // If point is on curve
|
||||||
var pair = i === 0 ? [t1, t2] : [t2, t1];
|
var pair = i === 0 ? [t1, t2] : [t2, t1];
|
||||||
if (pairs.length === 1 && pair[0] < pairs[0][0]) {
|
// Filter out tiny overlaps
|
||||||
pairs.unshift(pair);
|
// TODO: Compare distance of points instead of curve time?
|
||||||
} else if (pairs.length === 0
|
if (pairs.length === 0
|
||||||
// TODO: Compare distance of the actual points instead!
|
|
||||||
|| abs(pair[0] - pairs[0][0]) > timeEpsilon
|
|| abs(pair[0] - pairs[0][0]) > timeEpsilon
|
||||||
|| abs(pair[1] - pairs[0][1]) > timeEpsilon) {
|
&& abs(pair[1] - pairs[0][1]) > timeEpsilon) {
|
||||||
pairs.push(pair);
|
pairs.push(pair);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1751,12 +1750,7 @@ new function() { // Scope for intersection using bezier fat-line clipping
|
||||||
if (pairs.length === 2) {
|
if (pairs.length === 2) {
|
||||||
// create values for overlapping part of each curve
|
// create values for overlapping part of each curve
|
||||||
var p1 = Curve.getPart(v[0], pairs[0][0], pairs[1][0]),
|
var p1 = Curve.getPart(v[0], pairs[0][0], pairs[1][0]),
|
||||||
p2 = Curve.getPart(v[1], Math.min(pairs[0][1], pairs[1][1]),
|
p2 = Curve.getPart(v[1], pairs[0][1], pairs[1][1]);
|
||||||
Math.max(pairs[0][1], pairs[1][1]));
|
|
||||||
// Reverse values of second curve if necessary
|
|
||||||
if (pairs[0][1] > pairs[1][1]) {
|
|
||||||
p2 = [p2[6], p2[7], p2[4], p2[5], p2[2], p2[3], p2[0], p2[1]];
|
|
||||||
}
|
|
||||||
// Check if handles of overlapping paths are similar enough.
|
// Check if handles of overlapping paths are similar enough.
|
||||||
// We could do another check for curve identity here if we find a
|
// We could do another check for curve identity here if we find a
|
||||||
// better criteria.
|
// better criteria.
|
||||||
|
|
Loading…
Reference in a new issue