修复头像重叠问题

This commit is contained in:
chatgpt-yunju 2025-07-07 19:28:44 +08:00
parent 1688d8b200
commit ddcba3b96e

View File

@ -171,11 +171,28 @@ onMounted(() => {
// 5. combo
nodes.forEach(node => {
const combo = combos.find(c => c.id === node.comboId);
// combo
const angle = Math.random() * 2 * Math.PI;
const radius = Math.random() * (combo.r - nodeSize / 2);
node.x = combo.x + Math.cos(angle) * radius;
node.y = combo.y + Math.sin(angle) * radius;
let valid = false;
let tryCount = 0;
let x, y;
const placed = nodes.filter(n => n.comboId === node.comboId && n !== node);
while (!valid && tryCount < 100) {
const angle = Math.random() * 2 * Math.PI;
const radius = Math.random() * (combo.r - nodeSize / 2);
x = combo.x + Math.cos(angle) * radius;
y = combo.y + Math.sin(angle) * radius;
valid = true;
for (const other of placed) {
const dx = x - other.x;
const dy = y - other.y;
if (Math.sqrt(dx * dx + dy * dy) < nodeSize) {
valid = false;
break;
}
}
tryCount++;
}
node.x = x;
node.y = y;
});
// 6. layout: nullG6