fix: 每帧仅显示当前窗口边,不再混合两窗口

放弃交叉淡入淡出(两条边透明度叠加难以区分),
改为仅显示当前窗口的边(t<0.5→w0, t>=0.5→w1),
不同窗口不同边集一目了然。

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
TianXuan Developer
2026-07-25 14:48:54 +08:00
parent bca6929838
commit 45034813ad
@@ -2782,26 +2782,14 @@ function renderTrafficCrossfade() {
const t = mix.t; const t = mix.t;
// Each frame: add w0 edges with fade-out, w1 edges with fade-in // Each frame: add w0 edges with fade-out, w1 edges with fade-in
// Only show current window edges — clean switch, no blending
// Brief fade-in for newly appearing edges
const curEdges = t < 0.5 ? (w0 ? w0.edges : []) : (w1 ? w1.edges : []);
const edgeMap = {}; const edgeMap = {};
function add(edges, w) { curEdges.forEach(e => {
if (!edges || w < 0.03) return; const k = e.source + '|' + e.target;
edges.forEach(e => { edgeMap[k] = {source:e.source, target:e.target, weight:1.0, count:e.count||0};
const k = e.source + '|' + e.target; });
if (!edgeMap[k]) edgeMap[k] = {source:e.source, target:e.target, weight:0, count:0};
if (w > edgeMap[k].weight) edgeMap[k].weight = w;
if ((e.count||0) > edgeMap[k].count) edgeMap[k].count = e.count||0;
});
}
add(w0?w0.edges:[], 1-t);
add(w1?w1.edges:[], t);
// Also blend in edges that are about to appear (smooth entry)
if (mix.i + 2 < wins.length) {
add(wins[mix.i + 2].edges, Math.max(0, t - 0.85));
}
// Blend out edges from previous window (smooth exit)
if (mix.i > 0) {
add(wins[mix.i - 1].edges, Math.max(0, 0.15 - t));
}
const edges = Object.values(edgeMap); const edges = Object.values(edgeMap);
if (!edges.length) return; if (!edges.length) return;
@@ -2822,9 +2810,8 @@ function renderTrafficCrossfade() {
if (!p1 || !p2) return; if (!p1 || !p2) return;
const midX = (p1.x + p2.x) / 2; const midX = (p1.x + p2.x) / 2;
const midY = (p1.y + p2.y) / 2 - Math.abs(p2.x - p1.x) * 0.1; const midY = (p1.y + p2.y) / 2 - Math.abs(p2.x - p1.x) * 0.1;
if (e.weight < 0.05) return; // skip near-invisible edges
const ratio = Math.min(1, e.count / maxCount); const ratio = Math.min(1, e.count / maxCount);
const alpha = 0.08 + 0.92 * e.weight; const alpha = 0.6 + 0.4 * ratio;
// Edge trace with src→dst color gradient // Edge trace with src→dst color gradient
const grad = ctx.createLinearGradient(p1.x, p1.y, p2.x, p2.y); const grad = ctx.createLinearGradient(p1.x, p1.y, p2.x, p2.y);