If a raid unit is out of range and you are using bright backgrounds the background will shine through and the whole frame will glow in light background color.
Example:
You can prevent this with two textures and some math.
createHealth
lua Code:
--create health frames
local createHealthFrame = function(self)
-- health statusbar
local h = CreateFrame("StatusBar", nil, self)
h:SetAllPoints(self)
h:SetStatusBarTexture("") --use transparent texture
--save the width of the healthbar, important for later
h.w = self:GetWidth()
--new bg texture
local t = h:CreateTexture(nil,"BACKGROUND",nil,-6)
t:SetPoint("TOPRIGHT",h,"TOPRIGHT",0,0)
t:SetPoint("BOTTOMRIGHT",h,"BOTTOMRIGHT",0,0)
t:SetWidth(0.01)
t:SetTexture(self.cfg.health.texture)
h.back = t
--new fake statusbar
local n = h:CreateTexture(nil,"BACKGROUND",nil,-6)
n:SetPoint("TOPLEFT",h,"TOPLEFT",0,0)
n:SetPoint("BOTTOMLEFT",h,"BOTTOMLEFT",0,0)
n:SetPoint("RIGHT", t, "LEFT", 0, 0) --right point of n will anchor left point of t
n:SetTexture(self.cfg.health.texture)
h.new = n
h.new:SetVertexColor(0.15,0.15,0.15,1)
h.back:SetVertexColor(1,0,0,1)
self.Health = h
end
postUpdateHealth
lua Code:
--post update health func
local postUpdateHealth = function(bar, unit, min, max)
local d = floor(min/max*100)
--apply bar width
if d == 100 then
bar.back:SetWidth(0.01) --fix (0) makes the bar go anywhere
elseif d < 100 then
local w = bar.w
bar.back:SetWidth(w-(w*d/100)) --calc new width of bar based on size of healthbar
end
end
Result: