Module:HexToRgb

local p = {}

function p.HexToRgb1(frame) local hex = frame.args[1]:gsub("#","") if hex:len == 3 then return "rgb(" .. ((tonumber("0x"..hex:sub(1,1))*17)/255) .. "," .. ((tonumber("0x"..hex:sub(2,2))*17)/255) .. "," .. ((tonumber("0x"..hex:sub(3,3))*17)/255) .. ")" else return "rgb(" .. (tonumber("0x"..hex:sub(1,2))/255) .. "," .. (tonumber("0x"..hex:sub(3,4))/255) .. "," .. (tonumber("0x"..hex:sub(5,6))/255) .. ")" end end

function p.HexToRgb255(frame) local hex = frame.args[1]:gsub("#","") if hex:len == 3 then return "rgb(" .. (tonumber("0x"..hex:sub(1,1))*17) .. "," .. (tonumber("0x"..hex:sub(2,2))*17) .. "," .. (tonumber("0x"..hex:sub(3,3))*17) .. ")" else return "rgb(" .. tonumber("0x"..hex:sub(1,2)) .. "," .. tonumber("0x"..hex:sub(3,4)) .. "," .. tonumber("0x"..hex:sub(5,6)) .. ")" end end

return p