From 874e5bf66b5fa098e033f7a7c8e513c71b3d470c Mon Sep 17 00:00:00 2001 From: light-xiaomi-1 Date: Mon, 4 May 2026 16:27:46 +0800 Subject: [PATCH 1/3] =?UTF-8?q?refactor:=20=E7=AE=80=E5=8D=95=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E4=BA=86=E6=B3=A2=E7=9A=84=E6=A0=B7=E5=BC=8F=EF=BC=8C?= =?UTF-8?q?=E7=AE=80=E5=8D=95=E9=87=8D=E6=9E=84=E4=BA=86index.html?= =?UTF-8?q?=E9=87=8C=E7=9A=84=E4=BB=A3=E7=A0=81=EF=BC=8C=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E7=BC=93=E5=86=B2=E7=94=BB=E5=B8=83=E5=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Web/index.html | 841 +++++++++++++++++++++++++++------------------ 1 file changed, 501 insertions(+), 340 deletions(-) diff --git a/src/Web/index.html b/src/Web/index.html index f077ee3..7dd4bb9 100644 --- a/src/Web/index.html +++ b/src/Web/index.html @@ -1,365 +1,526 @@ + + - + + window.spark = new MouseSpark(); + + // C# 通信接口 + + let lastBoomX = -1, lastBoomY = -1; + let lastBoomTime = 0; + let lastMoveX = -1, lastMoveY = -1; + + window.currentInputMode = "mouse"; + window.enableAlwaysTrailEffect = false; + window.effectiveAlwaysTrail = false; + + window.setInputContext = (mode, alwaysTrailEnabled) => { + window.currentInputMode = mode === "touch" ? "touch" : "mouse"; + window.enableAlwaysTrailEffect = Boolean(alwaysTrailEnabled); + window.effectiveAlwaysTrail = window.currentInputMode === "mouse" && window.enableAlwaysTrailEffect; + }; + + window.setInputContext("mouse", false); + + // 接收 C# 传来的物理百分比 (0.0 ~ 1.0),由前端根据真实的画布宽度自行计算 + window.externalBoom = (percentX, percentY) => { + const now = Date.now(); + if (percentX === lastBoomX && percentY === lastBoomY && (now - lastBoomTime) < 25) return; + lastBoomX = percentX; lastBoomY = percentY; lastBoomTime = now; + + // 百分比乘以 WebView 当前真实的内部宽度 + let cx = percentX * window.innerWidth; + let cy = percentY * window.innerHeight; + window.dispatchEvent(new MouseEvent('mousedown', { clientX: cx, clientY: cy, bubbles: true })); + }; + + window.externalMove = (percentX, percentY) => { + if (percentX === lastMoveX && percentY === lastMoveY) return; + lastMoveX = percentX; lastMoveY = percentY; + + // 方法与上述相同 + let cx = percentX * window.innerWidth; + let cy = percentY * window.innerHeight; + window.dispatchEvent(new MouseEvent('mousemove', { clientX: cx, clientY: cy, bubbles: true })); + }; + window.externalUp = () => { + window.dispatchEvent(new MouseEvent('mouseup', { bubbles: true })); + }; + + window.updateColor = (rgbString) => { + if (window.spark) window.spark.color = rgbString; + }; + + window.updateEffectSettings = (scale, opacity, trailSpeed, clickSpeed) => { + if (!window.spark) return; + window.spark.scale = Math.max(0.5, Math.min(3, Number(scale) || 1.5)); + window.spark.opacity = Math.max(0.1, Math.min(1, Number(opacity) || 1.0)); + let t = Number(trailSpeed); + if (!Number.isFinite(t)) t = 1.0; + let c = Number(clickSpeed); + if (!Number.isFinite(c)) c = t; + window.spark.trailSpeed = Math.max(0.2, Math.min(3, t)); + window.spark.clickSpeed = Math.max(0.2, Math.min(3, c)); + }; + - + + \ No newline at end of file From 8886be0d6e9e6e54f44e4144c44b028325be7ec4 Mon Sep 17 00:00:00 2001 From: light-xiaomi-1 Date: Mon, 4 May 2026 19:11:06 +0800 Subject: [PATCH 2/3] =?UTF-8?q?fix:=E4=BF=AE=E6=94=B9=E4=BA=86=E5=AE=A2?= =?UTF-8?q?=E5=88=B6=E5=8C=96=E9=A2=9C=E8=89=B2=E6=94=B9=E5=8F=98=EF=BC=8C?= =?UTF-8?q?=E5=85=89=E5=BC=A7=E9=A2=9C=E8=89=B2=E6=B2=A1=E5=8F=98=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Web/index.html | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/Web/index.html b/src/Web/index.html index 7dd4bb9..542ff0b 100644 --- a/src/Web/index.html +++ b/src/Web/index.html @@ -55,6 +55,11 @@ this.maxDeltaMs = 100; this.lastFrameTime = performance.now(); + + this.ringsStartColor = [250, 252, 252]; + //this.ringsEndColor = [200, 250, 255]; + this.ringsEndColor = this.color.split(',').map(Number).map(n => (n + 255 * 2) / 3); + this.initCanvas(); this.bindEvents(); requestAnimationFrame((now) => this.animationLoops(now)); @@ -229,8 +234,6 @@ // ==End-整合的数据== maxLife: 23, - startColor: [250, 252, 252], - endColor: [200, 250, 255], segNum: 16, // 拆成的段数 minW: 0.4, // 最小宽度 maxW: 3.3, // 最大宽度 @@ -311,9 +314,9 @@ } function getColor(rProg) { const t = Math.min(1.2 * rProg, 1); - const r = ringsConfig.startColor[0] * (1 - t) + ringsConfig.endColor[0] * t; - const g = ringsConfig.startColor[1] * (1 - t) + ringsConfig.endColor[1] * t; - const b = ringsConfig.startColor[2] * (1 - t) + ringsConfig.endColor[2] * t; + const r = this.ringsStartColor[0] * (1 - t) + this.ringsEndColor[0] * t; + const g = this.ringsStartColor[1] * (1 - t) + this.ringsEndColor[1] * t; + const b = this.ringsStartColor[2] * (1 - t) + this.ringsEndColor[2] * t; return `rgba(${Math.round(r)}, ${Math.round(g)}, ${Math.round(b)}`; } function getAlpha(rProg) { @@ -344,7 +347,7 @@ seg = r.segs[i]; base = r.ang + seg.off; - + if (rProg <= ringsConfig.lenStopAddPoint) { // 前段:终点固定,起点逆时针延伸 len = seg.len * (rProg / ringsConfig.lenStopAddPoint); @@ -372,13 +375,13 @@ a1 = start + (end - start) * t1; // 终止子位置 (? if (Math.abs(a1 - a0) < 0.01) continue; - + // 光弧 let wT = getWeightProp(t0); this.bufferCtx.beginPath(); this.bufferCtx.arc(w.x, w.y, w.r + seg.rRoundRate * this.scale, a0, a1); this.bufferCtx.lineWidth = (ringsConfig.minW * (1 - wT) + ringsConfig.maxW * wT) * Math.min((-0.8 * (rProg - 0.8) + 1), 1); // 看不懂了(?) - this.bufferCtx.strokeStyle = `${getColor(rProg)}, ${getAlpha(rProg)})`; + this.bufferCtx.strokeStyle = `${getColor.call(this, rProg)}, ${getAlpha(rProg)})`; this.bufferCtx.stroke(); } } @@ -506,7 +509,10 @@ }; window.updateColor = (rgbString) => { - if (window.spark) window.spark.color = rgbString; + if (window.spark) { + window.spark.color = rgbString; + window.spark.ringsEndColor = rgbString.split(',').map(Number).map(n => (n + 255 * 2) / 3); + } }; window.updateEffectSettings = (scale, opacity, trailSpeed, clickSpeed) => { From 83118c316523590859bb4d6aec0970d8e1bc462d Mon Sep 17 00:00:00 2001 From: DoomVoss Date: Mon, 4 May 2026 22:31:24 +0800 Subject: [PATCH 3/3] =?UTF-8?q?refactor:=20=E5=86=8D=E6=AC=A1=E4=BC=98?= =?UTF-8?q?=E5=8C=96=20canvas=20=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Web/index.html | 591 ++++++++++++++++++++++----------------------- 1 file changed, 295 insertions(+), 296 deletions(-) diff --git a/src/Web/index.html b/src/Web/index.html index 542ff0b..75dc8ca 100644 --- a/src/Web/index.html +++ b/src/Web/index.html @@ -31,9 +31,32 @@ - \ No newline at end of file