Fix #getCrossings() where calling #getPoint() / #getTangent() was slow and also wrong when a matrix was used.

This commit is contained in:
Jürg Lehni 2011-07-09 10:09:41 +02:00
parent 8606f25542
commit 8928a7b057

View file

@ -319,13 +319,13 @@ var Curve = this.Curve = Base.extend(/** @lends Curve# */{
crossings = 0;
for (var i = 0, l = roots != Infinity && roots.length; i < l; i++) {
var t = roots[i];
if (t >= 0 && t < 1 && this.getPoint(t).x > point.x) {
if (t >= 0 && t < 1 && Curve.evaluate(vals, t, 0).y > point.x) {
// If we're close to 0 and are not changing y-direction from the
// previous curve, do not count this root, as we're merely
// touching a tip.
if (t < Numerical.TOLERANCE
&& this.getPrevious().getTangent(1).y
* this.getTangent(t).y >= 0)
if (t < Numerical.TOLERANCE && Curve.evaluate(
this.getPrevious().getValues(matrix), 1, 1).y
* Curve.evaluate(vals, t, 1).y >= 0)
continue;
crossings++;
}