fix: 每帧仅显示当前窗口边,不再混合两窗口
放弃交叉淡入淡出(两条边透明度叠加难以区分), 改为仅显示当前窗口的边(t<0.5→w0, t>=0.5→w1), 不同窗口不同边集一目了然。 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -2782,26 +2782,14 @@ function renderTrafficCrossfade() {
|
||||
const t = mix.t;
|
||||
|
||||
// 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 = {};
|
||||
function add(edges, w) {
|
||||
if (!edges || w < 0.03) return;
|
||||
edges.forEach(e => {
|
||||
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));
|
||||
}
|
||||
curEdges.forEach(e => {
|
||||
const k = e.source + '|' + e.target;
|
||||
edgeMap[k] = {source:e.source, target:e.target, weight:1.0, count:e.count||0};
|
||||
});
|
||||
|
||||
const edges = Object.values(edgeMap);
|
||||
if (!edges.length) return;
|
||||
@@ -2822,9 +2810,8 @@ function renderTrafficCrossfade() {
|
||||
if (!p1 || !p2) return;
|
||||
const midX = (p1.x + p2.x) / 2;
|
||||
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 alpha = 0.08 + 0.92 * e.weight;
|
||||
const alpha = 0.6 + 0.4 * ratio;
|
||||
|
||||
// Edge trace with src→dst color gradient
|
||||
const grad = ctx.createLinearGradient(p1.x, p1.y, p2.x, p2.y);
|
||||
|
||||
Reference in New Issue
Block a user