优化座驾特效入场标题

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
@@ -269,8 +269,9 @@ const Df5cEffect = (() => {
* @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.1) / 0.18));
const leave = Math.min(1, Math.max(0, (1 - progress) / 0.14));
const alpha = easeInOutCubic(enter) * leave;
@@ -282,7 +283,7 @@ const Df5cEffect = (() => {
ctx.fillStyle = "rgba(15,23,42,0.68)";
ctx.strokeStyle = "rgba(248,113,113,0.72)";
ctx.lineWidth = 2;
roundRect(ctx, w * 0.5 - 246, y - 42, 492, 88, 18);
roundRect(ctx, w * 0.5 - 330, y - 46, 660, 96, 18);
ctx.fill();
ctx.stroke();
ctx.shadowColor = "rgba(248,113,113,0.95)";
@@ -292,7 +293,7 @@ const Df5cEffect = (() => {
ctx.fillText("DF-5C STRATEGIC LAUNCH PREVIEW", w * 0.5, y - 12);
ctx.fillStyle = "#ffffff";
ctx.font = "900 38px serif";
ctx.fillText("东风-5C 洲际导弹 升空", w * 0.5, y + 28);
ctx.fillText(title, w * 0.5, y + 28, 610);
ctx.restore();
}
@@ -325,13 +326,15 @@ const Df5cEffect = (() => {
*
* @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 particles = createParticles(120);
const title = String(options.effect_title || "东风-5C 洲际导弹 升空").trim() || "东风-5C 洲际导弹 升空";
const startTime = performance.now();
let animId = null;
let finished = false;
@@ -375,7 +378,7 @@ const Df5cEffect = (() => {
drawLaunchPad(ctx, w, h, progress);
drawExhaust(ctx, particles, tailX, tailY, progress);
drawMissile(ctx, launchX, launchY, scale, progress);
drawHud(ctx, w, h, progress);
drawHud(ctx, w, h, progress, title);
if (progress < 1) {
animId = requestAnimationFrame(animate);