Skip to content

Commit

Permalink
ignore errors
Browse files Browse the repository at this point in the history
  • Loading branch information
634750802 committed Jun 25, 2023
1 parent 608f327 commit 3945895
Showing 1 changed file with 28 additions and 14 deletions.
42 changes: 28 additions & 14 deletions context2d.patch.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,20 @@ export function patchContext2D(CanvasRenderingContext2D, Path2D) {
stroke.apply(this, arguments)
return
}
this.canvas._roughEnabled = false;
this.canvas._rough.path(toSvgString(this._path), {
fill: 'none',
stroke: this.strokeStyle,
strokeWidth: this.lineWidth,
})
this.canvas._roughEnabled = true;
try {
this.canvas._roughEnabled = false;
this.canvas._rough.path(toSvgString(this._path), {
fill: 'none',
stroke: this.strokeStyle,
strokeWidth: this.lineWidth,
})
this.canvas._roughEnabled = true;
} catch (e) {
console.error(e);
stroke.apply(this, arguments)
} finally {
this.canvas._roughEnabled = true;
}
}

CanvasRenderingContext2D.prototype.fill = function (path) {
Expand All @@ -59,13 +66,20 @@ export function patchContext2D(CanvasRenderingContext2D, Path2D) {
fill.apply(this, arguments)
return
}
this.canvas._roughEnabled = false;
this.canvas._rough.path(toSvgString(this._path), {
fill: this.fillStyle,
stroke: this.strokeStyle === 'rgba(0, 0, 0, 0)' ? 'none' : this.strokeStyle,
strokeWidth: this.lineWidth,
})
this.canvas._roughEnabled = true;
try {
this.canvas._roughEnabled = false;
this.canvas._rough.path(toSvgString(this._path), {
fill: this.fillStyle,
stroke: this.strokeStyle === 'rgba(0, 0, 0, 0)' ? 'none' : this.strokeStyle,
strokeWidth: this.lineWidth,
})
this.canvas._roughEnabled = true;
} catch (e) {
console.error(e);
fill.apply(this, arguments)
} finally {
this.canvas._roughEnabled = true;
}
};

names.forEach(name => {
Expand Down

0 comments on commit 3945895

Please sign in to comment.