unitframes: option to fade health to custom color

This commit is contained in:
shagu
2021-12-13 03:20:28 +01:00
parent c38a55a89e
commit a4796e6c85
3 changed files with 15 additions and 0 deletions
+11
View File
@@ -1800,6 +1800,7 @@ function pfUI.uf:RefreshUnit(unit, component)
local custom_active = nil
local customfullhp = unit.config.defcolor == "0" and unit.config.customfullhp or C.unitframes.customfullhp
local customcolor = unit.config.defcolor == "0" and unit.config.customcolor or C.unitframes.customcolor
local customfade = unit.config.defcolor == "0" and unit.config.customfade or C.unitframes.customfade
local custom = unit.config.defcolor == "0" and unit.config.custom or C.unitframes.custom
local r, g, b, a = .2, .2, .2, 1
@@ -1839,6 +1840,16 @@ function pfUI.uf:RefreshUnit(unit, component)
r, g, b = (r + .5) * .5, (g + .5) * .5, (b + .5) * .5
end
if customfade == "1" then
-- fade custom color into default color
local perc = UnitHealth(unitstr) / UnitHealthMax(unitstr) * 2 - 1
local cr, cg, cb, ca = pfUI.api.strsplit(",", customcolor)
r = (cr*perc) + (r*(1-perc))
g = (cr*perc) + (g*(1-perc))
b = (cr*perc) + (b*(1-perc))
end
unit.hp.bar:SetStatusBarColor(r, g, b, a)
-- set powerbar color