@cardenelabs/cdl 0.20.1 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -1
- package/dist/index.cjs +67 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +67 -2
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +67 -2
- package/dist/react.cjs.map +1 -1
- package/dist/react.js +67 -2
- package/dist/react.js.map +1 -1
- package/package.json +1 -1
- package/src/layout/collisions.ts +100 -2
package/dist/react.js
CHANGED
|
@@ -913,6 +913,7 @@ function footerShapeDrawTop(node) {
|
|
|
913
913
|
|
|
914
914
|
// src/layout/collisions.ts
|
|
915
915
|
var LANE_LABEL_CLEARANCE_MARGIN = 2;
|
|
916
|
+
var NEAR_MISS_MARGIN = LANE_LABEL_CLEARANCE_MARGIN;
|
|
916
917
|
function collectBBoxes(lanes, nodes, edges) {
|
|
917
918
|
const out = [];
|
|
918
919
|
for (const lane of lanes) {
|
|
@@ -1582,8 +1583,8 @@ function resolveEdgeLabelOverlapsWithChainAndPropagate(edges, obstacles, minClea
|
|
|
1582
1583
|
};
|
|
1583
1584
|
const shift = computeOverlapShift(label, inflated);
|
|
1584
1585
|
if (!shift) continue;
|
|
1585
|
-
const amount = shift.amount - minClearance;
|
|
1586
|
-
if (amount <=
|
|
1586
|
+
const amount = shift.amount - minClearance + NEAR_MISS_MARGIN;
|
|
1587
|
+
if (amount <= NEAR_MISS_MARGIN) continue;
|
|
1587
1588
|
out.push({
|
|
1588
1589
|
target: { kind: "label", id: label.id },
|
|
1589
1590
|
axis: shift.axis,
|
|
@@ -1624,6 +1625,36 @@ function resolveEdgeLabelOverlapsWithChainAndPropagate(edges, obstacles, minClea
|
|
|
1624
1625
|
out.push({ target: { kind: "label", id: moveBox.id }, ...shift });
|
|
1625
1626
|
}
|
|
1626
1627
|
}
|
|
1628
|
+
for (let i = 0; i < labels.length; i++) {
|
|
1629
|
+
for (let j = i + 1; j < labels.length; j++) {
|
|
1630
|
+
const a = labels[i];
|
|
1631
|
+
const b = labels[j];
|
|
1632
|
+
if (computeOverlapShift(a, b)) continue;
|
|
1633
|
+
const orderA = edgeOrder.get(a.id);
|
|
1634
|
+
const orderB = edgeOrder.get(b.id);
|
|
1635
|
+
const moveBox = orderA > orderB ? a : b;
|
|
1636
|
+
const staticBox = orderA > orderB ? b : a;
|
|
1637
|
+
const required = requiredNearClearance(moveBox.kind, staticBox.kind);
|
|
1638
|
+
const inflated = {
|
|
1639
|
+
...staticBox,
|
|
1640
|
+
x: staticBox.x - required,
|
|
1641
|
+
y: staticBox.y - required,
|
|
1642
|
+
w: staticBox.w + required * 2,
|
|
1643
|
+
h: staticBox.h + required * 2
|
|
1644
|
+
};
|
|
1645
|
+
const shift = computeOverlapShift(moveBox, inflated);
|
|
1646
|
+
if (!shift) continue;
|
|
1647
|
+
const amount = shift.amount - minClearance + NEAR_MISS_MARGIN;
|
|
1648
|
+
if (amount <= NEAR_MISS_MARGIN) continue;
|
|
1649
|
+
out.push({
|
|
1650
|
+
target: { kind: "label", id: moveBox.id },
|
|
1651
|
+
axis: shift.axis,
|
|
1652
|
+
sign: shift.sign,
|
|
1653
|
+
amount,
|
|
1654
|
+
chain: false
|
|
1655
|
+
});
|
|
1656
|
+
}
|
|
1657
|
+
}
|
|
1627
1658
|
for (const label of labels) {
|
|
1628
1659
|
const currentShift = getLabelChainShift(label.id);
|
|
1629
1660
|
if (currentShift.dx === 0 && currentShift.dy === 0) continue;
|
|
@@ -1719,12 +1750,46 @@ function resolveEdgeLabelOverlapsWithChainAndPropagate(edges, obstacles, minClea
|
|
|
1719
1750
|
if (bestSideIdx < 0) continue;
|
|
1720
1751
|
const amount = pathLabelClearance - gap + pathLabelClearance;
|
|
1721
1752
|
const ordered = edgeProbes.map((p, idx) => ({ p, idx })).sort((a, b) => probeDist[a.idx] - probeDist[b.idx]);
|
|
1753
|
+
let \u7DDA\u3092\u52D5\u304B\u305B\u305F = false;
|
|
1722
1754
|
for (const { p } of ordered) {
|
|
1723
1755
|
const axis = p.axis;
|
|
1724
1756
|
if (!pathShiftIsSafe(e.id, axis, p.sign, amount)) continue;
|
|
1725
1757
|
out.push({ target: { kind: "edge-path", id: e.id }, axis, sign: p.sign, amount });
|
|
1758
|
+
\u7DDA\u3092\u52D5\u304B\u305B\u305F = true;
|
|
1726
1759
|
break;
|
|
1727
1760
|
}
|
|
1761
|
+
if (!\u7DDA\u3092\u52D5\u304B\u305B\u305F) {
|
|
1762
|
+
const \u82AF = { x: label.x + label.w / 2, y: label.y + label.h / 2 };
|
|
1763
|
+
let \u8FD1\u3044\u70B9 = null;
|
|
1764
|
+
let \u6700\u77ED = Infinity;
|
|
1765
|
+
for (const seg of segs) {
|
|
1766
|
+
for (const \u70B9 of [
|
|
1767
|
+
{ x: seg.x1, y: seg.y1 },
|
|
1768
|
+
{ x: seg.x2, y: seg.y2 },
|
|
1769
|
+
{ x: (seg.x1 + seg.x2) / 2, y: (seg.y1 + seg.y2) / 2 }
|
|
1770
|
+
]) {
|
|
1771
|
+
const d = Math.hypot(\u70B9.x - \u82AF.x, \u70B9.y - \u82AF.y);
|
|
1772
|
+
if (d < \u6700\u77ED) {
|
|
1773
|
+
\u6700\u77ED = d;
|
|
1774
|
+
\u8FD1\u3044\u70B9 = \u70B9;
|
|
1775
|
+
}
|
|
1776
|
+
}
|
|
1777
|
+
}
|
|
1778
|
+
if (\u8FD1\u3044\u70B9) {
|
|
1779
|
+
const dx = \u82AF.x - \u8FD1\u3044\u70B9.x;
|
|
1780
|
+
const dy = \u82AF.y - \u8FD1\u3044\u70B9.y;
|
|
1781
|
+
const axis = Math.abs(dx) >= Math.abs(dy) ? "x" : "y";
|
|
1782
|
+
const \u5411\u304D = axis === "x" ? dx : dy;
|
|
1783
|
+
const sign = \u5411\u304D >= 0 ? 1 : -1;
|
|
1784
|
+
out.push({
|
|
1785
|
+
target: { kind: "label", id: label.id },
|
|
1786
|
+
axis,
|
|
1787
|
+
sign,
|
|
1788
|
+
amount: pathLabelClearance - gap + NEAR_MISS_MARGIN,
|
|
1789
|
+
chain: false
|
|
1790
|
+
});
|
|
1791
|
+
}
|
|
1792
|
+
}
|
|
1728
1793
|
}
|
|
1729
1794
|
}
|
|
1730
1795
|
for (const label of labels) {
|