WoW:API UIObject SetAlpha: Difference between revisions

From AddOn Studio
Jump to navigation Jump to search
(Parent/child alpha relationship is not multiplicative)
m (Move page script moved page API UIObject SetAlpha to API UIObject SetAlpha without leaving a redirect)
 
(5 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{widgetmethod}}
{{widgetmethod}}


Sets the alpha (transparency) of the given object.  
Sets the alpha (transparency) of the given object.


  MyObject:SetAlpha(alpha)
  MyObject:SetAlpha(alpha)


== Arguments ==
== Parameters ==
 
=== Arguments ===
:;Alpha: Number - a floating-point number between 0 and 1. 1 is fully opaque, 0 is transparent.
* alpha (number) - a floating-point number between 0 and 1: 1 is fully opaque, 0 is transparent (in fact, invisible).


== Example ==
== Example ==
Makes frame <tt>MyFrame</tt> translucent, more visible than not:
MyFrame:SetAlpha(.75);


  MyFrame:SetAlpha(.75);  
Fade the whole UI so that it becomes barely visible:
 
  UIParent:SetAlpha(0.1);
Makes the frame translucent, more visible than not.


== Notes ==
== Notes ==
* As of [[2.1.0_consolidated_changes#Frames|patch 2.1.0]], transparency propagates down through all child objects.
: ''"Frame alpha now propagates in the same way as scale (though is clamped between 0 and 1 on each object). This means you can cleanly fade the whole UI or specific frame assemblies."''


Transparency is '''not''' applied to child objects the same as scaling. The parent frame's alpha is inherited if and only if the child's alpha has not been set or has been set to 1. If the child frame's alpha has been set to anything other than 1, then that alpha value is absolute and is unaffected by the parent frame's alpha setting, meaning a parent frame can be "dimmer" than its child frames.
== See also ==
 
* [[API Frame GetEffectiveAlphs|Frame:GetEffectiveAlpha()]]
''Note'': it may have behaved multiplicatively like SetScale() in previous patches, and the current behavior (patch 2.06) may be a bug. This is unconfirmed.
* [[API UIObject GetAlpha|UIObject:GetAlpha()]]
 
If you attempt to set the same value more than once it will detect this and return early after the first attempt.

Latest revision as of 04:47, 15 August 2023

Widget API ← UIObject < SetAlpha

Sets the alpha (transparency) of the given object.

MyObject:SetAlpha(alpha)

Parameters[edit]

Arguments[edit]

  • alpha (number) - a floating-point number between 0 and 1: 1 is fully opaque, 0 is transparent (in fact, invisible).

Example[edit]

Makes frame MyFrame translucent, more visible than not:

MyFrame:SetAlpha(.75);

Fade the whole UI so that it becomes barely visible:

UIParent:SetAlpha(0.1);

Notes[edit]

  • As of patch 2.1.0, transparency propagates down through all child objects.
"Frame alpha now propagates in the same way as scale (though is clamped between 0 and 1 on each object). This means you can cleanly fade the whole UI or specific frame assemblies."

See also[edit]