浏览代码

Fix slight error in calculating width and height

master
Fen Dweller 5 年前
父节点
当前提交
e4a6ae2d7d
共有 1 个文件被更改,包括 3 次插入4 次删除
  1. +3
    -4
      xray.js

+ 3
- 4
xray.js 查看文件

@@ -17,7 +17,7 @@ let scale;

document.addEventListener("DOMContentLoaded", e => {
document.querySelector("#reset-button").addEventListener("click", reset);
document.querySelector("#load-button").addEventListener("click", e => {
console.log("Trying to load...");
const baseInput = document.querySelector("#base-url").value;
@@ -329,11 +329,10 @@ function setup() {
const scaleH = availableHeight / baseImg.height;
scale = Math.min(scaleW, scaleH);

const width = availableWidth * scale / scaleW;
const height = availableHeight * scale / scaleH;
width = Math.floor(availableWidth * scale / scaleW);
height = Math.floor(availableHeight * scale / scaleH);

[baseCtx, baseCtxResized, overlayCtx, overlayCtxResized].forEach(ctx => {
console.log(ctx.canvas)
ctx.canvas.width = width;
ctx.canvas.height = height;
ctx.canvas.style.left = (availableWidth - width) / 2 + "px";


正在加载...
取消
保存