Do not pass prevSlope to Curve#getCrossings(), rely on #getPrevious() instead.

This commit is contained in:
Jürg Lehni 2011-07-07 16:08:10 +02:00
parent 4a53503130
commit e573fe5dcd
2 changed files with 5 additions and 9 deletions

View file

@ -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++;
}

View file

@ -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;
}