From 34dc0e1589c266f6634bfe741bdb6bbd0468d844 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Fri, 15 Jan 2016 12:10:43 +0100 Subject: [PATCH] Fix geometric and catmull-rom smooth on closed paths. --- src/path/Path.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/path/Path.js b/src/path/Path.js index ee2c1265..660ab0f6 100644 --- a/src/path/Path.js +++ b/src/path/Path.js @@ -2087,10 +2087,10 @@ var Path = PathItem.extend(/** @lends Path# */{ type = opts.type || 'asymmetric', segments = this._segments, 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), - to = getIndex(opts.to, length - 1), - closed = this._closed; + to = getIndex(opts.to, length - 1); if (from > to) { if (closed) { from -= length; @@ -2117,7 +2117,6 @@ var Path = PathItem.extend(/** @lends Path# */{ n = amount - 1, // Overlap by up to 4 points on closed paths since a current // segment is affected by its 4 neighbors on both sides (?). - loop = closed && !range, padding = loop ? min(amount, 4) : 1, paddingLeft = padding, paddingRight = padding, @@ -2206,7 +2205,7 @@ var Path = PathItem.extend(/** @lends Path# */{ // All other smoothing methods are handled directly on the segments: for (var i = from; i <= to; i++) { segments[i < 0 ? i + length : i].smooth(opts, - i === from, i === to); + !loop && i === from, !loop && i === to); } } }