mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-20 22:39:50 -05:00
Do not pass prevSlope to Curve#getCrossings(), rely on #getPrevious() instead.
This commit is contained in:
parent
4a53503130
commit
e573fe5dcd
2 changed files with 5 additions and 9 deletions
|
@ -326,7 +326,7 @@ var Curve = this.Curve = Base.extend(/** @lends Curve# */{
|
|||
return Curve.getParameter.apply(Curve, args);
|
||||
},
|
||||
|
||||
getCrossings: function(point, matrix, prevSlope) {
|
||||
getCrossings: function(point, matrix) {
|
||||
// Implement the crossing number algorithm:
|
||||
// http://en.wikipedia.org/wiki/Point_in_polygon
|
||||
// Solve the y-axis cubic polynominal for point.y and count all
|
||||
|
@ -342,7 +342,8 @@ var Curve = this.Curve = Base.extend(/** @lends Curve# */{
|
|||
// previous curve, do not count this root, as we're merely
|
||||
// touching a tip.
|
||||
if (t < Numerical.TOLERANCE
|
||||
&& prevSlope * this.getTangent(t).y >= 0)
|
||||
&& this.getPrevious().getTangent(1).y
|
||||
* this.getTangent(t).y >= 0)
|
||||
continue;
|
||||
crossings++;
|
||||
}
|
||||
|
|
|
@ -1189,14 +1189,9 @@ var Path = this.Path = PathItem.extend(/** @lends Path# */{
|
|||
// number, meaning the starting point is inside the shape.
|
||||
// http://en.wikipedia.org/wiki/Point_in_polygon
|
||||
var curves = this.getCurves(),
|
||||
prevCurve = this.getLastCurve(),
|
||||
crossings = 0;
|
||||
for (var i = 0, l = curves.length; i < l; i++) {
|
||||
var curve = curves[i];
|
||||
crossings += curve.getCrossings(point,
|
||||
prevCurve.getTangent(1).y);
|
||||
prevCurve = curve;
|
||||
}
|
||||
for (var i = 0, l = curves.length; i < l; i++)
|
||||
crossings += curves[i].getCrossings(point, matrix);
|
||||
return (crossings & 1) == 1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue