I was failing earlier when the aspect ratio was close to square. Like with the default resolution of a LÖVE window on a computer :/ Thanks Ivan Reese for the report.
LUYWR2DLKU5HA5LEY5ZW6BKL5WEWJREBN5WL4C7XPYECD7LUP3VQC
side = min(w/(lw+6), h/(lh+6)) -- leave some margin for buttons
local w1, w2 = landscape_button_offsets()
local h1, h2 = portrait_button_offsets()
if Safe_width > Safe_height then
side = min((w-w1-w2)/(1+lw+1+6), h/(lh+6)) -- leave 1 side between board and buttons
else
side = min(w/(lw+6), (h-h1-h2)/(1+lh+1+6)) -- leave 1 side between board and buttons
end
bside = min(left, top)
if Safe_width > Safe_height then
bside = min((w-w1-w2-side*(1+lw+1))/2, (h-side*lh)/2)
else
bside = min((h-h1-h2-side*(1+lh+1))/2, (w-side*lw)/2)
end
end
-- space needed for buttons to the left and right
function landscape_button_offsets()
local ns, ps = tostring('>>'), tostring('<<')
local nw, pw = App.width(ns)+10, App.width(ps)+10
return 10+pw+10, 10+nw+10
-- we assume the level name and undo button will be within this width
end
-- space needed for buttons to the top and bottom
function portrait_button_offsets()
return 10+Line_height+10, 10+Line_height+10