mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-07 13:22:07 -05:00
Fix geometric and catmull-rom smooth on closed paths.
This commit is contained in:
parent
af799976d4
commit
34dc0e1589
1 changed files with 4 additions and 5 deletions
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue