Skip to content

Commit

Permalink
No need to pass normalized tangents to PathFitter#fitCubic()
Browse files Browse the repository at this point in the history
The get normalized and scaled anyway.
  • Loading branch information
lehni committed Feb 9, 2016
1 parent e5d139c commit c793538
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/path/PathFitter.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ var PathFitter = Base.extend({
segments = [new Segment(points[0])];
if (length > 1) {
this.fitCubic(segments, error, 0, length - 1,
// Left Tangent
points[1].subtract(points[0]).normalize(),
// Right Tangent
points[length - 2].subtract(points[length - 1]).normalize());
// Left Tangent
points[1].subtract(points[0]),
// Right Tangent
points[length - 2].subtract(points[length - 1]));
// Remove the duplicated segments for closed paths again.
if (this.closed) {
segments.shift();
Expand Down Expand Up @@ -99,8 +99,7 @@ var PathFitter = Base.extend({
maxError = max.error;
}
// Fitting failed -- split at max error point and fit recursively
var tanCenter = points[split - 1].subtract(points[split + 1])
.normalize();
var tanCenter = points[split - 1].subtract(points[split + 1]);
this.fitCubic(segments, error, first, split, tan1, tanCenter);
this.fitCubic(segments, error, split, last, tanCenter.negate(), tan2);
},
Expand Down

0 comments on commit c793538

Please sign in to comment.