From 49dc3b0a75dcc05c77a12678266bd9173e952bb1 Mon Sep 17 00:00:00 2001 From: Sam El-Husseini <16690124+samelhusseini@users.noreply.github.com> Date: Thu, 8 Mar 2018 14:34:27 -0800 Subject: [PATCH] Fix resizing of screen canvas to ensure it fits within the area in the ev3 svg (#365) --- sim/visuals/board.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sim/visuals/board.ts b/sim/visuals/board.ts index 29103832..fe4f9c04 100644 --- a/sim/visuals/board.ts +++ b/sim/visuals/board.ts @@ -504,12 +504,12 @@ namespace pxsim.visuals { const bBox = this.layoutView.getBrick().getScreenBBox(); if (!bBox || bBox.width == 0) return; - const scale = (bBox.width - 4) / SCREEN_WIDTH; - this.screenScaledWidth = (bBox.width - 4); - this.screenScaledHeight = this.screenScaledWidth / SCREEN_WIDTH * SCREEN_HEIGHT; + const scale = (bBox.height - 2) / SCREEN_HEIGHT; + this.screenScaledHeight = (bBox.height - 2); + this.screenScaledWidth = this.screenScaledHeight / SCREEN_HEIGHT * SCREEN_WIDTH; - this.screenCanvas.style.top = `${bBox.top + 2}px`; - this.screenCanvas.style.left = `${bBox.left + 2}px`; + this.screenCanvas.style.top = `${bBox.top + 1}px`; + this.screenCanvas.style.left = `${bBox.left + ((bBox.width - this.screenScaledWidth) * 0.5)}px`; this.screenCanvas.width = this.screenScaledWidth; this.screenCanvas.height = this.screenScaledHeight;