From 36b70fcdf2dc76b10f52660517e4819863c11f7c Mon Sep 17 00:00:00 2001 From: Fen Dweller Date: Mon, 22 Jun 2020 13:10:01 -0400 Subject: [PATCH] Center the horiziontal axis --- macrovision.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/macrovision.js b/macrovision.js index d07df88a..e20dd933 100644 --- a/macrovision.js +++ b/macrovision.js @@ -470,11 +470,15 @@ function drawHorizontalScale(ifDirty = false) { if (ifDirty && !worldSizeDirty) return; function drawTicks(/** @type {CanvasRenderingContext2D} */ ctx, pixelsPer, heightPer) { - console.log(heightPer); let total = heightPer.clone(); total.value = math.unit(-config.x, "meters").toNumber(config.unit); + + // further adjust it to put the current position in the center + + total.value -= heightPer.toNumber("meters") / pixelsPer * (canvasWidth + 50) / 2; let x = ctx.canvas.clientWidth - 50; + let offset = total.toNumber("meters") % heightPer.toNumber("meters"); x += offset / heightPer.toNumber("meters") * pixelsPer;