cgText切屏优化

This commit is contained in:
草莓 2025-04-16 17:15:18 +08:00
parent b8450d3672
commit b40a399c80

View File

@ -2774,7 +2774,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
const uictx = main.dom.outerUI.getContext("2d");
let now = 0;
core.registerAnimationFrame("lightFloor", true, function (timestamp) {
if(!core.status.floorId)return
if (!core.status.floorId) return
if (timestamp - now > 1000 / 60) {
now = timestamp;
globalAlphafloor += globalAlphafloorStatus;
@ -2896,7 +2896,8 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
core.ui.cgText.update();
if (main.dom.boss1 && main.dom.boss1.style.display === "block")
core.ui.boss.update();
if (main.dom.over && main.dom.over.style.display === "block")
core.overupdate()
if (main.dom.saveLoad && main.dom.saveLoad.style.display === "block")
core.saveLoad.update();
};
@ -4513,6 +4514,8 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
core.drawTip(text, id, frame);
core.playSound('error.opus');
}
const floor = Math.floor
Math.floor = (a) => floor(a + 1e-8)
},
"额外信息": function () {
/*
@ -16639,9 +16642,31 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
over.style.top = "50%";
over.style.left = "50%";
over.style.transform = "translate(-50%,-50%)";
const ctx = over.getContext("2d");
const ctx1 = over.getContext("2d");
main.dom.over = over;
const temp = document.createElement("canvas")
temp.width = 676 * 3;
temp.height = 416 * 3;
const ctx = temp.getContext("2d");
this.overupdate = function () {
if (core.domStyle.isVertical) {
ctx1.canvas.width = 416 * 3;
ctx1.canvas.height = 676 * 3;
ctx1.save(); //保存设置
ctx1.translate(416 * 3, 0); //重新定位右上角为基准
ctx1.rotate(Math.PI / 2); //旋转90度
} else {
ctx1.canvas.width = 676 * 3;
ctx1.canvas.height = 416 * 3;
}
core.clearMap(ctx1)
ctx1.drawImage(temp, 0, 0, 676 * 3, 416 * 3)
ctx1.restore();
}
this.over = function (
image,
memory,
@ -16658,67 +16683,74 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
}
const img = core.material.images.images?.[image];
over.style.display = "block";
let frame = 0;
let sod = 0;
let now = 0;
let start = 0;
core.registerAnimationFrame("over", true, (timestamp) => {
if (timestamp - now > 1000 / 60) {
now = timestamp;
core.clearMap(ctx);
if (core.domStyle.isVertical) {
ctx.canvas.width = 416 * 3;
ctx.canvas.height = 676 * 3;
ctx.save(); //保存设置
ctx.translate(416 * 3, 0); //重新定位右上角为基准
ctx.rotate(Math.PI / 2); //旋转90度
} else {
ctx.canvas.width = 676 * 3;
ctx.canvas.height = 416 * 3;
}
ctx.globalAlpha = 1;
if (img) {
//绘制背景
if (memory) ctx.filter = "sepia(50%)";
ctx.drawImage(img, 0, 0, 676 * 3, 416 * 3);
ctx.filter = "none";
} else {
core.fillRect(ctx, 0, 0, 676 * 3, 416 * 3);
}
frame++;
// 绘制
if (frame <= hidetime)
core.setAlpha(ctx, 1 - (hidetime - frame) / hidetime);
if (frame > hidetime && frame <= hidetime + time) ctx.globalAlpha = 1;
if (frame > hidetime + time && frame <= hidetime * 2 + time)
core.setAlpha(ctx, 1 - (frame - hidetime - time) / hidetime);
const lisen =
sound && core.sounds[sound] && core.musicStatus.soundStatus;
if (frame == hidetime && lisen) {
sod = core.playSound(sound);
}
if (frame > hidetime * 2 + time) {
core.unregisterAnimationFrame("over");
ctx.restore();
over.style.display = "none";
core.stopSound(sod);
core.doAction();
return;
}
core.setTextAlign(ctx, "center");
core.fillBoldText1(
ctx,
text,
1014,
624,
textColor,
boldColor,
6,
font
);
if (start === 0) start = timestamp;
core.clearMap(ctx);
ctx.globalAlpha = 1;
if (img) {
//绘制背景
if (memory) ctx.filter = "sepia(50%)";
ctx.drawImage(img, 0, 0, 676 * 3, 416 * 3);
ctx.filter = "none";
} else {
ctx.fillStyle = "#000000"
core.fillRect(ctx, 0, 0, 676 * 3, 416 * 3);
ctx.restore();
}
let frame = Math.floor((timestamp - start) / (1000 / 60))
// 绘制
if (frame <= hidetime)
core.setAlpha(ctx, 1 - (hidetime - frame) / hidetime);
if (frame > hidetime && frame <= hidetime + time) ctx.globalAlpha = 1;
if (frame > hidetime + time && frame <= hidetime * 2 + time)
core.setAlpha(ctx, 1 - (frame - hidetime - time) / hidetime);
const lisen =
sound && core.sounds[sound] && core.musicStatus.soundStatus;
if (frame == hidetime && lisen) {
sod = core.playSound(sound);
}
if (frame > hidetime * 2 + time) {
core.unregisterAnimationFrame("over");
ctx.restore();
over.style.display = "none";
core.stopSound(sod);
core.doAction();
return;
}
core.setTextAlign(ctx, "center");
core.fillBoldText1(
ctx,
text,
1014,
624,
textColor,
boldColor,
6,
font
);
if (core.domStyle.isVertical) {
ctx1.canvas.width = 416 * 3;
ctx1.canvas.height = 676 * 3;
ctx1.save(); //保存设置
ctx1.translate(416 * 3, 0); //重新定位右上角为基准
ctx1.rotate(Math.PI / 2); //旋转90度
} else {
ctx1.canvas.width = 676 * 3;
ctx1.canvas.height = 416 * 3;
}
core.clearMap(ctx1)
ctx1.drawImage(temp, 0, 0, 676 * 3, 416 * 3)
ctx1.restore();
});
};
@ -16748,23 +16780,16 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
if (timestamp - now > 1000 / 60) {
now = timestamp;
core.clearMap(ctx);
if (core.domStyle.isVertical) {
ctx.canvas.width = 416 * 3;
ctx.canvas.height = 676 * 3;
ctx.save(); //保存设置
ctx.translate(416 * 3, 0); //重新定位右上角为基准
ctx.rotate(Math.PI / 2); //旋转90度
} else {
ctx.canvas.width = 676 * 3;
ctx.canvas.height = 416 * 3;
}
ctx.globalAlpha = 1;
if (img) {
//绘制背景
if (memory) ctx.filter = "sepia(50%)";
core.drawImage(ctx, img, 0, 0, 676 * 3, 416 * 3);
ctx.filter = "none";
} else {
ctx.fillStyle = "#000000"
core.fillRect(ctx, 0, 0, 676 * 3, 416 * 3);
}
const a = list[i];
@ -16971,7 +16996,9 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
}
if (d.frame == hidetime * 2 + d.time && !c) {
core.unregisterAnimationFrame("overlist");
ctx.restore();
core.clearMap(ctx)
core.clearMap(ctx1)
over.style.display = "none";
core.stopSound(sod);
core.doAction();
@ -16979,133 +17006,159 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
}
}
}
ctx.restore();
if (core.domStyle.isVertical) {
ctx1.canvas.width = 416 * 3;
ctx1.canvas.height = 676 * 3;
ctx1.save(); //保存设置
ctx1.translate(416 * 3, 0); //重新定位右上角为基准
ctx1.rotate(Math.PI / 2); //旋转90度
} else {
ctx1.canvas.width = 676 * 3;
ctx1.canvas.height = 416 * 3;
}
core.clearMap(ctx1)
ctx1.drawImage(temp, 0, 0, 676 * 3, 416 * 3)
ctx1.restore();
}
});
};
this.changebg = function (img1, memory1, img2, memory2, time, style) {
let globalAlpha1 = 0;
let globalAlpha2 = time;
let frame = 0;
img1 = core.material.images.images?.[img1];
img2 = core.material.images.images?.[img2];
over.style.display = "block";
let now = 0;
let start = 0;
switch (style) {
case "引入":
core.registerAnimationFrame("bgin", true, (timestamp) => {
if (timestamp - now > 1000 / 60) {
now = timestamp;
core.clearMap(ctx);
if (core.domStyle.isVertical) {
ctx.canvas.width = 1248;
ctx.canvas.height = 676 * 3;
ctx.save(); //保存设置
ctx.translate(1248, 0); //重新定位右上角为基准
ctx.rotate(Math.PI / 2); //旋转90度
} else {
ctx.canvas.width = 676 * 3;
ctx.canvas.height = 1248;
}
ctx.globalAlpha = globalAlpha1 / time;
if (img2) {
//绘制背景
if (memory2) ctx.filter = "sepia(50%)";
core.drawImage(ctx, img2, 0, 0, 676 * 3, 1248);
ctx.filter = "none";
} else {
core.fillRect(ctx, 0, 0, 676 * 3, 1248);
}
globalAlpha1++;
ctx.restore();
if (globalAlpha1 >= time) {
core.unregisterAnimationFrame("bgin");
core.doAction();
}
if (start === 0) start = timestamp;
let frame = Math.floor((timestamp - start) / (1000 / 60))
core.clearMap(ctx);
ctx.globalAlpha = frame / time;
if (img2) {
//绘制背景
if (memory2) ctx.filter = "sepia(50%)";
core.drawImage(ctx, img2, 0, 0, 676 * 3, 1248);
ctx.filter = "none";
} else {
ctx.fillStyle = "#000000"
core.fillRect(ctx, 0, 0, 676 * 3, 1248);
}
if (core.domStyle.isVertical) {
ctx1.canvas.width = 416 * 3;
ctx1.canvas.height = 676 * 3;
ctx1.save(); //保存设置
ctx1.translate(416 * 3, 0); //重新定位右上角为基准
ctx1.rotate(Math.PI / 2); //旋转90度
} else {
ctx1.canvas.width = 676 * 3;
ctx1.canvas.height = 416 * 3;
}
core.clearMap(ctx1)
ctx1.drawImage(temp, 0, 0, 676 * 3, 416 * 3)
ctx1.restore();
if (frame > time) {
core.unregisterAnimationFrame("bgin");
core.doAction();
}
});
break;
case "引出":
core.registerAnimationFrame("bgout", true, (timestamp) => {
if (timestamp - now > 1000 / 60) {
now = timestamp;
core.clearMap(ctx);
if (core.domStyle.isVertical) {
ctx.canvas.width = 1248;
ctx.canvas.height = 676 * 3;
ctx.save(); //保存设置
ctx.translate(1248, 0); //重新定位右上角为基准
ctx.rotate(Math.PI / 2); //旋转90度
} else {
ctx.canvas.width = 676 * 3;
ctx.canvas.height = 1248;
}
ctx.globalAlpha = globalAlpha2 / time;
if (img1) {
//绘制背景
if (memory1) ctx.filter = "sepia(50%)";
core.drawImage(ctx, img1, 0, 0, 676 * 3, 1248);
ctx.filter = "none";
} else {
core.fillRect(ctx, 0, 0, 676 * 3, 1248);
}
globalAlpha2--;
ctx.restore();
if (globalAlpha2 <= 0) {
core.unregisterAnimationFrame("bgout");
over.style.display = "none";
core.doAction();
}
if (start === 0) start = timestamp;
let frame = Math.floor((timestamp - start) / (1000 / 60))
core.clearMap(ctx);
ctx.globalAlpha = 1 - frame / time;
if (img1) {
//绘制背景
if (memory1) ctx.filter = "sepia(50%)";
core.drawImage(ctx, img1, 0, 0, 676 * 3, 1248);
ctx.filter = "none";
} else {
ctx.fillStyle = "#000000"
core.fillRect(ctx, 0, 0, 676 * 3, 1248);
}
if (core.domStyle.isVertical) {
ctx1.canvas.width = 416 * 3;
ctx1.canvas.height = 676 * 3;
ctx1.save(); //保存设置
ctx1.translate(416 * 3, 0); //重新定位右上角为基准
ctx1.rotate(Math.PI / 2); //旋转90度
} else {
ctx1.canvas.width = 676 * 3;
ctx1.canvas.height = 416 * 3;
}
core.clearMap(ctx1)
ctx1.drawImage(temp, 0, 0, 676 * 3, 416 * 3)
ctx1.restore();
if (frame > time) {
core.unregisterAnimationFrame("bgout");
over.style.display = "none";
core.doAction();
}
});
break;
case "场景切换":
core.registerAnimationFrame("changebg", true, (timestamp) => {
if (timestamp - now > 1000 / 60) {
now = timestamp;
core.clearMap(ctx);
if (core.domStyle.isVertical) {
ctx.canvas.width = 1248;
ctx.canvas.height = 676 * 3;
ctx.save(); //保存设置
ctx.translate(1248, 0); //重新定位右上角为基准
ctx.rotate(Math.PI / 2); //旋转90度
} else {
ctx.canvas.width = 676 * 3;
ctx.canvas.height = 1248;
}
ctx.globalAlpha = 1;
core.fillRect(ctx, 0, 0, 676 * 3, 1248);
ctx.globalAlpha = globalAlpha2 / time;
if (img1) {
//绘制背景
if (memory1) ctx.filter = "sepia(50%)";
core.drawImage(ctx, img1, 0, 0, 676 * 3, 1248);
ctx.filter = "none";
} else {
core.fillRect(ctx, 0, 0, 676 * 3, 1248);
}
ctx.globalAlpha = globalAlpha1 / time;
if (img2) {
//绘制背景
if (memory2) ctx.filter = "sepia(50%)";
core.drawImage(ctx, img2, 0, 0, 676 * 3, 1248);
ctx.filter = "none";
} else {
core.fillRect(ctx, 0, 0, 676 * 3, 1248);
}
globalAlpha2--;
globalAlpha1++;
ctx.restore();
if (globalAlpha2 <= 0 || globalAlpha1 >= time) {
core.unregisterAnimationFrame("changebg");
if (start === 0) start = timestamp;
let frame = Math.floor((timestamp - start) / (1000 / 60))
core.clearMap(ctx);
core.doAction();
}
ctx.globalAlpha = 1;
ctx.fillStyle = "#000000"
core.fillRect(ctx, 0, 0, 676 * 3, 1248);
ctx.globalAlpha = 1 - frame / time;
if (img1) {
//绘制背景
if (memory1) ctx.filter = "sepia(50%)";
core.drawImage(ctx, img1, 0, 0, 676 * 3, 1248);
ctx.filter = "none";
} else {
ctx.fillStyle = "#000000"
core.fillRect(ctx, 0, 0, 676 * 3, 1248);
}
ctx.globalAlpha = frame / time;
if (img2) {
//绘制背景
if (memory2) ctx.filter = "sepia(50%)";
core.drawImage(ctx, img2, 0, 0, 676 * 3, 1248);
ctx.filter = "none";
} else {
ctx.fillStyle = "#000000"
core.fillRect(ctx, 0, 0, 676 * 3, 1248);
}
if (core.domStyle.isVertical) {
ctx1.canvas.width = 416 * 3;
ctx1.canvas.height = 676 * 3;
ctx1.save(); //保存设置
ctx1.translate(416 * 3, 0); //重新定位右上角为基准
ctx1.rotate(Math.PI / 2); //旋转90度
} else {
ctx1.canvas.width = 676 * 3;
ctx1.canvas.height = 416 * 3;
}
core.clearMap(ctx1)
ctx1.drawImage(temp, 0, 0, 676 * 3, 416 * 3)
ctx1.restore();
if (frame > time) {
core.unregisterAnimationFrame("changebg");
core.doAction();
}
});
break;
@ -17114,16 +17167,6 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
};
this.drawbackground = function (image, memory) {
if (core.domStyle.isVertical) {
ctx.canvas.width = 1248;
ctx.canvas.height = 2028;
ctx.save(); //保存设置
ctx.translate(1248, 0); //重新定位右上角为基准
ctx.rotate(Math.PI / 2); //旋转90度
} else {
ctx.canvas.width = 2028;
ctx.canvas.height = 1248;
}
over.style.display = "block";
@ -17131,7 +17174,19 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
if (memory) ctx.filter = "sepia(70%)";
core.drawImage(ctx, image, 0, 0, 2028, 1248);
ctx.filter = "none";
ctx.restore();
if (core.domStyle.isVertical) {
ctx1.canvas.width = 416 * 3;
ctx1.canvas.height = 676 * 3;
ctx1.save(); //保存设置
ctx1.translate(416 * 3, 0); //重新定位右上角为基准
ctx1.rotate(Math.PI / 2); //旋转90度
} else {
ctx1.canvas.width = 676 * 3;
ctx1.canvas.height = 416 * 3;
}
core.clearMap(ctx1)
ctx1.drawImage(temp, 0, 0, 676 * 3, 416 * 3)
ctx1.restore();
}
this.clearbackground = function () {