Исправили отображение связей V3

This commit is contained in:
AidarKC
2026-11-11 00:52:46 +03:00
parent 689321da1a
commit e7f6e0580c
5 changed files with 35 additions and 7 deletions
@@ -89,7 +89,7 @@ const DOUBLE_TAP_MS = 320; // окно двойного тапа по фо
const RELATION_COLORS = {
family: 'rgba(255, 159, 94, 0.92)',
friend: 'rgba(120, 179, 255, 0.9)',
close_friend: 'rgba(120, 179, 255, 0.98)',
close_friend: 'rgba(255, 76, 92, 0.98)',
business: 'rgba(190, 150, 255, 0.9)',
contact: 'rgba(170, 190, 220, 0.7)',
};
@@ -110,7 +110,7 @@ function easeOutCubic(t) {
const RELATION_COLORS_LIGHT = {
family: 'rgba(184, 92, 20, 0.9)',
friend: 'rgba(38, 96, 196, 0.9)',
close_friend: 'rgba(38, 96, 196, 0.98)',
close_friend: 'rgba(214, 38, 55, 0.98)',
business: 'rgba(108, 62, 200, 0.9)',
contact: 'rgba(92, 98, 121, 0.75)',
};
@@ -971,6 +971,8 @@ export function createForceGraph({ stage, model, onCenterTap, onNodeTap, onNodeL
function renderHistoryEdges() {
const Z = zoom;
const parts = [];
const defs = [];
let gradientIndex = 0;
const tx = (n) => centerX + camX + n.x * Z;
const ty = (n) => centerY + camY + n.y * Z;
@@ -1014,6 +1016,7 @@ export function createForceGraph({ stage, model, onCenterTap, onNodeTap, onNodeL
const cpx = 2 * desX - mx;
const cpy = 2 * desY - my;
const relationType = String(ref?.relationType || n.relationType || 'contact');
const reverseRelationType = String(ref?.reverseRelationType || '');
const strength = Math.max(0, Math.min(1, Number(ref?.strength) || Number(n.strength) || 0.5));
const opacity = Math.min(childOpacity, parentOpacity);
const shine = Boolean(parent.shining && n.shining) && !n.hidden;
@@ -1022,6 +1025,12 @@ export function createForceGraph({ stage, model, onCenterTap, onNodeTap, onNodeL
parts.push(...directedFriendEdgePaths(x1, y1, cpx, cpy, x2, y2, relationColor(relationType), opacity * 0.82));
continue;
}
let edgeStroke = relationColor(relationType);
if (reverseRelationType && reverseRelationType !== relationType) {
const gradientId = `fg-relation-gradient-${gradientIndex++}`;
defs.push(`<linearGradient id="${gradientId}" x1="0%" y1="0%" x2="100%" y2="0%"><stop offset="0%" stop-color="${relationColor(relationType)}"/><stop offset="100%" stop-color="${relationColor(reverseRelationType)}"/></linearGradient>`);
edgeStroke = `url(#${gradientId})`;
}
if (shine) {
const pnx = -uy;
const pny = ux;
@@ -1038,14 +1047,14 @@ export function createForceGraph({ stage, model, onCenterTap, onNodeTap, onNodeL
parts.push(`<path class="fg-plasma-core" d="${d}" opacity="${opacity.toFixed(3)}" />`);
} else {
const d = `M${x1.toFixed(1)} ${y1.toFixed(1)} Q${cpx.toFixed(1)} ${cpy.toFixed(1)} ${x2.toFixed(1)} ${y2.toFixed(1)}`;
const col = relationColor(relationType);
const col = edgeStroke;
const haloWidth = (2.6 + strength * 1.4).toFixed(2);
parts.push(`<path d="${d}" fill="none" stroke="${col}" stroke-width="${haloWidth}" stroke-linecap="round" opacity="${(0.22 * opacity).toFixed(2)}" />`);
parts.push(`<path d="${d}" fill="none" stroke="${col}" stroke-width="1.2" stroke-linecap="round" opacity="${(0.70 * opacity).toFixed(2)}" />`);
}
}
}
edgesSvg.innerHTML = parts.join('');
edgesSvg.innerHTML = `<defs>${defs.join('')}</defs>${parts.join('')}`;
}
function renderEdges() {