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"); const uictx = main.dom.outerUI.getContext("2d");
let now = 0; let now = 0;
core.registerAnimationFrame("lightFloor", true, function (timestamp) { core.registerAnimationFrame("lightFloor", true, function (timestamp) {
if(!core.status.floorId)return if (!core.status.floorId) return
if (timestamp - now > 1000 / 60) { if (timestamp - now > 1000 / 60) {
now = timestamp; now = timestamp;
globalAlphafloor += globalAlphafloorStatus; globalAlphafloor += globalAlphafloorStatus;
@ -2896,7 +2896,8 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
core.ui.cgText.update(); core.ui.cgText.update();
if (main.dom.boss1 && main.dom.boss1.style.display === "block") if (main.dom.boss1 && main.dom.boss1.style.display === "block")
core.ui.boss.update(); 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") if (main.dom.saveLoad && main.dom.saveLoad.style.display === "block")
core.saveLoad.update(); core.saveLoad.update();
}; };
@ -4513,6 +4514,8 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
core.drawTip(text, id, frame); core.drawTip(text, id, frame);
core.playSound('error.opus'); core.playSound('error.opus');
} }
const floor = Math.floor
Math.floor = (a) => floor(a + 1e-8)
}, },
"额外信息": function () { "额外信息": function () {
/* /*
@ -16639,9 +16642,31 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
over.style.top = "50%"; over.style.top = "50%";
over.style.left = "50%"; over.style.left = "50%";
over.style.transform = "translate(-50%,-50%)"; over.style.transform = "translate(-50%,-50%)";
const ctx = over.getContext("2d"); const ctx1 = over.getContext("2d");
main.dom.over = over; 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 ( this.over = function (
image, image,
memory, memory,
@ -16658,33 +16683,29 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
} }
const img = core.material.images.images?.[image]; const img = core.material.images.images?.[image];
over.style.display = "block"; over.style.display = "block";
let frame = 0;
let sod = 0; let sod = 0;
let now = 0; let start = 0;
core.registerAnimationFrame("over", true, (timestamp) => { core.registerAnimationFrame("over", true, (timestamp) => {
if (timestamp - now > 1000 / 60) {
now = timestamp; if (start === 0) start = timestamp;
core.clearMap(ctx); 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; ctx.globalAlpha = 1;
if (img) { if (img) {
//绘制背景 //绘制背景
if (memory) ctx.filter = "sepia(50%)"; if (memory) ctx.filter = "sepia(50%)";
ctx.drawImage(img, 0, 0, 676 * 3, 416 * 3); ctx.drawImage(img, 0, 0, 676 * 3, 416 * 3);
ctx.filter = "none"; ctx.filter = "none";
} else { } else {
ctx.fillStyle = "#000000"
core.fillRect(ctx, 0, 0, 676 * 3, 416 * 3); core.fillRect(ctx, 0, 0, 676 * 3, 416 * 3);
} }
frame++; let frame = Math.floor((timestamp - start) / (1000 / 60))
// 绘制 // 绘制
if (frame <= hidetime) if (frame <= hidetime)
core.setAlpha(ctx, 1 - (hidetime - frame) / hidetime); core.setAlpha(ctx, 1 - (hidetime - frame) / hidetime);
@ -16716,9 +16737,20 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
6, 6,
font font
); );
if (core.domStyle.isVertical) {
ctx.restore(); 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) { if (timestamp - now > 1000 / 60) {
now = timestamp; now = timestamp;
core.clearMap(ctx); 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; ctx.globalAlpha = 1;
if (img) { if (img) {
//绘制背景 //绘制背景
if (memory) ctx.filter = "sepia(50%)"; if (memory) ctx.filter = "sepia(50%)";
core.drawImage(ctx, img, 0, 0, 676 * 3, 416 * 3); core.drawImage(ctx, img, 0, 0, 676 * 3, 416 * 3);
ctx.filter = "none"; ctx.filter = "none";
} else { } else {
ctx.fillStyle = "#000000"
core.fillRect(ctx, 0, 0, 676 * 3, 416 * 3); core.fillRect(ctx, 0, 0, 676 * 3, 416 * 3);
} }
const a = list[i]; const a = list[i];
@ -16971,7 +16996,9 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
} }
if (d.frame == hidetime * 2 + d.time && !c) { if (d.frame == hidetime * 2 + d.time && !c) {
core.unregisterAnimationFrame("overlist"); core.unregisterAnimationFrame("overlist");
ctx.restore(); core.clearMap(ctx)
core.clearMap(ctx1)
over.style.display = "none"; over.style.display = "none";
core.stopSound(sod); core.stopSound(sod);
core.doAction(); 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) { this.changebg = function (img1, memory1, img2, memory2, time, style) {
let globalAlpha1 = 0; let frame = 0;
let globalAlpha2 = time;
img1 = core.material.images.images?.[img1]; img1 = core.material.images.images?.[img1];
img2 = core.material.images.images?.[img2]; img2 = core.material.images.images?.[img2];
over.style.display = "block"; over.style.display = "block";
let now = 0; let start = 0;
switch (style) { switch (style) {
case "引入": case "引入":
core.registerAnimationFrame("bgin", true, (timestamp) => { core.registerAnimationFrame("bgin", true, (timestamp) => {
if (timestamp - now > 1000 / 60) {
now = timestamp; if (start === 0) start = timestamp;
let frame = Math.floor((timestamp - start) / (1000 / 60))
core.clearMap(ctx); core.clearMap(ctx);
if (core.domStyle.isVertical) {
ctx.canvas.width = 1248; ctx.globalAlpha = frame / time;
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 (img2) {
//绘制背景 //绘制背景
if (memory2) ctx.filter = "sepia(50%)"; if (memory2) ctx.filter = "sepia(50%)";
core.drawImage(ctx, img2, 0, 0, 676 * 3, 1248); core.drawImage(ctx, img2, 0, 0, 676 * 3, 1248);
ctx.filter = "none"; ctx.filter = "none";
} else { } else {
ctx.fillStyle = "#000000"
core.fillRect(ctx, 0, 0, 676 * 3, 1248); core.fillRect(ctx, 0, 0, 676 * 3, 1248);
} }
globalAlpha1++;
ctx.restore(); if (core.domStyle.isVertical) {
if (globalAlpha1 >= time) { 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.unregisterAnimationFrame("bgin");
core.doAction(); core.doAction();
} }
}
}); });
break; break;
case "引出": case "引出":
core.registerAnimationFrame("bgout", true, (timestamp) => { core.registerAnimationFrame("bgout", true, (timestamp) => {
if (timestamp - now > 1000 / 60) { if (start === 0) start = timestamp;
now = timestamp; let frame = Math.floor((timestamp - start) / (1000 / 60))
core.clearMap(ctx); core.clearMap(ctx);
if (core.domStyle.isVertical) {
ctx.canvas.width = 1248; ctx.globalAlpha = 1 - frame / time;
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 (img1) {
//绘制背景 //绘制背景
if (memory1) ctx.filter = "sepia(50%)"; if (memory1) ctx.filter = "sepia(50%)";
core.drawImage(ctx, img1, 0, 0, 676 * 3, 1248); core.drawImage(ctx, img1, 0, 0, 676 * 3, 1248);
ctx.filter = "none"; ctx.filter = "none";
} else { } else {
ctx.fillStyle = "#000000"
core.fillRect(ctx, 0, 0, 676 * 3, 1248); core.fillRect(ctx, 0, 0, 676 * 3, 1248);
} }
globalAlpha2--;
ctx.restore(); if (core.domStyle.isVertical) {
if (globalAlpha2 <= 0) { 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"); core.unregisterAnimationFrame("bgout");
over.style.display = "none"; over.style.display = "none";
core.doAction(); core.doAction();
} }
}
}); });
break; break;
case "场景切换": case "场景切换":
core.registerAnimationFrame("changebg", true, (timestamp) => { core.registerAnimationFrame("changebg", true, (timestamp) => {
if (timestamp - now > 1000 / 60) { if (start === 0) start = timestamp;
now = timestamp; let frame = Math.floor((timestamp - start) / (1000 / 60))
core.clearMap(ctx); 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; ctx.globalAlpha = 1;
ctx.fillStyle = "#000000"
core.fillRect(ctx, 0, 0, 676 * 3, 1248); core.fillRect(ctx, 0, 0, 676 * 3, 1248);
ctx.globalAlpha = globalAlpha2 / time; ctx.globalAlpha = 1 - frame / time;
if (img1) { if (img1) {
//绘制背景 //绘制背景
if (memory1) ctx.filter = "sepia(50%)"; if (memory1) ctx.filter = "sepia(50%)";
core.drawImage(ctx, img1, 0, 0, 676 * 3, 1248); core.drawImage(ctx, img1, 0, 0, 676 * 3, 1248);
ctx.filter = "none"; ctx.filter = "none";
} else { } else {
ctx.fillStyle = "#000000"
core.fillRect(ctx, 0, 0, 676 * 3, 1248); core.fillRect(ctx, 0, 0, 676 * 3, 1248);
} }
ctx.globalAlpha = globalAlpha1 / time; ctx.globalAlpha = frame / time;
if (img2) { if (img2) {
//绘制背景 //绘制背景
if (memory2) ctx.filter = "sepia(50%)"; if (memory2) ctx.filter = "sepia(50%)";
core.drawImage(ctx, img2, 0, 0, 676 * 3, 1248); core.drawImage(ctx, img2, 0, 0, 676 * 3, 1248);
ctx.filter = "none"; ctx.filter = "none";
} else { } else {
ctx.fillStyle = "#000000"
core.fillRect(ctx, 0, 0, 676 * 3, 1248); core.fillRect(ctx, 0, 0, 676 * 3, 1248);
} }
globalAlpha2--;
globalAlpha1++; if (core.domStyle.isVertical) {
ctx.restore(); ctx1.canvas.width = 416 * 3;
if (globalAlpha2 <= 0 || globalAlpha1 >= time) { 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.unregisterAnimationFrame("changebg");
core.doAction(); core.doAction();
} }
}
}); });
break; break;
@ -17114,16 +17167,6 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
}; };
this.drawbackground = function (image, memory) { 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"; over.style.display = "block";
@ -17131,7 +17174,19 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
if (memory) ctx.filter = "sepia(70%)"; if (memory) ctx.filter = "sepia(70%)";
core.drawImage(ctx, image, 0, 0, 2028, 1248); core.drawImage(ctx, image, 0, 0, 2028, 1248);
ctx.filter = "none"; 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 () { this.clearbackground = function () {