From 724ea4912eb21ae82b777fba581cf3ffb4b3033f Mon Sep 17 00:00:00 2001 From: Fen Dweller Date: Thu, 3 Jun 2021 13:06:34 -0500 Subject: [PATCH] Store the ratio-info area instead of searching for it constantly --- macrovision.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/macrovision.js b/macrovision.js index a9b0baec..7c81dfcf 100644 --- a/macrovision.js +++ b/macrovision.js @@ -529,6 +529,8 @@ function updateEntityElement(entity, element) { } } +let ratioInfo + function updateRatios() { if (config.showRatios) { if (selectedEntity !== null && prevSelectedEntity !== null && selectedEntity !== prevSelectedEntity) { @@ -553,9 +555,9 @@ function updateRatios() { text += prevSelectedEntity.name + " looks " + math.format(apparentHeight, { precision: 3}) + " tall to " + selectedEntity.name; - document.querySelector(".ratio-info").innerText = text; + ratioInfo.innerText = text; } else { - document.querySelector(".ratio-info").innerText = ""; + //ratioInfo.innerText = ""; } } @@ -894,8 +896,7 @@ function drawHorizontalScale(ifDirty = false) { } function drawTick(/** @type {CanvasRenderingContext2D} */ ctx, x, y, label) { - const oldStroke = ctx.strokeStyle; - const oldFill = ctx.fillStyle; + ctx.save() ctx.beginPath(); ctx.moveTo(x, y); @@ -922,9 +923,7 @@ function drawHorizontalScale(ifDirty = false) { ctx.beginPath(); ctx.fillText(label, x + 35, y + 20); - ctx.font = oldFont; - ctx.strokeStyle = oldStroke; - ctx.fillStyle = oldFill; + ctx.restore() } const canvas = document.querySelector("#display"); @@ -3740,6 +3739,9 @@ function prepareEntities() { updateFilter(); }); + + ratioInfo = document.body.querySelector(".ratio-info") + } // Only display authors and owners if they appear