Browse Source

Center the horiziontal axis

master
Fen Dweller 5 years ago
parent
commit
36b70fcdf2
1 changed files with 5 additions and 1 deletions
  1. +5
    -1
      macrovision.js

+ 5
- 1
macrovision.js View File

@@ -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;


Loading…
Cancel
Save