Поправил пуши для личных сообщений

This commit is contained in:
AidarKC
2026-10-21 11:47:27 +03:00
parent aa5addb5d9
commit 7a6ab3b35a
22 changed files with 723 additions and 678 deletions
+36 -6
View File
@@ -1604,6 +1604,20 @@ export function createGraphCanvas({ stage, onSelect, onNodeMoved, onGroupSelect,
return !edge.tie;
}
// Подотрезок квадратичной Безье по параметру t (направление: добавивший → добавленный).
function quadraticPart(g, from, to) {
const point = (t) => ({
x: (1 - t) ** 2 * g.x1 + 2 * t * (1 - t) * g.cx + t ** 2 * g.x2,
y: (1 - t) ** 2 * g.y1 + 2 * t * (1 - t) * g.cy + t ** 2 * g.y2,
});
const first = point(from);
const last = point(to);
const dx = 2 * ((1 - from) * (g.cx - g.x1) + from * (g.x2 - g.cx));
const dy = 2 * ((1 - from) * (g.cy - g.y1) + from * (g.y2 - g.cy));
const dt = (to - from) / 2;
return { first, ctrl: { x: first.x + dx * dt, y: first.y + dy * dt }, last };
}
// Нити рисуются пачками одного вида: сотни отдельных штрихов со сменой пунктира – это
// и была главная цена кадра на «друзьях друзей».
function drawEdges(inView, widthScale) {
@@ -1660,13 +1674,29 @@ export function createGraphCanvas({ stage, onSelect, onNodeMoved, onGroupSelect,
for (const batch of ordered) {
ctx.strokeStyle = rgba(colors.edge[batch.type], batch.alpha);
ctx.lineWidth = EDGE_WIDTH[batch.type] * widthScale * (batch.incident ? 1.5 : 1);
ctx.setLineDash(batch.mutual ? [] : [5 * widthScale, 4 * widthScale]);
ctx.beginPath();
for (const g of batch.list) {
ctx.moveTo(g.x1, g.y1);
ctx.quadraticCurveTo(g.cx, g.cy, g.x2, g.y2);
if (batch.mutual) {
ctx.setLineDash([]);
ctx.beginPath();
for (const g of batch.list) {
ctx.moveTo(g.x1, g.y1);
ctx.quadraticCurveTo(g.cx, g.cy, g.x2, g.y2);
}
ctx.stroke();
} else {
// От инициатора дружбы линия почти сплошная; возле адресата превращается в точки.
// Делим кривую, сохраняя геометрию и пакетную отрисовку внутри каждого сегмента.
const patterns = [[20, 3], [12, 4], [6, 4], [1, 5]];
patterns.forEach(([dash, gap], section) => {
ctx.setLineDash([dash * widthScale, gap * widthScale]);
ctx.beginPath();
for (const g of batch.list) {
const part = quadraticPart(g, section / 4, (section + 1) / 4);
ctx.moveTo(part.first.x, part.first.y);
ctx.quadraticCurveTo(part.ctrl.x, part.ctrl.y, part.last.x, part.last.y);
}
ctx.stroke();
});
}
ctx.stroke();
}
ctx.setLineDash([]);
}