Rename PathIterator back to PathFlattener.

This commit is contained in:
Jürg Lehni 2016-07-27 14:18:01 +02:00
parent 753b27afe0
commit a29ada8f23
3 changed files with 21 additions and 21 deletions

View file

@ -77,7 +77,7 @@ var paper = function(self, undefined) {
/*#*/ if (__options.booleanOperations) {
/*#*/ include('path/PathItem.Boolean.js');
/*#*/ }
/*#*/ include('path/PathIterator.js');
/*#*/ include('path/PathFlattener.js');
/*#*/ include('path/PathFitter.js');
/*#*/ include('text/TextItem.js');

View file

@ -1239,17 +1239,17 @@ var Path = PathItem.extend(/** @lends Path# */{
// NOTE: Documentation is in PathItem#flatten()
flatten: function(flatness) {
// Use PathIterator to subdivide the curves into parts that are flat
// Use PathFlattener to subdivide the curves into parts that are flat
// enough, as specified by `flatness` / Curve.isFlatEnough():
var iterator = new PathIterator(this, flatness || 0.25, 256, true),
parts = iterator.parts,
var flattener = new PathFlattener(this, flatness || 0.25, 256, true),
parts = flattener.parts,
length = parts.length,
segments = [];
for (var i = 0; i < length; i++) {
segments.push(new Segment(parts[i].curve.slice(0, 2)));
}
if (!this._closed && length > 0) {
// We need to explicitly add the end point of the last curve on open paths.
// Explicitly add the end point of the last curve on open paths.
segments.push(new Segment(parts[length - 1].curve.slice(6)));
}
this.setSegments(segments);
@ -2260,12 +2260,12 @@ new function() { // Scope for drawing
if (hasStroke) {
if (dashLength) {
// We cannot use the path created by drawSegments above
// Use PathIterator to draw dashed paths:
// Use PathFlattener to draw dashed paths:
if (!dontStart)
ctx.beginPath();
var iterator = new PathIterator(this, 0.25, 32, false,
var flattener = new PathFlattener(this, 0.25, 32, false,
strokeMatrix),
length = iterator.length,
length = flattener.length,
from = -style.getDashOffset(), to,
i = 0;
from = from % length;
@ -2277,7 +2277,7 @@ new function() { // Scope for drawing
while (from < length) {
to = from + getOffset(i++);
if (from > 0 || to > 0)
iterator.drawPart(ctx,
flattener.drawPart(ctx,
Math.max(from, 0), Math.max(to, 0));
from = to + getOffset(i++);
}

View file

@ -11,22 +11,22 @@
*/
/**
* @name PathIterator
* @name PathFlattener
* @class
* @private
*/
var PathIterator = Base.extend({
_class: 'PathIterator',
var PathFlattener = Base.extend({
_class: 'PathFlattener',
/**
* Creates a path iterator for the given path. The iterator converts curves
* into a sequence of straight lines by the use of curve-subdivision with an
* allowed maximum error to create a lookup table that maps curve-time to
* path offsets, and can be used for efficient iteration over the full
* length of the path, and getting points / tangents / normals and curvature
* in path offset space.
* Creates a path flattener for the given path. The flattener converts
* curves into a sequence of straight lines by the use of curve-subdivision
* with an allowed maximum error to create a lookup table that maps curve-
* time to path offsets, and can be used for efficient iteration over the
* full length of the path, and getting points / tangents / normals and
* curvature in path offset space.
*
* @param {Path} path the path to create the iterator for
* @param {Path} path the path to create the flattener for
* @param {Number} [flatness=0.25] the maximum error allowed for the
* straight lines to deviate from the original curves
* @param {Number} [maxRecursion=32] the maximum amount of recursion in
@ -37,7 +37,7 @@ var PathIterator = Base.extend({
* translation
* @param {Matrix} [matrix] the matrix by which to transform the path's
* coordinates without modifying the actual path.
* @return {PathIterator} the newly created path iterator
* @return {PathFlattener} the newly created path flattener
*/
initialize: function(path, flatness, maxRecursion, ignoreStraight, matrix) {
// Instead of relying on path.curves, we only use segments here and
@ -100,7 +100,7 @@ var PathIterator = Base.extend({
this.parts = parts;
this.length = length;
// Keep a current index from the part where we last where in
// _get(), to optimise for iterator-like usage of iterator.
// _get(), to optimise for iterator-like usage of flattener.
this.index = 0;
},