mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -05:00
Rename PathIterator back to PathFlattener.
This commit is contained in:
parent
753b27afe0
commit
a29ada8f23
3 changed files with 21 additions and 21 deletions
|
@ -77,7 +77,7 @@ var paper = function(self, undefined) {
|
||||||
/*#*/ if (__options.booleanOperations) {
|
/*#*/ if (__options.booleanOperations) {
|
||||||
/*#*/ include('path/PathItem.Boolean.js');
|
/*#*/ include('path/PathItem.Boolean.js');
|
||||||
/*#*/ }
|
/*#*/ }
|
||||||
/*#*/ include('path/PathIterator.js');
|
/*#*/ include('path/PathFlattener.js');
|
||||||
/*#*/ include('path/PathFitter.js');
|
/*#*/ include('path/PathFitter.js');
|
||||||
|
|
||||||
/*#*/ include('text/TextItem.js');
|
/*#*/ include('text/TextItem.js');
|
||||||
|
|
|
@ -1239,17 +1239,17 @@ var Path = PathItem.extend(/** @lends Path# */{
|
||||||
|
|
||||||
// NOTE: Documentation is in PathItem#flatten()
|
// NOTE: Documentation is in PathItem#flatten()
|
||||||
flatten: function(flatness) {
|
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():
|
// enough, as specified by `flatness` / Curve.isFlatEnough():
|
||||||
var iterator = new PathIterator(this, flatness || 0.25, 256, true),
|
var flattener = new PathFlattener(this, flatness || 0.25, 256, true),
|
||||||
parts = iterator.parts,
|
parts = flattener.parts,
|
||||||
length = parts.length,
|
length = parts.length,
|
||||||
segments = [];
|
segments = [];
|
||||||
for (var i = 0; i < length; i++) {
|
for (var i = 0; i < length; i++) {
|
||||||
segments.push(new Segment(parts[i].curve.slice(0, 2)));
|
segments.push(new Segment(parts[i].curve.slice(0, 2)));
|
||||||
}
|
}
|
||||||
if (!this._closed && length > 0) {
|
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)));
|
segments.push(new Segment(parts[length - 1].curve.slice(6)));
|
||||||
}
|
}
|
||||||
this.setSegments(segments);
|
this.setSegments(segments);
|
||||||
|
@ -2260,12 +2260,12 @@ new function() { // Scope for drawing
|
||||||
if (hasStroke) {
|
if (hasStroke) {
|
||||||
if (dashLength) {
|
if (dashLength) {
|
||||||
// We cannot use the path created by drawSegments above
|
// We cannot use the path created by drawSegments above
|
||||||
// Use PathIterator to draw dashed paths:
|
// Use PathFlattener to draw dashed paths:
|
||||||
if (!dontStart)
|
if (!dontStart)
|
||||||
ctx.beginPath();
|
ctx.beginPath();
|
||||||
var iterator = new PathIterator(this, 0.25, 32, false,
|
var flattener = new PathFlattener(this, 0.25, 32, false,
|
||||||
strokeMatrix),
|
strokeMatrix),
|
||||||
length = iterator.length,
|
length = flattener.length,
|
||||||
from = -style.getDashOffset(), to,
|
from = -style.getDashOffset(), to,
|
||||||
i = 0;
|
i = 0;
|
||||||
from = from % length;
|
from = from % length;
|
||||||
|
@ -2277,7 +2277,7 @@ new function() { // Scope for drawing
|
||||||
while (from < length) {
|
while (from < length) {
|
||||||
to = from + getOffset(i++);
|
to = from + getOffset(i++);
|
||||||
if (from > 0 || to > 0)
|
if (from > 0 || to > 0)
|
||||||
iterator.drawPart(ctx,
|
flattener.drawPart(ctx,
|
||||||
Math.max(from, 0), Math.max(to, 0));
|
Math.max(from, 0), Math.max(to, 0));
|
||||||
from = to + getOffset(i++);
|
from = to + getOffset(i++);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,22 +11,22 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @name PathIterator
|
* @name PathFlattener
|
||||||
* @class
|
* @class
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
var PathIterator = Base.extend({
|
var PathFlattener = Base.extend({
|
||||||
_class: 'PathIterator',
|
_class: 'PathFlattener',
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a path iterator for the given path. The iterator converts curves
|
* Creates a path flattener for the given path. The flattener converts
|
||||||
* into a sequence of straight lines by the use of curve-subdivision with an
|
* curves into a sequence of straight lines by the use of curve-subdivision
|
||||||
* allowed maximum error to create a lookup table that maps curve-time to
|
* with an allowed maximum error to create a lookup table that maps curve-
|
||||||
* path offsets, and can be used for efficient iteration over the full
|
* time to path offsets, and can be used for efficient iteration over the
|
||||||
* length of the path, and getting points / tangents / normals and curvature
|
* full length of the path, and getting points / tangents / normals and
|
||||||
* in path offset space.
|
* 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
|
* @param {Number} [flatness=0.25] the maximum error allowed for the
|
||||||
* straight lines to deviate from the original curves
|
* straight lines to deviate from the original curves
|
||||||
* @param {Number} [maxRecursion=32] the maximum amount of recursion in
|
* @param {Number} [maxRecursion=32] the maximum amount of recursion in
|
||||||
|
@ -37,7 +37,7 @@ var PathIterator = Base.extend({
|
||||||
* translation
|
* translation
|
||||||
* @param {Matrix} [matrix] the matrix by which to transform the path's
|
* @param {Matrix} [matrix] the matrix by which to transform the path's
|
||||||
* coordinates without modifying the actual path.
|
* 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) {
|
initialize: function(path, flatness, maxRecursion, ignoreStraight, matrix) {
|
||||||
// Instead of relying on path.curves, we only use segments here and
|
// Instead of relying on path.curves, we only use segments here and
|
||||||
|
@ -100,7 +100,7 @@ var PathIterator = Base.extend({
|
||||||
this.parts = parts;
|
this.parts = parts;
|
||||||
this.length = length;
|
this.length = length;
|
||||||
// Keep a current index from the part where we last where in
|
// 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;
|
this.index = 0;
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue