Hi, when experimenting with oUF I came across a healthbar style I like, which is fatter at low health so it's easier to notice. However, when implementing it, I realized that statusbars don't actually shrink or clip... they just slide along their axis.
Please look at this image on full life:
And now, when I am damaged:
The dark health bar is just moving, which makes sense for some layouts, but not for something like this. I had thought, due to some
previous discussion, that unconventionally shaped status bars weren't a problem these days.
I'm unsure how to proceed to get the desired effect of just clipping off the end of the bar with the more damage you take.
Here's the current code generating my health bar. Any advice on what to add or change to be able to use this awkwardly-shaped health effectively would be very appreciated.
Lua Code:
local Health = CreateFrame("StatusBar", "hiuiPlayerHealthBar", self)
--[[ Player Health Border (Art)
Art frame keeping the health bar in check.
--]]
local HealthBorder = Health:CreateTexture("hiuiPlayerHealthArt", "ARTWORK", nil, 1)
HealthBorder:SetTexture(defaults.player.textures.border)
HealthBorder:SetTexCoord(0, 377/512, 0, 60/64)
HealthBorder:SetPoint("TOPLEFT", self, "TOPLEFT")
HealthBorder:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT")
--[[ Player Health Status Bar
Dark bar that moves when you take damage.
--]]
Health:SetStatusBarTexture(defaults.player.textures.healthBarStretch)
-- The border art on +1 and the bg on -1, so don't need this.
--Health:GetStatusBarTexture():SetDrawLayer("ARTWORK", 0)
Health:SetPoint("TOPLEFT", HealthBorder, "TOPLEFT", 0, 0)
Health:SetPoint("BOTTOMRIGHT", HealthBorder, "BOTTOMRIGHT", 0, 0)
Health:SetReverseFill(defaults.player.reverseFill);
Health.frequentUpdates = defaults.player.frequent
--[[ Player Health Bar Background
Bright background that's revealed as damage is taken.
--]]
local HealthBg = Health:CreateTexture("hiuiPlayerHealthBg", "ARTWORK", nil, -1)
HealthBg:SetTexture(defaults.player.textures.healthBgStretch)
HealthBg:SetPoint("TOPLEFT", HealthBorder, "TOPLEFT", 0, 0)
HealthBg:SetPoint("BOTTOMRIGHT", HealthBorder, "BOTTOMRIGHT", 0, 0)
self.Health = Health
do -- bad practice, code abuse, programming under the influence
local function fixInnerElementsPos()
local l = 29/377 * hiuiPlayerHealthArt:GetWidth()
local t = 14/60 * hiuiPlayerHealthArt:GetHeight()
hiuiPlayerHealthBar:SetPoint("TOPLEFT", "hiuiPlayerHealthArt", "TOPLEFT", l, -t)
hiuiPlayerHealthBar:SetPoint("BOTTOMRIGHT", "hiuiPlayerHealthArt", "BOTTOMRIGHT", -l, t)
hiuiPlayerHealthBg:SetPoint("TOPLEFT", "hiuiPlayerHealthArt", "TOPLEFT", l, -t)
hiuiPlayerHealthBg:SetPoint("BOTTOMRIGHT", "hiuiPlayerHealthArt", "BOTTOMRIGHT", -l, t)
end
C_Timer.After(0.8, fixInnerElementsPos)
end