ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   Lua/XML Help (https://www.esoui.com/forums/forumdisplay.php?f=175)
-   -   Opacity/alpha channel on text, how? (https://www.esoui.com/forums/showthread.php?t=2040)

w33zl 08/01/14 02:47 AM

Opacity/alpha channel on text, how?
 
When you define a color using RGB you could attach an alpha channel to add transparency. My question is how to achieve this on text when using the "|c" formatting option?

If I would set the color of an entire label to red I could do like this:
Code:

myLabel:SetColor(255, 0, 0) -- equivivalent of hex code FF0000
Or I could do like this:
Code:

myLabel:SetText("|cFF0000" .. myText .. "|r")
If I would like the red text to be semi-transparent I could do like this according to the method in the first example:
Code:

myLabel:SetColor(255, 0, 0, 0.5) -- equivivalent of hex code FF0000 with 50% transparency
But how do I achieve this using the "|c" method? I would like to do anything similar to:
Code:

myLabel:SetText("|cFF00007F" .. myText .. "|r")
Or:
Code:

myLabel:SetText("|cFF0000|7F" .. myText .. "|r")
But neither alternatives works. Could anyone shine some light on this issue?

BR,
w33zl

merlight 08/01/14 04:03 AM

Controls have an additional method SetAlpha(a). Note that values for SetAlpha as well as SetColor should be in the range <0; 1>.

Garkin 08/01/14 04:52 AM

AFAIK color code can't have transparency. All you can do is as merlight suggested use myLabel:SetAlpha(0.5).

As for the hexadecimal color code - default ZO_ColorDef object works with ARGB, i.e.:
7FFF0000

Lua Code:
  1. local myColor = ZO_ColorDef:New("7FFF0000")
  2.  
  3. myText = myColor:Colorize("Hello World!")
  4. myLabel:SetColor(myColor:UnpackRGBA())

But still as I said above, transparency in the color code will be ignored, value of myText will be "|cFF0000Hello World!|r".

w33zl 08/01/14 10:02 AM

Quote:

Originally Posted by merlight (Post 10984)
Controls have an additional method SetAlpha(a). Note that values for SetAlpha as well as SetColor should be in the range <0; 1>.

Quote:

Originally Posted by Garkin (Post 10987)
AFAIK color code can't have transparency. All you can do is as merlight suggested use myLabel:SetAlpha(0.5).

Thanks both of you! I was worried it wasn't possible to set alpha on just a part of the text, however I was hoping to be wrong so I didn't have to split ut my control into multiple labels. Well, not much todo until the game supports it (wink wink ZO).


All times are GMT -6. The time now is 12:54 PM.

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