mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -05:00
Handle closed path in PathFitter
This commit is contained in:
parent
f193acf31b
commit
a9bf0b097e
1 changed files with 16 additions and 0 deletions
|
@ -33,6 +33,15 @@ var PathFitter = Base.extend({
|
||||||
prev = point;
|
prev = point;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// we need to duplicate first and last segments when simplifying a
|
||||||
|
// closed path
|
||||||
|
if ( path._closed ) {
|
||||||
|
this._closed = true;
|
||||||
|
this.points.unshift( segments[l - 1].point.clone() );
|
||||||
|
this.points.push( segments[0].point.clone() );
|
||||||
|
}
|
||||||
|
|
||||||
this.error = error;
|
this.error = error;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -46,6 +55,13 @@ var PathFitter = Base.extend({
|
||||||
points[1].subtract(points[0]).normalize(),
|
points[1].subtract(points[0]).normalize(),
|
||||||
// Right Tangent
|
// Right Tangent
|
||||||
points[length - 2].subtract(points[length - 1]).normalize());
|
points[length - 2].subtract(points[length - 1]).normalize());
|
||||||
|
|
||||||
|
// remove the duplicated segments
|
||||||
|
if ( this._closed ) {
|
||||||
|
this.segments.shift();
|
||||||
|
this.segments.pop();
|
||||||
|
}
|
||||||
|
|
||||||
return this.segments;
|
return this.segments;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue