WoW:USERAPI HexToRGB: Difference between revisions

no edit summary
m (Imp HexToRGB)
No edit summary
Line 1: Line 1:
{{userfunc}}
{{userfunc}}
__NOTOC__
__NOTOC__
Takes a hex string (must be 6 char long!) and converts it to a RGB set (0-255)


local function HexToRGB(hex)
local rhex, ghex, bhex = string.sub(hex, 1, 2), string.sub(hex, 3, 4), string.sub(hex, 5, 6)
return tonumber(rhex, 16), tonumber(ghex, 16), tonumber(bhex, 16)
end
== Alternative version ==
Takes a hex string (must be 3 or 6 chars long!) and converts it to a RGB set (0-255). If ''hex'' is invalid, return black (0,0,0).
Takes a hex string (must be 3 or 6 chars long!) and converts it to a RGB set (0-255). If ''hex'' is invalid, return black (0,0,0).


Anonymous user