Skip to content

Commit 175e637

Browse files
committed
Use own way of calculating number of bend points
1 parent a104c8f commit 175e637

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

lib/index.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,19 @@ function render(skin_data, yosys_netlist, done) {
6565

6666
const indexOfMin = graphs.reduce((prev, [g, m], i) => {
6767
m.bendPoints = g.edges.reduce((prev, e) => {
68-
return prev + e.sections.reduce((p, s) => p + (s.bendPoints || []).length, 0)
68+
return prev + e.sections.reduce((prev, s) => {
69+
// only count the bendpoints if it's not a straight line (a
70+
// straight line doesn't have any bends, but ELK seems to
71+
// count them anyway)
72+
if (s.startPoint.x !== s.endPoint.x && s.startPoint.y !== s.endPoint.y) {
73+
return prev + (s.bendPoints || []).length
74+
}
75+
return prev
76+
}, 0)
6977
}, 0)
70-
if (m.bendPoints <= prev[0])
78+
if (m.bendPoints <= prev[0]) {
7179
return [m.bendPoints, i]
80+
}
7281
return prev
7382
}, [Infinity, 0])[1]
7483

0 commit comments

Comments
 (0)