From 7aee907d5db22322e684c22230937ebcbe09f355 Mon Sep 17 00:00:00 2001 From: ShakeFlower Date: Thu, 6 Mar 2025 10:38:37 +0800 Subject: [PATCH] =?UTF-8?q?fix:(from=202.10.3)=E4=BF=AE=E5=A4=8D=E4=BA=86?= =?UTF-8?q?=E7=BC=A9=E6=94=BE=E8=BF=87=E5=B0=8F=E6=97=B6=E4=BC=9A=E6=9C=89?= =?UTF-8?q?=E7=94=BB=E9=9D=A2=E6=97=A0=E6=B3=95=E6=B8=85=E9=99=A4=E7=9A=84?= =?UTF-8?q?bug,=20=E4=BF=AE=E5=A4=8D=E4=BA=86=E7=BC=A9=E6=94=BE=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E6=97=B6=E7=94=BB=E5=B8=83=E5=A4=A7=E5=B0=8F=E4=B8=8D?= =?UTF-8?q?=E6=AD=A3=E7=A1=AE=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/control.js | 4 +--- libs/ui.js | 10 +++++++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/libs/control.js b/libs/control.js index a4a221bc..4b176d52 100644 --- a/libs/control.js +++ b/libs/control.js @@ -3511,9 +3511,7 @@ control.prototype._resize_canvas = function (obj) { } else { for (var name in core.dymCanvas) { var ctx = core.dymCanvas[name], canvas = ctx.canvas; - var ratio = canvas.hasAttribute('isHD') ? core.domStyle.ratio : 1; - canvas.style.width = canvas.width / ratio * core.domStyle.scale + "px"; - canvas.style.height = canvas.height / ratio * core.domStyle.scale + "px"; + core.resizeCanvas(ctx, parseFloat(canvas.getAttribute("_width")), parseFloat(canvas.getAttribute("_height"))); canvas.style.left = parseFloat(canvas.getAttribute("_left")) * core.domStyle.scale + "px"; canvas.style.top = parseFloat(canvas.getAttribute("_top")) * core.domStyle.scale + "px"; } diff --git a/libs/ui.js b/libs/ui.js index 5ca53c49..1e178ef4 100644 --- a/libs/ui.js +++ b/libs/ui.js @@ -64,7 +64,13 @@ ui.prototype.clearMap = function (name, x, y, width, height) { if (x != null && y != null && width != null && height != null) { ctx.clearRect(x, y, width, height); } else { - ctx.clearRect(-32, -32, ctx.canvas.width + 32, ctx.canvas.height + 32); + if (ctx.canvas.getAttribute('isHD')) { + const width = ctx.canvas.width / core.domStyle.scale / devicePixelRatio; + const height = ctx.canvas.height / core.domStyle.scale / devicePixelRatio; + ctx.clearRect(0, 0, width, height); + } else { + ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height); + } } } } @@ -3446,6 +3452,8 @@ ui.prototype.createCanvas = function (name, x, y, width, height, z) { newCanvas.style.display = 'block'; newCanvas.setAttribute("_left", x); newCanvas.setAttribute("_top", y); + newCanvas.setAttribute("_width", width); + newCanvas.setAttribute("_height", height); newCanvas.style.width = width * core.domStyle.scale + 'px'; newCanvas.style.height = height * core.domStyle.scale + 'px'; newCanvas.style.left = x * core.domStyle.scale + 'px';