WoW:USERAPI RGBToHex
This page documents a <i>user-defined function</i> that you can copy and paste into your addon. Replace PREFIX with your addon or lib prefix to avoid conflicts between different versions of these functions.
Takes a RGB value set (0-255) and converts it into a hex string.
local function RGBToHex(r, g, b)
return string.format("%02x%02x%02x", r, g, b)
end