67 lines
		
	
	
		
			2.3 KiB
		
	
	
	
		
			Lua
		
	
	
	
	
	
			
		
		
	
	
			67 lines
		
	
	
		
			2.3 KiB
		
	
	
	
		
			Lua
		
	
	
	
	
	
| --UPDATE_MOUSEOVER_UNIT
 | |
| function()
 | |
|     return true
 | |
| end
 | |
| 
 | |
| --DISPLAY
 | |
| function()
 | |
|     if UnitBuff("mouseover", "Rejuvenation (Germination)") then
 | |
|         local caster = select(8, UnitBuff("mouseover", "Rejuvenation (Germination)"))
 | |
|         if caster == "player" then
 | |
|             local amount = select(17, UnitBuff("mouseover", "Rejuvenation (Germination)"))
 | |
|             local exp = select(7, UnitBuff("mouseover", "Rejuvenation (Germination)"))
 | |
|             local dur = select(6, UnitBuff("mouseover", "Rejuvenation (Germination)"))
 | |
|             local remDur = exp - GetTime()
 | |
|             return aura_env.hexgrad(dur - remDur, 0, dur) .. aura_env.shorten(amount) .. "\124r"
 | |
|         end
 | |
|     end
 | |
| end
 | |
| 
 | |
| --INIT
 | |
| aura_env.hexgrad = function(val, min, max)
 | |
|     local function tohex(input)
 | |
|         local output = string.format("%x", input * 255)
 | |
|         return output
 | |
|     end
 | |
|     local function grad(c, min, max)
 | |
|         c = (((max - c) / (max - min)) * 1)
 | |
|         if c > 0.5 then
 | |
|             c = 1 - (2 * (c - 0.5))
 | |
|             return c, 1, 0, 1
 | |
|         else
 | |
|             c = c * 2
 | |
|             return 1, c, 0, 1
 | |
|         end
 | |
|     end
 | |
|     local color1, color2, color3, color4 = 0, 0, 0, 0
 | |
|     color1, color2, color3, color4 = grad(val, min, max)
 | |
|     color1, color2, color3, color4 = tohex(color1), tohex(color2), tohex(color3), tohex(color4)
 | |
|     color1, color2, color3, color4 = tostring(color1), tostring(color2), tostring(color3), tostring(color4)
 | |
|     if string.len(color1) == 1 then color1 = "0" .. color1 end
 | |
|     if string.len(color2) == 1 then color2 = "0" .. color2 end
 | |
|     if string.len(color3) == 1 then color3 = "0" .. color3 end
 | |
|     if string.len(color4) == 1 then color4 = "0" .. color4 end
 | |
|     local color = "\124c" .. color4 .. color1 .. color2 .. color3
 | |
|     return color
 | |
| end
 | |
| aura_env.shorten = function(val)
 | |
|     local function round(var, n)
 | |
|         if (n) then
 | |
|             var = math.floor((var * 10 ^ n) + 0.5) / (10 ^ n)
 | |
|         else
 | |
|             var = math.floor(var + 0.5)
 | |
|         end
 | |
|         return var
 | |
|     end
 | |
|     local n = 2
 | |
|     if val < 1e3 then
 | |
|         return round(val, n)
 | |
|     elseif val > 1e3 and val < 1e6 then
 | |
|         return round(val / 1e3, n) .. "k"
 | |
|     elseif val > 1e6 and val < 1e9 then
 | |
|         return round(val / 1e6, n) .. "M"
 | |
|     elseif val > 1e9 then
 | |
|         return round(val / 1e9, n) .. "G"
 | |
|     end
 | |
| end
 |