Replace all unsupported Curve#getLength(from, to) calls with #getPartLength(from, to)

This commit is contained in:
Jürg Lehni 2014-03-30 14:17:02 +02:00
parent c464f9ce1b
commit a81063a994
2 changed files with 8 additions and 5 deletions

View file

@ -73,8 +73,8 @@ var CurveLocation = Base.extend(/** @lends CurveLocation# */{
return null;
} else {
// Determine the closest segment by comparing curve lengths
this._segment = curve.getLength(0, parameter)
< curve.getLength(parameter, 1)
this._segment = curve.getPartLength(0, parameter)
< curve.getPartLength(parameter, 1)
? curve._segment1
: curve._segment2;
}
@ -180,7 +180,7 @@ var CurveLocation = Base.extend(/** @lends CurveLocation# */{
getCurveOffset: function() {
var curve = this.getCurve(),
parameter = this.getParameter();
return parameter != null && curve && curve.getLength(0, parameter);
return parameter != null && curve && curve.getPartLength(0, parameter);
},
/**

View file

@ -1334,8 +1334,11 @@ var Path = PathItem.extend(/** @lends Path# */{
offset = 0;
for (var i = 0; i < index; i++)
offset += curves[i].getLength();
var curve = curves[index];
return offset + curve.getLength(0, location.getParameter());
var curve = curves[index],
parameter = location.getParameter();
if (parameter > 0)
offset += curve.getPartLength(0, parameter);
return offset;
}
return null;
},