Skip to content

Commit 64d5a98

Browse files
committed
Fix incorrect canvas buffer dimension
1 parent 4063546 commit 64d5a98

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

js/libs/Board.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,19 +47,19 @@ var Board = (function() {
4747
var bufferCanvas = document.createElement('canvas');
4848
var bufferCtx = bufferCanvas.getContext('2d');
4949

50-
bufferCanvas.width = widthCanvas;
51-
bufferCanvas.height = heightCanvas;
50+
bufferCanvas.width = this.domMem.width;
51+
bufferCanvas.height = this.domMem.height;
5252

5353
// Clear buffer
5454
bufferCtx.fillStyle = '#ffffff';
5555
bufferCtx.fillRect(0, 0, widthCanvas, heightCanvas);
5656

5757
// Save canvas to buffer
5858
bufferCtx.drawImage(this.dom, 0, 0);
59-
59+
6060
// Resize memory
61-
this.domMem.width = widthCanvas;
62-
this.domMem.height = heightCanvas;
61+
if (this.domMem.width < widthCanvas) this.domMem.width = widthCanvas;
62+
if (this.domMem.height < heightCanvas) this.domMem.height = heightCanvas;
6363
this.ctxMem.drawImage(bufferCanvas, 0, 0);
6464
} else {
6565
this.ctxMem.drawImage(this.dom, 0 ,0);

0 commit comments

Comments
 (0)