Lore archive · Warcraft Wiki, 2023 dump
HexToRGB
Last wiki revision 2013-05-31
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
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).
local function HexToRGB(hex) if type(hex) == "string" then local m = #hex == 3 and 17 or (#hex == 6 and 1 or 0) local rhex, ghex, bhex = hex:match('^(%x%x?)(%x%x?)(%x%x?)$') if rhex and m > 0 then return tonumber(rhex, 16) * m, tonumber(ghex, 16) * m, tonumber(bhex, 16) * m end end return 0, 0, 0 end
Source
https://warcraft.wiki.gg/wiki/HexToRGB · retrieved 2023-11-13 · CC BY-SA 4.0
Converted from wikitext with templates, tables and images removed, so some sentences may be missing values.
This archive predates WoW: Forever. For collected gameplay facts see the Forever database. Search the archive.