Module:TierColour
From SmashWiki, the Super Smash Bros. wiki
Jump to navigationJump to search
Documentation for this module may be created at Module:TierColour/doc
local tierColours = mw.loadData("Module:TierColour/data")
local tierColouriser = {}
function tierColouriser.getColour(frame)
colourCount = tonumber(frame.args[1])
thisTier = tonumber(frame.args[2])
style = frame.args[3]
targetColour = tierColours[colourCount][thisTier]
if targetColour == nil then
targetColour = {127, 127, 127}
end
lighten = 0
if style == "header" then
lighten = 0.75
elseif style == "cell" then
lighten = 0.5
end
returnColour = {127, 127, 127} -- targetColour inherits the readonly-ness of the import
returnColour[1] = math.floor(targetColour[1] * (1 - lighten) + 255 * lighten)
returnColour[2] = math.floor(targetColour[2] * (1 - lighten) + 255 * lighten)
returnColour[3] = math.floor(targetColour[3] * (1 - lighten) + 255 * lighten)
return "rgb("..returnColour[1]..","..returnColour[2]..","..returnColour[3]..")"
end
return tierColouriser