fix(core): Make Path.clean() check for valid paths before returning
A path that has no drawing operations or only a move operation causes problems with the path offset code. This will cause Path.clean() to return false in such a case, which in turn will cause Path.__asPath() to return false when called from the offset code. We check this return value in the offset code and do not push this segment to the offsetted path. This fixes #3038 This closes #3056
This commit is contained in:
parent
a764ebb6cb
commit
5ba6e12469
1 changed files with 6 additions and 2 deletions
|
@ -192,7 +192,8 @@ Path.prototype.clean = function () {
|
|||
|
||||
if (ops.length < this.ops.length) this.ops = ops
|
||||
|
||||
return this
|
||||
// A path with not drawing operations or only a move is not path at all
|
||||
return ops.length === 0 || (ops.length === 1 && ops[0].type === 'move') ? false : this
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1311,7 +1312,10 @@ function __pathOffset(path, distance, log) {
|
|||
{ x: cp2.x, y: cp2.y },
|
||||
{ x: op.to.x, y: op.to.y }
|
||||
)
|
||||
for (let bezier of b.offset(distance)) offset.push(__asPath(bezier, path.log))
|
||||
for (let bezier of b.offset(distance)) {
|
||||
const segment = __asPath(bezier, path.log)
|
||||
if (segment) offset.push(segment)
|
||||
}
|
||||
} else if (op.type === 'close') closed = true
|
||||
if (op.to) current = op.to
|
||||
if (!start) start = current
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue