From 378fa3d9f00b19988b12857e40dd5896020ce9d4 Mon Sep 17 00:00:00 2001 From: qweasz687 <66411718+qweasz687@users.noreply.github.com> Date: Mon, 16 Nov 2020 19:57:31 +0800 Subject: [PATCH 1/2] Update ui.js --- libs/ui.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/ui.js b/libs/ui.js index e3b5e925..27fe1715 100644 --- a/libs/ui.js +++ b/libs/ui.js @@ -538,11 +538,11 @@ ui.prototype.splitLines = function (name, text, maxWidth, font) { } ////// 绘制一张图片 ////// -ui.prototype.drawImage = function (name, image, x, y, w, h, x1, y1, w1, h1, angle) { +ui.prototype.drawImage = function (name, image, x, y, w, h, x1, y1, w1, h1, angle, reverse) { // 检测文件名以 :x, :y, :o 结尾,表示左右翻转,上下翻转和中心翻转 var ctx = this.getContextByName(name); if (!ctx) return; - var reverse = null; + // var reverse = null; if (typeof image == 'string') { if (image.endsWith(':x') || image.endsWith(':y') || image.endsWith(':o')) { reverse = image.charAt(image.length - 1); From 1d4286818a316758f8c65df744091858a5d60b27 Mon Sep 17 00:00:00 2001 From: qweasz687 <66411718+qweasz687@users.noreply.github.com> Date: Mon, 16 Nov 2020 19:59:41 +0800 Subject: [PATCH 2/2] Update maps.js --- libs/maps.js | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/libs/maps.js b/libs/maps.js index 08122217..58eb63e7 100644 --- a/libs/maps.js +++ b/libs/maps.js @@ -2561,25 +2561,20 @@ maps.prototype._drawAnimateFrame = function (name, animate, centerX, centerY, in frame.forEach(function (t) { var image = animate.images[t.index]; if (!image) return; + var realWidth = image.width * ratio * t.zoom / 100; var realHeight = image.height * ratio * t.zoom / 100; core.setAlpha(ctx, t.opacity / 255); var cx = centerX + t.x, cy = centerY + t.y; - if (!t.mirror && !t.angle) { - core.drawImage(ctx, image, cx - realWidth / 2 - core.bigmap.offsetX, cy - realHeight / 2 - core.bigmap.offsetY, realWidth, realHeight); - } - else { - core.saveCanvas(ctx); - ctx.translate(cx, cy); - if (t.angle) - ctx.rotate(-t.angle * Math.PI / 180); - if (t.mirror) - ctx.scale(-1, 1); - core.drawImage(ctx, image, -realWidth / 2 - core.bigmap.offsetX, -realHeight / 2 - core.bigmap.offsetY, realWidth, realHeight); - core.loadCanvas(ctx); - } + var ix = cx - realWidth / 2 - core.bigmap.offsetX, + iy = cy - realHeight / 2 - core.bigmap.offsetY; + + var mirror = t.mirror ? 'x' : null; + var angle = t.angle ? -t.angle * Math.PI / 180 : null; + core.drawImage(ctx, image, ix, iy, realWidth, realHeight, null, null, null, null, angle, mirror); + core.setAlpha(ctx, 1); }) }