Просмотр исходного кода

Store the ratio-info area instead of searching for it constantly

master
Fen Dweller 4 лет назад
Родитель
Сommit
724ea4912e
1 измененных файлов: 9 добавлений и 7 удалений
  1. +9
    -7
      macrovision.js

+ 9
- 7
macrovision.js Просмотреть файл

@@ -529,6 +529,8 @@ function updateEntityElement(entity, element) {
} }
} }


let ratioInfo

function updateRatios() { function updateRatios() {
if (config.showRatios) { if (config.showRatios) {
if (selectedEntity !== null && prevSelectedEntity !== null && selectedEntity !== prevSelectedEntity) { 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; text += prevSelectedEntity.name + " looks " + math.format(apparentHeight, { precision: 3}) + " tall to " + selectedEntity.name;
document.querySelector(".ratio-info").innerText = text;
ratioInfo.innerText = text;
} else { } else {
document.querySelector(".ratio-info").innerText = "";
//ratioInfo.innerText = "";
} }
} }
@@ -894,8 +896,7 @@ function drawHorizontalScale(ifDirty = false) {
} }


function drawTick(/** @type {CanvasRenderingContext2D} */ ctx, x, y, label) { function drawTick(/** @type {CanvasRenderingContext2D} */ ctx, x, y, label) {
const oldStroke = ctx.strokeStyle;
const oldFill = ctx.fillStyle;
ctx.save()


ctx.beginPath(); ctx.beginPath();
ctx.moveTo(x, y); ctx.moveTo(x, y);
@@ -922,9 +923,7 @@ function drawHorizontalScale(ifDirty = false) {
ctx.beginPath(); ctx.beginPath();
ctx.fillText(label, x + 35, y + 20); ctx.fillText(label, x + 35, y + 20);


ctx.font = oldFont;
ctx.strokeStyle = oldStroke;
ctx.fillStyle = oldFill;
ctx.restore()
} }
const canvas = document.querySelector("#display"); const canvas = document.querySelector("#display");


@@ -3740,6 +3739,9 @@ function prepareEntities() {


updateFilter(); updateFilter();
}); });

ratioInfo = document.body.querySelector(".ratio-info")

} }


// Only display authors and owners if they appear // Only display authors and owners if they appear


Загрузка…
Отмена
Сохранить