But this only draws one edge and crashes on the second.
O6BJMU4CBHITY2L3ST32YBU2H7ZXYH47Q2TBA4THK5YMAPM6JZEAC
compute_layout_for_edge = function(s, e)
local cs = centroid(Nodes[s])
local ce = centroid(Nodes[e])
local s = intersect_with_centroid(Nodes[s], ce.sx,ce.sy)
local e = intersect_with_centroid(Nodes[e], s.sx,s.sy)
table.insert(Surface, {type='line', r=0,g=0,b=0, data={s.sx,s.sy, e.sx,e.sy}})
end
centroid = function(node)
return {
sx=node.x + node.width/2,
sy=node.y + node_height(node)/2
}
end
local h = node_height(Edge.source)
local c = {
sx=Edge.source.x + Edge.source.w/2,
sy=Edge.source.y + h/2
}
if c.sx == sx then
if sy > c.sy then
return {sx=sx, sy=Edge.source.y + h + 10}
else
return {sx=sx, sy=Edge.source.y - 10}
end
end
local h = node_height(node)
local c = centroid(node)
local y = y_at_x(sx,sy, c.sx,c.sy, Edge.source.x-10)
if y and y >= Edge.source.y-10 and y < Edge.source.x+h+10 then
table.insert(candidates, {sx=Edge.source.x-10, sy=y})
local y = y_at_x(sx,sy, c.sx,c.sy, node.x-10)
if y and y >= node.y-10 and y < node.x+h+10 then
table.insert(candidates, {sx=node.x-10, sy=y})
y = y_at_x(sx,sy, c.sx,c.sy, Edge.source.x + Edge.source.w + 10)
if y and y >= Edge.source.y-10 and y < Edge.source.x+h+10 then
table.insert(candidates, {sx=Edge.source.x+Edge.source.w+10, sy=y})
y = y_at_x(sx,sy, c.sx,c.sy, node.x+node.w+10)
if y and y >= node.y-10 and y < node.x+h+10 then
table.insert(candidates, {sx=node.x+node.w+10, sy=y})
local x = x_at_y(sx,sy, c.sx,c.sy, Edge.source.y-10)
if x and x >= Edge.source.x-10 and x < Edge.source.x + Edge.source.w + 10 then
table.insert(candidates, {sx=x, sy=Edge.source.y-10})
local x = x_at_y(sx,sy, c.sx,c.sy, node.y-10)
if x and x >= node.x-10 and x < node.x+node.w+10 then
table.insert(candidates, {sx=x, sy=node.y-10})
x = x_at_y(sx,sy, c.sx,c.sy, Edge.source.y+h+10)
if x and x >= Edge.source.x-10 and x < Edge.source.x + Edge.source.w + 10 then
table.insert(candidates, {sx=x, sy=Edge.source.y+h+10})
x = x_at_y(sx,sy, c.sx,c.sy, node.y+h+10)
if x and x >= node.x-10 and x < node.x+node.w+10 then
table.insert(candidates, {sx=x, sy=node.y+h+10})