forked from oUF-wow/oUF
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcolors.lua
74 lines (61 loc) · 1.64 KB
/
colors.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
local parent, ns = ...
local oUF = ns.oUF
local Private = oUF.Private
local frame_metatable = Private.frame_metatable
local colors = {
smooth = {
1, 0, 0,
1, 1, 0,
0, 1, 0
},
disconnected = {.6, .6, .6},
tapped = {.6,.6,.6},
class = {},
reaction = {},
}
-- We do this because people edit the vars directly, and changing the default
-- globals makes SPICE FLOW!
if(IsAddOnLoaded'!ClassColors' and CUSTOM_CLASS_COLORS) then
local updateColors = function()
for eclass, color in next, CUSTOM_CLASS_COLORS do
colors.class[eclass] = {color.r, color.g, color.b}
end
for _, obj in next, oUF.objects do
obj:UpdateAllElements("CUSTOM_CLASS_COLORS")
end
end
updateColors()
CUSTOM_CLASS_COLORS:RegisterCallback(updateColors)
else
for eclass, color in next, RAID_CLASS_COLORS do
colors.class[eclass] = {color.r, color.g, color.b}
end
end
for eclass, color in next, FACTION_BAR_COLORS do
colors.reaction[eclass] = {color.r, color.g, color.b}
end
-- http://www.wowwiki.com/ColorGradient
local ColorGradient = function(a, b, ...)
local perc
if(b == 0) then
perc = 0
else
perc = a / b
end
if perc >= 1 then
local r, g, b = select(select('#', ...) - 2, ...)
return r, g, b
elseif perc <= 0 then
local r, g, b = ...
return r, g, b
end
local num = select('#', ...) / 3
local segment, relperc = math.modf(perc*(num-1))
local r1, g1, b1, r2, g2, b2 = select((segment*3)+1, ...)
return r1 + (r2-r1)*relperc, g1 + (g2-g1)*relperc, b1 + (b2-b1)*relperc
end
Private.colors = colors
oUF.colors = colors
oUF.ColorGradient = ColorGradient
frame_metatable.__index.colors = colors
frame_metatable.__index.ColorGradient = ColorGradient