local getArgs = require('Module:Arguments').getArgs
local iconData = require('Module:CGSSIconData')
local p = {}
function p.main(frame)
local args = getArgs(frame)
local name = args[1] or ""
local size = tonumber(args[2]) or 42
local pos = iconData.posTable[name] or -1
if pos == -1 then
-- EmptyIcon
return string.format(
'<span class="EmptyIcon" style="height:%dpx;width:%dpx;background-size:%dpx"></span>',
size, size, size
)
else
local link = iconData.linkTable[pos] or 'JF'
if size == 42 then
-- Ic4
local x = 420 - 42 * (pos % 10)
local y = 840 - 42 * math.floor(pos / 10)
return string.format(
'[[%s|<span class="Ic4" style="background-position:%dpx %dpx"></span>]]',
link, x, y
)
else
-- Ico
local x = size * 10 - size * (pos % 10)
local y = size * 20 - size * math.floor(pos / 10)
local bgsize = size * 10
return string.format(
'[[%s|<span class="Ico" style="height:%dpx;width:%dpx;background-size:%dpx;background-position:%dpx %dpx"></span>]]',
link, size, size, bgsize, x, y
)
end
end
end
return p