Thread Tools Display Modes
04-24-11, 02:04 PM   #1
Aftermathhqt
A Molten Giant
 
Aftermathhqt's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 784
gradient colors

Hello there, i'm trying to add gradient colors depending on health statusbar color, but i have know idea how do add this. anyone knows ?

like if 10% hp then the health statusbarcolor is red.

like if 50% hp then the health statusbarcolor is yellow.

like if 80% hp then the health statusbarcolor is green.

Last edited by Aftermathhqt : 04-25-11 at 08:24 AM.
  Reply With Quote
04-25-11, 03:37 PM   #2
Akkorian
A Flamescale Wyrmkin
 
Akkorian's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2010
Posts: 111
Hi Game92,

Does the healthBar.colorSmooth property not work for you? If you need more flexibility, you could look at the gradient function in oUF for an example of how to write your own.
__________________
“Be humble, for you are made of earth. Be noble, for you are made of stars.”
  Reply With Quote
04-25-11, 05:10 PM   #3
Aftermathhqt
A Molten Giant
 
Aftermathhqt's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 784
Originally Posted by Akkorian View Post
Hi Game92,

Does the healthBar.colorSmooth property not work for you? If you need more flexibility, you could look at the gradient function in oUF for an example of how to write your own.
Nop, don't think so, its just green all the time on the statusbar, anyways i changed my mind i want the health backdrop to be like it, can you link it? nvm i tihnk i found it ;>

Anyways got the idea from oUF Mono, but can't seem to fina anything.


Last edited by Aftermathhqt : 04-25-11 at 05:27 PM.
  Reply With Quote
04-25-11, 05:38 PM   #4
Aftermathhqt
A Molten Giant
 
Aftermathhqt's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 784
Just somthing i came up with

Code:
local UpdateHealth = function(self, health, perc)
    if (perc == 100) then
	    self:SetVertexColor(0, 0, 0, 0.8) -- 100% health
	elseif(perc >= 80 ) then
        self:SetVertexColor(0, 0, 1, 0.8) -- 80>50% health green
	elseif(perc >= 50 ) then
	    self:SetVertexColor(1, 1, 0, 0.8) -- 50>20% health yellow
    elseif(perc >= 20 ) then	 
	    self:SetVertexColor(1, 0, 0, 0.8) -- 20>0% health red 
	end	
end
  Reply With Quote
04-25-11, 06:13 PM   #5
Aftermathhqt
A Molten Giant
 
Aftermathhqt's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 784
Code:
	local healthbg = health:CreateTexture(nil, 'BORDER')
	healthbg:SetAllPoints(health)
	healthbg:SetTexture(backdrop)
	
	if ( UnitHealth == 100) then
	    healthbg:SetVertexColor(0, 0, 0, 0.8) -- 100% health
	elseif ( UnitHealth ~= 90 ) then
        healthbg:SetVertexColor(0, 0, 1, 0.8) -- 90>50% health green
	elseif ( UnitHealth ~= 50 ) then
	    healthbg:SetVertexColor(1, 1, 0, 0.8) -- 50>30% health yellow
    elseif ( UnitHealth ~= 30 ) then	 
	    healthbg:SetVertexColor(1, 0, 0, 0.8) -- 30>0% health red 
	end
Doesn't work, i guess it needs some tweaks.

Last edited by Aftermathhqt : 04-25-11 at 06:16 PM.
  Reply With Quote
04-25-11, 07:03 PM   #6
nin
A Cobalt Mageweaver
AddOn Author - Click to view addons
Join Date: Dec 2008
Posts: 213
i use a gradient function too do this. i don't know it in my head though and im not at home -_-

Seen a lot of people doing it in their healthupdates with this string.

Code:
r, g, b = self.ColorGradient(min/max, r,g,b,r,g,b,r,g,b)
r,g,b you need too set too the color values you want.
  Reply With Quote
04-25-11, 07:26 PM   #7
Aftermathhqt
A Molten Giant
 
Aftermathhqt's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 784
The thing is i want to affect my health backdrop not my health bar and i'm going with just normal coloring

Code:
local healthbg = health:CreateTexture(nil, 'BORDER')
	healthbg:SetAllPoints(health)
	healthbg:SetTexture(texture)
	healthbg:SetVertexColor(0, 0, 0, 0.6)
	
	if ( hp% == 100) then
	    healthbg:SetVertexColor(0, 0, 0, 0.8) -- 100% health
	elseif ( hp% ~= 90 ) then
        healthbg:SetVertexColor(0, 0, 1, 0.8) -- 90>50% health green
	elseif ( hp% ~= 50 ) then
	    healthbg:SetVertexColor(1, 1, 0, 0.8) -- 50>30% health yellow
    elseif ( hp% ~= 30 ) then	 
	    healthbg:SetVertexColor(1, 0, 0, 0.8) -- 30>0% health red 
	end

Last edited by Aftermathhqt : 04-25-11 at 07:39 PM.
  Reply With Quote
04-26-11, 06:30 PM   #8
frohanss
A Cyclonian
AddOn Author - Click to view addons
Join Date: Mar 2011
Posts: 40
Nice 1 Game29.

I'v just been using:
Code:
	    healthbg:SetGradientAlpha("HORIZONTAL",0,1,0,1,1,0,0,1)
But it only fades from green to red. Not sure if it could be set to 50% of bar size and used another for below 50%.

Would be nice if some have a better way to color the back panel more acurate. Cause i don't whana touch the front/health bar color. Only the "missing" hp part.

Last edited by frohanss : 04-26-11 at 06:35 PM.
  Reply With Quote

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » gradient colors


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off