pothi.love/0148-compute_viewport_bounds

21 lines
624 B
Plaintext

compute_viewport_bounds = function()
local xmin, ymin, xmax, ymax
for i,node in ipairs(Surface) do
if node.type == 'text' or node.type == 'rows' or node.type == 'cols' then
if xmin == nil or xmin > node.x then
xmin = node.x
end
if xmax == nil or xmax < node.x+node.w then
xmax = node.x+node.w
end
if ymin == nil or ymin > node.y then
ymin = node.y
end
if ymax == nil or ymax < node.y + node.h then
ymax = node.y+node.w
end
end
end
xmin, ymin = xmin-50, ymin-50
Viewport_bounds.xmin, Viewport_bounds.xmax, Viewport_bounds.ymin, Viewport_bounds.ymax = xmin,xmax, ymin, ymax
end