If I understand your idea correctly, those functions are already provided by zos to convert rgb and hex values.
I use
Lua Code:
ZO_ColorDef.FloatsToHex()
to get the hex string based on the rgb values
and I am pretty sure there is also a function for the conversion in the other direction.
(I just dont know its exact name because I have not used it so far)