Round backported x/y/w/h numbers

This commit is contained in:
luk3yx 2020-09-10 14:21:55 +12:00
parent 4140908e65
commit 490ff71e47
1 changed files with 11 additions and 0 deletions

View File

@ -444,7 +444,18 @@ end
function renderer.export(tree, opts)
if opts.use_v1 then
tree = fs51.backport(tree)
-- Round numbers to 2 decimal places
local c = {'x', 'y', 'w', 'h'}
for node in formspec_ast.walk(tree) do
for _, k in ipairs(c) do
if type(node[k]) == 'number' then
node[k] = math.floor((node[k] * 100) + 0.5) / 100
end
end
end
end
local fs, err = formspec_ast.unparse(tree)
if not fs then return nil, err end
if opts.format then