Thread Tools Display Modes
08/01/14, 02:47 AM   #1
w33zl
 
w33zl's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 13
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
  Reply With Quote
08/01/14, 04:03 AM   #2
merlight
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 671
Controls have an additional method SetAlpha(a). Note that values for SetAlpha as well as SetColor should be in the range <0; 1>.
  Reply With Quote
08/01/14, 04:52 AM   #3
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
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".
  Reply With Quote
08/01/14, 10:02 AM   #4
w33zl
 
w33zl's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 13
Originally Posted by merlight View Post
Controls have an additional method SetAlpha(a). Note that values for SetAlpha as well as SetColor should be in the range <0; 1>.
Originally Posted by Garkin View Post
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).
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » Opacity/alpha channel on text, how?


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