fix:(from 2.10.3)修复了缩放过小时会有画面无法清除的bug, 修复了缩放修改时画布大小不正确的bug

This commit is contained in:
ShakeFlower 2025-03-06 10:38:37 +08:00
parent ffd8beebf9
commit 7aee907d5d
2 changed files with 10 additions and 4 deletions

View File

@ -3511,9 +3511,7 @@ control.prototype._resize_canvas = function (obj) {
} else { } else {
for (var name in core.dymCanvas) { for (var name in core.dymCanvas) {
var ctx = core.dymCanvas[name], canvas = ctx.canvas; var ctx = core.dymCanvas[name], canvas = ctx.canvas;
var ratio = canvas.hasAttribute('isHD') ? core.domStyle.ratio : 1; core.resizeCanvas(ctx, parseFloat(canvas.getAttribute("_width")), parseFloat(canvas.getAttribute("_height")));
canvas.style.width = canvas.width / ratio * core.domStyle.scale + "px";
canvas.style.height = canvas.height / ratio * core.domStyle.scale + "px";
canvas.style.left = parseFloat(canvas.getAttribute("_left")) * core.domStyle.scale + "px"; canvas.style.left = parseFloat(canvas.getAttribute("_left")) * core.domStyle.scale + "px";
canvas.style.top = parseFloat(canvas.getAttribute("_top")) * core.domStyle.scale + "px"; canvas.style.top = parseFloat(canvas.getAttribute("_top")) * core.domStyle.scale + "px";
} }

View File

@ -64,7 +64,13 @@ ui.prototype.clearMap = function (name, x, y, width, height) {
if (x != null && y != null && width != null && height != null) { if (x != null && y != null && width != null && height != null) {
ctx.clearRect(x, y, width, height); ctx.clearRect(x, y, width, height);
} else { } 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.style.display = 'block';
newCanvas.setAttribute("_left", x); newCanvas.setAttribute("_left", x);
newCanvas.setAttribute("_top", y); newCanvas.setAttribute("_top", y);
newCanvas.setAttribute("_width", width);
newCanvas.setAttribute("_height", height);
newCanvas.style.width = width * core.domStyle.scale + 'px'; newCanvas.style.width = width * core.domStyle.scale + 'px';
newCanvas.style.height = height * core.domStyle.scale + 'px'; newCanvas.style.height = height * core.domStyle.scale + 'px';
newCanvas.style.left = x * core.domStyle.scale + 'px'; newCanvas.style.left = x * core.domStyle.scale + 'px';