wip pad trainers to 80x80

need to use tup config variables for compression settings, its too
expensive for development otherwise
This commit is contained in:
Christopher Monsanto 2020-04-30 03:57:26 -04:00
parent 429b673621
commit c76e5e415a
2 changed files with 49 additions and 0 deletions

View File

@ -64,3 +64,34 @@ local files =
fbsprite(files, "build/smogon/fbsprites/xy/%B.png")
twittersprite(files, "build/smogon/twittersprites/xy/%B.png")
-- Trainers
function padtrainer(input, output)
return "convert " .. input .. " -background transparent -gravity center -extent 80x80 " .. output
end
-- TODO: move some of these to util, when we figure out the precise abstractions desired
function compresspng(filename, opts)
local cmds = {}
if opts.optipng then
cmds += "optipng -q " .. opts.optipng .. " " .. filename
end
if opts.advpng then
cmds += "advpng -q " .. opts.advpng .. " " .. filename
end
return cmds
end
function makecmd(cmds)
return table.concat(flatten(cmds), " && ")
end
tup.foreach_rule(
{"src/canonical/trainers/*"},
"^ pad trainer %f^ " .. makecmd{padtrainer("%f", "%o"), compresspng("%f", {})},
{"build/padded-trainers/canonical/%b"}
)

View File

@ -19,3 +19,21 @@ function astable(table)
return {}
end
end
-- Adapted from premake
function flatten(arr)
local result = { }
local function flatten(arr)
for v in iter(arr) do
if type(v) == "table" then
flatten(v)
else
table.insert(result, v)
end
end
end
flatten(arr)
return result
end