Module:Sandbox/Jikat2/gradient

Revision as of 18:46, 3 July 2021 by imported>Bumbleglue123
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Documentation for this module may be created at Module:Sandbox/Jikat2/gradient/doc

local p = {}
p.gradient = function(frame)
local ranking = frame.args.ranking
local colorValue = ""
local rankingPercent = ranking/43
local redNum = rankingPercent * 255
local greenNum = 102 + rankingPercent * 153
local redOut = string.format("%x", redNum)
local greenOut = string.format("%x", greenNum)
if string.len (redOut) == 1 then redOut = "0" .. redOut
end
if string.len (greenOut) == 1 then greenOut = "0" .. greenOut
end
colorValue = redOut .. greenOut .. "00"
local msg = ""
if redNum >= 50.0 then msg = "style='background:#" .. colorValue .. "; color:black'|" .. ranking
end
if redNum < 50.0 then msg = "style='background:#" .. colorValue .. "; color:white'|" .. ranking
end
return msg
end
return p