Skip to content

Commit 1ee6bb7

Browse files
committed
Use isZero() when checking for straight curves in Curve.getLength()
1 parent 123b6b6 commit 1ee6bb7

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

src/path/Curve.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1009,8 +1009,10 @@ new function() { // Scope for methods that require numerical integration
10091009
a = 0;
10101010
if (b === undefined)
10111011
b = 1;
1012+
var isZero = Numerical.isZero;
10121013
// See if the curve is linear by checking p1 == c1 and p2 == c2
1013-
if (v[0] == v[2] && v[1] == v[3] && v[6] == v[4] && v[7] == v[5]) {
1014+
if (isZero(v[0] - v[2]) && isZero(v[1] - v[3])
1015+
&& isZero(v[6] - v[4]) && isZero(v[7] - v[5])) {
10141016
// Straight line
10151017
var dx = v[6] - v[0], // p2x - p1x
10161018
dy = v[7] - v[1]; // p2y - p1y

test/tests/Path_Curves.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ test('path.curves synchronisation', function() {
3939
var length = path.curves[0].length;
4040
ok(path.curves[0]._length, 'Curve length does not appear to be cached');
4141
path.scale(2, [0, 0]);
42-
equals(path.curves[0].length, 200, 'Curve length should be updated when path is transformed');
42+
compareNumbers(path.curves[0].length, 200, 'Curve length should be updated when path is transformed');
4343

4444
var points = [];
4545
for (var i = 0; i < 40; i++)

0 commit comments

Comments
 (0)