mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -05:00
Fix issue in Curve.getLength() for linear curves with sub-ranges.
Closes #376.
This commit is contained in:
parent
6654dca6bf
commit
6a11547942
1 changed files with 3 additions and 2 deletions
|
@ -1091,12 +1091,13 @@ new function() { // Scope for methods that require numerical integration
|
|||
b = 1;
|
||||
var isZero = Numerical.isZero;
|
||||
// See if the curve is linear by checking p1 == c1 and p2 == c2
|
||||
if (isZero(v[0] - v[2]) && isZero(v[1] - v[3])
|
||||
if (a === 0 && b === 1
|
||||
&& isZero(v[0] - v[2]) && isZero(v[1] - v[3])
|
||||
&& isZero(v[6] - v[4]) && isZero(v[7] - v[5])) {
|
||||
// Straight line
|
||||
var dx = v[6] - v[0], // p2x - p1x
|
||||
dy = v[7] - v[1]; // p2y - p1y
|
||||
return (b - a) * Math.sqrt(dx * dx + dy * dy);
|
||||
return Math.sqrt(dx * dx + dy * dy);
|
||||
}
|
||||
var ds = getLengthIntegrand(v);
|
||||
return Numerical.integrate(ds, a, b, getIterations(a, b));
|
||||
|
|
Loading…
Reference in a new issue