wardley.love/0041-on_border

21 lines
595 B
Plaintext

on_border = function(sx,sy)
local corner_radius = 10
local near = function(a, b)
return a >= b-corner_radius and a < b+corner_radius
end
for _,node in ipairs(Surface) do
if node.type == 'text' then
local h = node_height(node)
if sx >= node.x-10-corner_radius and sx < node.x + node.w+10+corner_radius then
if near(sy, node.y-10) or near(sy, node.y+h+10) then
return node
end
end
if sy >= node.y-10-corner_radius and sy < node.y + h+10+corner_radius then
if near(sx, node.x-10) or near(sx, node.x+node.w+10) then
return node
end
end
end
end
end