18 lines
535 B
Plaintext
18 lines
535 B
Plaintext
on_edge = function(sx,sy)
|
|
-- check if mouse is on the border of a node and also on an edge to another node.
|
|
-- reading from Surface; I'm going to regret this.
|
|
for _,shape in ipairs(Surface) do
|
|
if shape.type == 'line' then
|
|
if shape.keys then
|
|
-- it's an edge; assuming keys are in a specific, brittle order
|
|
if distance_sq(sx,sy, shape.data[1], shape.data[2]) < 5*5 then
|
|
return shape.keys
|
|
end
|
|
if distance_sq(sx,sy, shape.data[3], shape.data[4]) < 5*5 then
|
|
return shape.keys
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|