七日内新公告:全站维护公告
  • 你好~!欢迎来到萌娘百科镜像站!如需查看或编辑,请联系本站管理员注册账号。
  • 本镜像站和其他萌娘百科的镜像站无关,请注意分别。

Module:CGSS标准头像

猛汉♂百科,万男皆可猛的百科全书!转载请标注来源页面的网页链接,并声明引自猛汉百科。内容不可商用。
跳到导航 跳到搜索
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