From cfeba5950ce69735ca705061dc359d000a00ee8c Mon Sep 17 00:00:00 2001 From: Tony Brix Date: Sun, 9 Aug 2020 00:16:42 -0500 Subject: [PATCH 1/2] fix: prevent error when minimap squished --- lib/canvas-layer.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/canvas-layer.js b/lib/canvas-layer.js index 95189b94..b16b1446 100644 --- a/lib/canvas-layer.js +++ b/lib/canvas-layer.js @@ -61,11 +61,15 @@ module.exports = class CanvasLayer { } copyToOffscreen () { - this.offscreenContext.drawImage(this.canvas, 0, 0) + if (this.canvas.width > 0 && this.canvas.height > 0) { + this.offscreenContext.drawImage(this.canvas, 0, 0) + } } copyFromOffscreen () { - this.context.drawImage(this.offscreenCanvas, 0, 0) + if (this.offscreenCanvas.width > 0 && this.offscreenCanvas.height > 0) { + this.context.drawImage(this.offscreenCanvas, 0, 0) + } } copyPartFromOffscreen (srcY, destY, height) { From 1ec8f12cfda88099697d20ccdc7a57b2c6d5ec49 Mon Sep 17 00:00:00 2001 From: Tony Brix Date: Sat, 21 Nov 2020 00:02:46 -0600 Subject: [PATCH 2/2] fix: prevent error when width = 0 --- lib/canvas-layer.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/canvas-layer.js b/lib/canvas-layer.js index b16b1446..3b7d4b09 100644 --- a/lib/canvas-layer.js +++ b/lib/canvas-layer.js @@ -73,11 +73,13 @@ module.exports = class CanvasLayer { } copyPartFromOffscreen (srcY, destY, height) { - this.context.drawImage( - this.offscreenCanvas, - 0, srcY, this.offscreenCanvas.width, height, - 0, destY, this.offscreenCanvas.width, height - ) + if (this.offscreenCanvas.width > 0 && this.offscreenCanvas.height > 0) { + this.context.drawImage( + this.offscreenCanvas, + 0, srcY, this.offscreenCanvas.width, height, + 0, destY, this.offscreenCanvas.width, height + ) + } } clearCanvas () {