bugfix: ensure that canvas scale is at least 1x

This commit is contained in:
Colin McMillen 2019-09-25 15:49:19 -04:00
parent 3e9a45a7c3
commit e13c4d0985

View File

@ -8,6 +8,10 @@ const Orientation = {
RIGHT: 'right'
}
function bound(low, x, high) {
return Math.max(low, Math.min(x, high));
}
class Input {
constructor() {
this.up = false;
@ -524,7 +528,7 @@ function setCanvasScale(scale) {
function setAutoCanvasScale() {
const widthAspect = Math.floor(window.innerWidth / SNES_WIDTH);
const heightAspect = Math.floor(window.innerHeight / SNES_HEIGHT);
const scale = Math.min(widthAspect, heightAspect)
const scale = bound(1, Math.min(widthAspect, heightAspect), 8);
setCanvasScale(scale);
}