mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-19 14:10:14 -05:00
Implement Path#curvesToPoints() using the new PathFlattener class.
This commit is contained in:
parent
74b9da9882
commit
e76c4e0de1
1 changed files with 15 additions and 2 deletions
|
@ -458,9 +458,22 @@ var Path = this.Path = PathItem.extend({
|
|||
setFullySelected: function(selected) {
|
||||
this.setSelected(selected);
|
||||
},
|
||||
|
||||
|
||||
curvesToPoints: function(maxDistance) {
|
||||
var flattener = new PathFlattener(this),
|
||||
pos = 0;
|
||||
var step = flattener.length / Math.ceil(flattener.length / maxDistance);
|
||||
this.segments = [];
|
||||
// Iterate over path and evaluate and add points at given offsets
|
||||
do {
|
||||
this._add([ new Segment(flattener.evaluate(pos, 0)) ]);
|
||||
} while ((pos += step) < flattener.length);
|
||||
// Add last one
|
||||
this._add([ new Segment(flattener.evaluate(flattener.length, 0)) ]);
|
||||
this._changed(ChangeFlags.GEOMETRY);
|
||||
},
|
||||
|
||||
// TODO: pointsToCurves([tolerance[, threshold[, cornerRadius[, scale]]]])
|
||||
// TODO: curvesToPoints([maxPointDistance[, flatness]])
|
||||
// TODO: reduceSegments([flatness])
|
||||
// TODO: split(offset) / split(location) / split(index[, parameter])
|
||||
|
||||
|
|
Loading…
Reference in a new issue