Wowpedia
Advertisement
Wowpedia
240,483
pages

Returns a region's opacity.

alpha = region:GetAlpha()
effectiveAlpha = region:GetEffectiveAlpha()

Returns

alpha 
number - The region's opacity as a proportion of its immediate parent (if it has one)
effectiveAlpha 
number - The region's net opacity, including its parent's effective alpha

Details

  • Region:SetIgnoreParentAlpha() allows a widget full control over its own alpha, rather than as a proportion of its parent's alpha.
  • Unaffected and unrelated to Region:IsShown(); changing alpha is not the same as hiding a frame.

Example

Opacity extends from each widget to its children

local parent = CreateFrame("Frame")
parent:SetAlpha(0.5)
local child = CreateFrame("Frame", nil, parent)
child:SetAlpha(0.5)
print(child:GetAlpha())                 -- 0.5
print(child:GetEffectiveAlpha())        -- 0.25

It is possible, albeit inefficient and unnecessary, to compute the effective alpha using GetAlpha() alone

function ComputeEffectiveAlpha(region)
	local alpha = 1
	while region do                       
		alpha = alpha * region:GetAlpha()
		if region:IsIgnoringParentAlpha() then
			return alpha
		end
		region = region:GetParent()
	end
	return alpha
end

Patch changes

  • Bc icon.gif Patch 2.1.0 / API (2007-05-22): GetEffectiveAlpha() added.[1]
    "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."

References

Advertisement