ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   Lua/XML Help (https://www.esoui.com/forums/forumdisplay.php?f=175)
-   -   Convert hexadecimal rgb to esoui SetColor(r,g,b,a) (https://www.esoui.com/forums/showthread.php?t=9798)

rp12439_3 06/17/21 01:39 PM

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 ! :)

rp12439_3 06/17/21 01:45 PM

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())

ZOS_DanBatson 06/18/21 09:17 AM

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.

Baertram 06/19/21 07:59 AM

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)


All times are GMT -6. The time now is 05:21 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI