Quantcast
Convert hexadecimal rgb to esoui SetColor(r,g,b,a) - ESOUI
Thread Tools Display Modes
06/17/21, 01:39 PM   #1
rp12439_3
AddOn Author - Click to view addons
Join Date: Jun 2021
Posts: 41
Convert hexadecimal rgb to esoui SetColor(r,g,b,a)

Hi there,

thought its easy but its not

How can I convert hex rgb CFDCBD to what ever system eso uses in SetColor.

I know values from 0 to 1... Is there a calculator?

Thanks !
  Reply With Quote
06/17/21, 01:45 PM   #2
rp12439_3
AddOn Author - Click to view addons
Join Date: Jun 2021
Posts: 41
got it:

-- declare your color once in your initialization code
local MINT_GREEN = ZO_ColorDef:New("c8ffd2")

-- assign it to the control whenever you need it
Nyght_Status_Window_StatusBar:SetColor(MINT_GREEN:UnpackRGBA())
  Reply With Quote
06/18/21, 09:17 AM   #3
ZOS_DanBatson
ZOS Staff!
 
ZOS_DanBatson's Avatar
Yes this person is from ZeniMax!
Join Date: Jul 2015
Posts: 93
There are also now a bunch of utility functions on ZO_ColorDef that allow you to convert from format to format. For instance:

Code:
local r, g, b, a = ZO_ColorDef.HexToRGBA("c8ffd2")
Nyght_Status_Window_StatusBar:SetColor(r, g, b, a)
But if you're going to use the color more than once, it's usually good to make a global ZO_ColorDef instance once and use it repeatedly.

Last edited by ZOS_DanBatson : 06/18/21 at 09:19 AM.
  Reply With Quote
06/19/21, 07:59 AM   #4
Baertram
 
Baertram's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 3,598
Just in case you guys need to find the other exisitng ZO_ColorDef functions, they are located here:
/esoui/libraries/utility/zo_colordef.lua

~around lines 66ff

Current version of the file:
https://github.com/esoui/esoui/blob/...lordef.lua#L66

Lua Code:
  1. function ZO_ColorDef:UnpackRGB()
  2. function ZO_ColorDef:UnpackRGBA()
  3. function ZO_ColorDef:SetRGB(r, g, b)
  4. function ZO_ColorDef:SetRGBA(r, g, b, a)
  5. function ZO_ColorDef:SetAlpha(a)
  6. function ZO_ColorDef:IsEqual(other)
  7. function ZO_ColorDef:Clone()
  8. function ZO_ColorDef:ToHex()
  9. function ZO_ColorDef:ToARGBHex()
  10. function ZO_ColorDef:Colorize(text)
  11. function ZO_ColorDef:Lerp(colorToLerpTorwards, amount)
  12. function ZO_ColorDef:ToHSL()
  13. function ZO_ColorDef:ToHSV()
  14. function ZO_ColorDef.RGBAToFloats(r, g, b, a)
  15. function ZO_ColorDef.FloatsToRGBA(r, g, b, a)
  16. function ZO_ColorDef.RGBAToStrings(r, g, b, a)
  17. function ZO_ColorDef.FloatsToStrings(r, g, b, a)
  18. function ZO_ColorDef.RGBAToHex(r, g, b, a)
  19. function ZO_ColorDef.FloatsToHex(r, g, b, a)
  20. function ZO_ColorDef.HexToRGBA(hexColor)
  21. function ZO_ColorDef.HexToFloats(hexColor)
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » Convert hexadecimal rgb to esoui SetColor(r,g,b,a)

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off