diff --git a/TomTom_CrazyArrow.lua b/TomTom_CrazyArrow.lua
index b4a9925..0cc2b67 100644
--- a/TomTom_CrazyArrow.lua
+++ b/TomTom_CrazyArrow.lua
@@ -6,6 +6,74 @@
-- with the artwork.)
----------------------------------------------------------------------------]]
+local DongleUtils = {}
+
+do
+ function DongleUtils.RGBToHex(r, g, b)
+ return string.format("%02x%02x%02x", r, g, b)
+ end
+
+
+ function DongleUtils.RGBPercToHex(r, g, b)
+ return string.format("%02x%02x%02x", r*255, g*255, b*255)
+ end
+
+
+ function DongleUtils.HexToRGB(hex)
+ local rhex, ghex, bhex = string.sub(hex, 1, 2), string.sub(hex, 3, 4), string.sub(hex, 5, 6)
+ return tonumber(rhex, 16), tonumber(ghex, 16), tonumber(bhex, 16)
+ end
+
+
+ function DongleUtils.HexToRGBPerc(hex)
+ local rhex, ghex, bhex = string.sub(hex, 1, 2), string.sub(hex, 3, 4), string.sub(hex, 5, 6)
+ return tonumber(rhex, 16)/255, tonumber(ghex, 16)/255, tonumber(bhex, 16)/255
+ end
+
+
+ function DongleUtils.ColorGradient(perc, ...)
+ local num = select("#", ...)
+ local hexes = type(select(1, ...)) == "string"
+
+ if perc == 1 then
+ if hexes then return select(num, ...)
+ else return select(num-2, ...), select(num-1, ...), select(num, ...) end
+ end
+
+ if not hexes then num = num / 3 end
+
+ local segment, relperc = math.modf(perc*(num-1))
+ local r1, g1, b1, r2, g2, b2
+ if hexes then
+ r1, g1, b1 = DongleUtils.HexToRGBPerc(select(segment+1, ...))
+ r2, g2, b2 = DongleUtils.HexToRGBPerc(select(segment+2, ...))
+ else
+ r1, g1, b1 = select((segment*3)+1, ...), select((segment*3)+2, ...), select((segment*3)+3, ...)
+ r2, g2, b2 = select((segment*3)+4, ...), select((segment*3)+5, ...), select((segment*3)+6, ...)
+ end
+
+ if hexes then
+ return DongleUtils.RGBToHex(r1 + (r2-r1)*relperc,
+ g1 + (g2-g1)*relperc,
+ b1 + (b2-b1)*relperc)
+ else
+ return r1 + (r2-r1)*relperc,
+ g1 + (g2-g1)*relperc,
+ b1 + (b2-b1)*relperc
+ end
+ end
+
+
+ function DongleUtils.GetHPSeverity(perc, class)
+ if not class then return DongleUtils.ColorGradient(perc, 1,0,0, 1,1,0, 0,1,0)
+ else
+ local c = RAID_CLASS_COLORS[class]
+ return DongleUtils.ColorGradient(perc, 1,0,0, 1,1,0, c.r,c.g,c.b)
+ end
+ end
+
+end
+
local Astrolabe = DongleStub("Astrolabe-0.4")
local sformat = string.format
local GetPlayerBearing
@@ -132,6 +200,11 @@ local function OnUpdate(self, elapsed)
angle = angle - player
+ local perc = math.abs((math.pi - math.abs(angle)) / math.pi)
+
+ local r,g,b = DongleUtils.ColorGradient(perc, 1,0,0, 1,1,0, 0,1,0)
+ arrow:SetVertexColor(r,g,b)
+
cell = floor(angle / twopi * 108 + 0.5) % 108
local column = cell % 9
local row = floor(cell / 9)