From 5a0cefbfbb908cd82a88f974296fada93a7464ba Mon Sep 17 00:00:00 2001 From: miteruzo Date: Fri, 9 Feb 2024 03:55:02 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=AA=E3=83=95=E3=82=A1=E3=82=AF=E3=82=BF?= =?UTF-8?q?=E3=83=AA=E3=83=B3=E3=82=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/paint.js | 58 +++++++++++++++++++++++++----------------------- 1 file changed, 30 insertions(+), 28 deletions(-) diff --git a/scripts/paint.js b/scripts/paint.js index c5f4e50..807f9c9 100644 --- a/scripts/paint.js +++ b/scripts/paint.js @@ -892,46 +892,48 @@ closeModal () function applyResolution () { - if (!(((changeWidth.value < canvasRoot.width) - || changeHeight.value < canvasRoot.height) - && !(window.confirm ('指定されている幅もしくは高さの値がサイズ変更前よりも小さいです.\nこのままだと右端もしくは下端が変更後のサイズに合わせてカットされてしまいます.\nよろしいかな?????')))) - { - canvasWidth = Math.max (32, Math.min (changeWidth.value, 640)); - canvasHeight = Math.max (24, Math.min (changeHeight.value, 480)); - - canvasArea.style.width = canvasWidth + 'px'; - canvasArea.style.height = canvasHeight + 'px'; + if ((changeWidth.value >= canvasRoot.width) + && (changeHeight.value >= canvasRoot.height)) + return; - for (let i = 0; i < layerMax; ++i) - { - const canvas4replace = document.createElement ('canvas'); + if (!(window.confirm ('指定されている幅もしくは高さの値がサイズ変更前よりも小さいです.\nこのままだと右端もしくは下端が変更後のサイズに合わせてカットされてしまいます.\nよろしいかな?????'))) + return; - canvas4replace.width = canvasWidth; - canvas4replace.height = canvasHeight; + canvasWidth = Math.max (32, Math.min (changeWidth.value, 640)); + canvasHeight = Math.max (24, Math.min (changeHeight.value, 480)); - const canvas4replaceCtx = canvas4replace.getContext ('2d'); + canvasArea.style.width = canvasWidth + 'px'; + canvasArea.style.height = canvasHeight + 'px'; - if (i == 0) - { - canvas4replaceCtx.fillStyle = 'white'; - canvas4replaceCtx.fillRect (0, 0, canvasWidth, canvasHeight); - } + for (let i = 0; i < layerMax; ++i) + { + const canvas4replace = document.createElement ('canvas'); - canvas4replaceCtx.drawImage (canvas[i], 0, 0); + canvas4replace.width = canvasWidth; + canvas4replace.height = canvasHeight; - canvas[i].width = canvasWidth; - canvas[i].height = canvasHeight; + const canvas4replaceCtx = canvas4replace.getContext ('2d'); - canvasCtx[i].drawImage (canvas4replace, 0, 0); + if (i == 0) + { + canvas4replaceCtx.fillStyle = 'white'; + canvas4replaceCtx.fillRect (0, 0, canvasWidth, canvasHeight); } - canvasPerfect.width = canvasRoot.width = canvasWidth; - canvasPerfect.height = canvasRoot.height = canvasHeight; + canvas4replaceCtx.drawImage (canvas[i], 0, 0); - reDraw (); + canvas[i].width = canvasWidth; + canvas[i].height = canvasHeight; - closeModal (); + canvasCtx[i].drawImage (canvas4replace, 0, 0); } + + canvasPerfect.width = canvasRoot.width = canvasWidth; + canvasPerfect.height = canvasRoot.height = canvasHeight; + + reDraw (); + + closeModal (); }