From 74a0010e59c61c0dc8d4ffa70ec9bfdaa70e92d0 Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Mon, 12 Jun 2017 20:46:50 +0100 Subject: [PATCH] [client] Tidy up translations --- Nibriboard/ClientFiles/BoardWindow.js | 11 ++++++++++- Nibriboard/ClientFiles/ChunkCache.js | 8 -------- Nibriboard/ClientFiles/Pencil.js | 7 +------ 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/Nibriboard/ClientFiles/BoardWindow.js b/Nibriboard/ClientFiles/BoardWindow.js index 850b063..8b5fa97 100644 --- a/Nibriboard/ClientFiles/BoardWindow.js +++ b/Nibriboard/ClientFiles/BoardWindow.js @@ -227,6 +227,13 @@ class BoardWindow extends EventEmitter if(this.displayGrid) this.renderGrid(canvas, context); + + context.save(); + context.translate( + -this.viewport.x, + -this.viewport.y + ); + // Only render the visible chunks if the chunk cache has been created // The chunk cache is only created once the ripple link connects successfully // to the nibriboard server. @@ -236,7 +243,9 @@ class BoardWindow extends EventEmitter this.renderOthers(canvas, context); // Render the currently active line if(typeof this.pencil !== "undefined") - this.pencil.render(this.viewport, canvas, context); + this.pencil.render(canvas, context); + + context.restore(); context.restore(); } diff --git a/Nibriboard/ClientFiles/ChunkCache.js b/Nibriboard/ClientFiles/ChunkCache.js index 017fa73..72b8d4e 100644 --- a/Nibriboard/ClientFiles/ChunkCache.js +++ b/Nibriboard/ClientFiles/ChunkCache.js @@ -54,14 +54,6 @@ class ChunkCache (Math.floor((visibleArea.y + (visibleArea.height / visibleArea.zoomLevel)) / chunkSize) * chunkSize) ); - /*context.translate( - -Math.abs(visibleArea.x - chunkArea.x), - -Math.abs(visibleArea.y - chunkArea.y) - );*/ - context.translate( - -visibleArea.x, - -visibleArea.y - ); for(let cx = chunkArea.x; cx <= chunkArea.x + chunkArea.width; cx += chunkSize) { diff --git a/Nibriboard/ClientFiles/Pencil.js b/Nibriboard/ClientFiles/Pencil.js index d42616e..cd47114 100644 --- a/Nibriboard/ClientFiles/Pencil.js +++ b/Nibriboard/ClientFiles/Pencil.js @@ -143,17 +143,12 @@ class Pencil * @param {HTMLCanvasElement} canvas The canvas to draw to. * @param {CanvasRenderingContext2D} context The rendering context to use to draw to the canvas. */ - render(visibleArea, canvas, context) { + render(canvas, context) { if(this.currentLineSegments.length == 0) return; context.save(); - context.translate( - -visibleArea.x, - -visibleArea.y - ); - context.beginPath(); context.moveTo(this.currentLineSegments[0].x, this.currentLineSegments[0].y); for(let i = 1; i < this.currentLineSegments.length; i++) {