From c49fe4d6a05bd32a0e2816bbd5887122027a1ba6 Mon Sep 17 00:00:00 2001 From: Julian Descottes Date: Thu, 9 Jun 2016 11:05:59 +0200 Subject: [PATCH] Issue #483 - limit zoom to have 10 sprite pixels displayed on screen --- src/js/Constants.js | 2 -- src/js/rendering/frame/FrameRenderer.js | 9 ++++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/js/Constants.js b/src/js/Constants.js index 90f0fd01..f6ac4519 100644 --- a/src/js/Constants.js +++ b/src/js/Constants.js @@ -14,8 +14,6 @@ var Constants = { MAX_PALETTE_COLORS : 100, - MINIMUM_ZOOM : 1, - PREVIEW_FILM_SIZE : 96, ANIMATED_PREVIEW_WIDTH : 200, diff --git a/src/js/rendering/frame/FrameRenderer.js b/src/js/rendering/frame/FrameRenderer.js index 0ea7723b..c9b610ce 100644 --- a/src/js/rendering/frame/FrameRenderer.js +++ b/src/js/rendering/frame/FrameRenderer.js @@ -75,9 +75,12 @@ }; ns.FrameRenderer.prototype.setZoom = function (zoom) { - if (zoom < Constants.MINIMUM_ZOOM) { - zoom = Constants.MINIMUM_ZOOM; - } + // Minimum zoom is one to ensure one sprite pixel occupies at least one pixel on screen. + var minimumZoom = 1; + // Maximum zoom is relative to the display dimensions to ensure at least 10 pixels can + // be drawn on screen. + var maximumZoom = Math.min(this.displayWidth, this.displayHeight) / 10; + zoom = pskl.utils.Math.minmax(zoom, minimumZoom, maximumZoom); if (zoom == this.zoom) { return;