Fix geometric and catmull-rom smooth on closed paths.

This commit is contained in:
Jürg Lehni 2016-01-15 12:10:43 +01:00
parent af799976d4
commit 34dc0e1589

View file

@ -2087,10 +2087,10 @@ var Path = PathItem.extend(/** @lends Path# */{
type = opts.type || 'asymmetric', type = opts.type || 'asymmetric',
segments = this._segments, segments = this._segments,
length = segments.length, length = segments.length,
range = opts.from !== undefined || opts.to !== undefined, closed = this._closed,
loop = closed && opts.from === undefined && opts.to === undefined,
from = getIndex(opts.from, 0), from = getIndex(opts.from, 0),
to = getIndex(opts.to, length - 1), to = getIndex(opts.to, length - 1);
closed = this._closed;
if (from > to) { if (from > to) {
if (closed) { if (closed) {
from -= length; from -= length;
@ -2117,7 +2117,6 @@ var Path = PathItem.extend(/** @lends Path# */{
n = amount - 1, n = amount - 1,
// Overlap by up to 4 points on closed paths since a current // Overlap by up to 4 points on closed paths since a current
// segment is affected by its 4 neighbors on both sides (?). // segment is affected by its 4 neighbors on both sides (?).
loop = closed && !range,
padding = loop ? min(amount, 4) : 1, padding = loop ? min(amount, 4) : 1,
paddingLeft = padding, paddingLeft = padding,
paddingRight = padding, paddingRight = padding,
@ -2206,7 +2205,7 @@ var Path = PathItem.extend(/** @lends Path# */{
// All other smoothing methods are handled directly on the segments: // All other smoothing methods are handled directly on the segments:
for (var i = from; i <= to; i++) { for (var i = from; i <= to; i++) {
segments[i < 0 ? i + length : i].smooth(opts, segments[i < 0 ? i + length : i].smooth(opts,
i === from, i === to); !loop && i === from, !loop && i === to);
} }
} }
} }