From 215fbd722134b46412e4071aa099d8c1ca4fa144 Mon Sep 17 00:00:00 2001 From: lkddi Date: Fri, 27 Feb 2026 14:17:56 +0800 Subject: [PATCH] =?UTF-8?q?Fix:=20=E7=83=9F=E8=8A=B1/=E4=B8=8B=E9=9B=A8?= =?UTF-8?q?=E6=94=B9=E7=94=A8clearRect=E4=B8=8D=E9=81=AE=E6=8C=A1=E8=83=8C?= =?UTF-8?q?=E6=99=AF=EF=BC=8C=E9=9B=B7=E7=94=B5=E6=AC=A1=E6=95=B0=E5=A2=9E?= =?UTF-8?q?=E8=87=B310=E6=AC=A1=E6=9B=B4=E5=AF=86=E9=9B=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/js/effects/fireworks.js | 7 +++---- public/js/effects/lightning.js | 10 +++++----- public/js/effects/rain.js | 9 ++------- 3 files changed, 10 insertions(+), 16 deletions(-) diff --git a/public/js/effects/fireworks.js b/public/js/effects/fireworks.js index c43025e..c64d404 100644 --- a/public/js/effects/fireworks.js +++ b/public/js/effects/fireworks.js @@ -112,11 +112,10 @@ const FireworksEffect = (() => { // 动画循环 function animate(now) { - // 用半透明黑色覆盖,产生运动拖尾效果 - ctx.fillStyle = "rgba(0, 0, 0, 0.18)"; - ctx.fillRect(0, 0, w, h); + // 清除画布(保持透明,不遮挡聊天背景) + ctx.clearRect(0, 0, w, h); - // 更新并绘制存活粒子 + // 更新并绘制存活粒子(粒子自带 alpha 衰减,视觉上有淡出效果) particles = particles.filter((p) => p.alpha > 0.02); particles.forEach((p) => { p.update(); diff --git a/public/js/effects/lightning.js b/public/js/effects/lightning.js index a3e9f4f..a75b2cf 100644 --- a/public/js/effects/lightning.js +++ b/public/js/effects/lightning.js @@ -91,8 +91,8 @@ const LightningEffect = (() => { */ function start(canvas, onEnd) { const ctx = canvas.getContext("2d"); - const FLASHES = 5; // 总闪电次数 - const DURATION = 5000; // 总时长(ms) + const FLASHES = 10; // 总闪电次数(增加密度) + const DURATION = 7000; // 总时长(ms,相应延长) let count = 0; // 间隔不规则触发多次闪电(模拟真实雷电节奏) @@ -102,13 +102,13 @@ const LightningEffect = (() => { setTimeout(() => { ctx.clearRect(0, 0, canvas.width, canvas.height); onEnd(); - }, 500); + }, 400); return; } _flash(canvas, ctx); count++; - // 下次闪电间隔:800ms ~ 1200ms 之间随机 - const delay = 700 + Math.random() * 500; + // 下次闪电间隔:400ms ~ 800ms 之间随机(更频繁) + const delay = 400 + Math.random() * 400; setTimeout(nextFlash, delay); } diff --git a/public/js/effects/rain.js b/public/js/effects/rain.js index 6c30281..4d9c472 100644 --- a/public/js/effects/rain.js +++ b/public/js/effects/rain.js @@ -78,14 +78,9 @@ const RainEffect = (() => { let animId = null; const startTime = performance.now(); - // 画"乌云"背景遮罩(让画面有阴暗感但不完全遮住聊天) - ctx.fillStyle = "rgba(30, 40, 60, 0.18)"; - ctx.fillRect(0, 0, w, h); - function animate(now) { - // 用极轻微的透明背景刷新(保留少量拖尾感) - ctx.fillStyle = "rgba(30, 40, 60, 0.08)"; - ctx.fillRect(0, 0, w, h); + // 清除画布(保持透明,不遮挡聊天背景) + ctx.clearRect(0, 0, w, h); drops.forEach((d) => { d.update();