リファクタリング
This commit is contained in:
+33
-31
@@ -892,46 +892,48 @@ closeModal ()
|
|||||||
function
|
function
|
||||||
applyResolution ()
|
applyResolution ()
|
||||||
{
|
{
|
||||||
if (!(((changeWidth.value < canvasRoot.width)
|
if ((changeWidth.value >= canvasRoot.width)
|
||||||
|| changeHeight.value < canvasRoot.height)
|
&& (changeHeight.value >= canvasRoot.height))
|
||||||
&& !(window.confirm ('指定されている幅もしくは高さの値がサイズ変更前よりも小さいです.\nこのままだと右端もしくは下端が変更後のサイズに合わせてカットされてしまいます.\nよろしいかな?????'))))
|
return;
|
||||||
|
|
||||||
|
if (!(window.confirm ('指定されている幅もしくは高さの値がサイズ変更前よりも小さいです.\nこのままだと右端もしくは下端が変更後のサイズに合わせてカットされてしまいます.\nよろしいかな?????')))
|
||||||
|
return;
|
||||||
|
|
||||||
|
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';
|
||||||
|
|
||||||
|
for (let i = 0; i < layerMax; ++i)
|
||||||
{
|
{
|
||||||
canvasWidth = Math.max (32, Math.min (changeWidth.value, 640));
|
const canvas4replace = document.createElement ('canvas');
|
||||||
canvasHeight = Math.max (24, Math.min (changeHeight.value, 480));
|
|
||||||
|
|
||||||
canvasArea.style.width = canvasWidth + 'px';
|
canvas4replace.width = canvasWidth;
|
||||||
canvasArea.style.height = canvasHeight + 'px';
|
canvas4replace.height = canvasHeight;
|
||||||
|
|
||||||
for (let i = 0; i < layerMax; ++i)
|
const canvas4replaceCtx = canvas4replace.getContext ('2d');
|
||||||
|
|
||||||
|
if (i == 0)
|
||||||
{
|
{
|
||||||
const canvas4replace = document.createElement ('canvas');
|
canvas4replaceCtx.fillStyle = 'white';
|
||||||
|
canvas4replaceCtx.fillRect (0, 0, canvasWidth, canvasHeight);
|
||||||
canvas4replace.width = canvasWidth;
|
|
||||||
canvas4replace.height = canvasHeight;
|
|
||||||
|
|
||||||
const canvas4replaceCtx = canvas4replace.getContext ('2d');
|
|
||||||
|
|
||||||
if (i == 0)
|
|
||||||
{
|
|
||||||
canvas4replaceCtx.fillStyle = 'white';
|
|
||||||
canvas4replaceCtx.fillRect (0, 0, canvasWidth, canvasHeight);
|
|
||||||
}
|
|
||||||
|
|
||||||
canvas4replaceCtx.drawImage (canvas[i], 0, 0);
|
|
||||||
|
|
||||||
canvas[i].width = canvasWidth;
|
|
||||||
canvas[i].height = canvasHeight;
|
|
||||||
|
|
||||||
canvasCtx[i].drawImage (canvas4replace, 0, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
canvasPerfect.width = canvasRoot.width = canvasWidth;
|
canvas4replaceCtx.drawImage (canvas[i], 0, 0);
|
||||||
canvasPerfect.height = canvasRoot.height = canvasHeight;
|
|
||||||
|
|
||||||
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 ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user