WoW:USERAPI HexToRGB: Difference between revisions

m
Move page script moved page USERAPI HexToRGB to WoW:USERAPI HexToRGB without leaving a redirect
m (Imp HexToRGB)
m (Move page script moved page USERAPI HexToRGB to WoW:USERAPI HexToRGB without leaving a redirect)
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{userfunc}}
{{userfunc}}
__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