优化座驾特效入场标题

This commit is contained in:
pllx
2026-04-30 10:29:11 +08:00
parent 18acd7d890
commit 221f629ec2
12 changed files with 91 additions and 41 deletions
+8 -5
View File
@@ -393,8 +393,9 @@ const FujianEffect = (() => {
* @param {number} w 画布宽度
* @param {number} h 画布高度
* @param {number} progress 播放进度
* @param {string} title 入场标题
*/
function drawHud(ctx, w, h, progress) {
function drawHud(ctx, w, h, progress, title) {
const enter = Math.min(1, Math.max(0, (progress - 0.12) / 0.2));
const leave = Math.min(1, Math.max(0, (1 - progress) / 0.14));
const alpha = easeInOutCubic(enter) * leave;
@@ -406,7 +407,7 @@ const FujianEffect = (() => {
ctx.fillStyle = "rgba(15,23,42,0.68)";
ctx.strokeStyle = "rgba(103,232,249,0.72)";
ctx.lineWidth = 2;
roundRect(ctx, w * 0.5 - 236, y - 42, 472, 88, 18);
roundRect(ctx, w * 0.5 - 320, y - 46, 640, 96, 18);
ctx.fill();
ctx.stroke();
ctx.shadowColor = "rgba(103,232,249,0.95)";
@@ -416,7 +417,7 @@ const FujianEffect = (() => {
ctx.fillText("FUJIAN AIRCRAFT CARRIER PREVIEW", w * 0.5, y - 12);
ctx.fillStyle = "#ffffff";
ctx.font = "900 38px serif";
ctx.fillText("福建舰 航母入场", w * 0.5, y + 28);
ctx.fillText(title, w * 0.5, y + 28, 590);
ctx.restore();
}
@@ -449,13 +450,15 @@ const FujianEffect = (() => {
*
* @param {HTMLCanvasElement} canvas 全屏特效画布
* @param {Function} onEnd 结束回调
* @param {object} options 特效附加参数
* @returns {{cancel: Function}}
*/
function start(canvas, onEnd) {
function start(canvas, onEnd, options = {}) {
const ctx = canvas.getContext("2d");
const w = canvas.width;
const h = canvas.height;
const waves = createWaves(w, h);
const title = String(options.effect_title || "福建舰 航母入场").trim() || "福建舰 航母入场";
const startTime = performance.now();
let animId = null;
let finished = false;
@@ -497,7 +500,7 @@ const FujianEffect = (() => {
drawBackdrop(ctx, w, h, progress);
drawWaves(ctx, waves, w, progress, carrierX, carrierY, scale);
drawCarrier(ctx, carrierX, carrierY, scale, progress);
drawHud(ctx, w, h, progress);
drawHud(ctx, w, h, progress, title);
if (progress < 1) {
animId = requestAnimationFrame(animate);