Revert "update oUF colors"

This reverts commit 80776fc058.
This commit is contained in:
Crum
2018-07-11 15:59:43 -05:00
parent 0a5d848f60
commit b6a1c95320
+36 -40
View File
@@ -2,11 +2,6 @@ local ns = oUF
local oUF = ns.oUF local oUF = ns.oUF
local Private = oUF.Private local Private = oUF.Private
local select, unpack = select, unpack
local abs, mod, modf = math.abs, math.mod, math.modf
local CreateFrame = CreateFrame
local frame_metatable = Private.frame_metatable local frame_metatable = Private.frame_metatable
local colors = { local colors = {
@@ -26,14 +21,14 @@ local colors = {
-- We do this because people edit the vars directly, and changing the default -- We do this because people edit the vars directly, and changing the default
-- globals makes SPICE FLOW! -- globals makes SPICE FLOW!
local function customClassColors() local function customClassColors()
if CUSTOM_CLASS_COLORS then if(CUSTOM_CLASS_COLORS) then
local function updateColors() local function updateColors()
for classToken, color in next, CUSTOM_CLASS_COLORS do for classToken, color in next, CUSTOM_CLASS_COLORS do
colors.class[classToken] = {color.r, color.g, color.b} colors.class[classToken] = {color.r, color.g, color.b}
end end
for _, obj in next, oUF.objects do for _, obj in next, oUF.objects do
obj:UpdateAllElements("CUSTOM_CLASS_COLORS") obj:UpdateAllElements('CUSTOM_CLASS_COLORS')
end end
end end
@@ -44,17 +39,17 @@ local function customClassColors()
end end
end end
if not customClassColors() then if(not customClassColors()) then
for classToken, color in next, RAID_CLASS_COLORS do for classToken, color in next, RAID_CLASS_COLORS do
colors.class[classToken] = {color.r, color.g, color.b} colors.class[classToken] = {color.r, color.g, color.b}
end end
local eventHandler = CreateFrame("Frame") local eventHandler = CreateFrame('Frame')
eventHandler:RegisterEvent("ADDON_LOADED") eventHandler:RegisterEvent('ADDON_LOADED')
eventHandler:SetScript("OnEvent", function() eventHandler:SetScript('OnEvent', function()
if customClassColors() then if(customClassColors()) then
this:UnregisterEvent("ADDON_LOADED") this:UnregisterEvent('ADDON_LOADED')
this:SetScript("OnEvent", nil) this:SetScript('OnEvent', nil)
end end
end) end)
end end
@@ -71,14 +66,14 @@ colors.power[3] = {1.00, 1.00, 0.00}
colors.power[4] = {0.00, 1.00, 1.00} colors.power[4] = {0.00, 1.00, 1.00}
local function colorsAndPercent(a, b, ...) local function colorsAndPercent(a, b, ...)
if a <= 0 or b == 0 then if(a <= 0 or b == 0) then
return nil, unpack(arg) return nil, unpack(arg)
elseif a >= b then elseif(a >= b) then
return nil, select(arg.n - 2, unpack(arg)) return nil, select(select('#', unpack(arg)) - 2, unpack(arg))
end end
local num = arg.n / 3 local num = select('#', unpack(arg)) / 3
local segment, relperc = modf((a / b) * (num - 1)) local segment, relperc = math.modf((a / b) * (num - 1))
return relperc, select((segment * 3) + 1, unpack(arg)) return relperc, select((segment * 3) + 1, unpack(arg))
end end
@@ -97,7 +92,7 @@ last 3 RGB values are returned.
--]] --]]
local function RGBColorGradient(...) local function RGBColorGradient(...)
local relperc, r1, g1, b1, r2, g2, b2 = colorsAndPercent(unpack(arg)) local relperc, r1, g1, b1, r2, g2, b2 = colorsAndPercent(unpack(arg))
if relperc then if(relperc) then
return r1 + (r2 - r1) * relperc, g1 + (g2 - g1) * relperc, b1 + (b2 - b1) * relperc return r1 + (r2 - r1) * relperc, g1 + (g2 - g1) * relperc, b1 + (b2 - b1) * relperc
else else
return r1, g1, b1 return r1, g1, b1
@@ -121,12 +116,12 @@ function oUF:RGBToHCY(r, g, b)
local min, max = min(r, g, b), max(r, g, b) local min, max = min(r, g, b), max(r, g, b)
local chroma = max - min local chroma = max - min
local hue local hue
if chroma > 0 then if(chroma > 0) then
if r == max then if(r == max) then
hue = mod((g - b) / chroma, 6) hue = math.mod((g - b) / chroma, 6)
elseif g == max then elseif(g == max) then
hue = (b - r) / chroma + 2 hue = (b - r) / chroma + 2
elseif b == max then elseif(b == max) then
hue = (r - g) / chroma + 4 hue = (r - g) / chroma + 4
end end
hue = hue / 6 hue = hue / 6
@@ -134,6 +129,7 @@ function oUF:RGBToHCY(r, g, b)
return hue, chroma, getY(r, g, b) return hue, chroma, getY(r, g, b)
end end
local math_abs = math.abs
--[[ Colors: oUF:HCYtoRGB(hue, chroma, luma) --[[ Colors: oUF:HCYtoRGB(hue, chroma, luma)
Used to convert a color from HCY to RGB color space. Used to convert a color from HCY to RGB color space.
@@ -144,27 +140,27 @@ Used to convert a color from HCY to RGB color space.
--]] --]]
function oUF:HCYtoRGB(hue, chroma, luma) function oUF:HCYtoRGB(hue, chroma, luma)
local r, g, b = 0, 0, 0 local r, g, b = 0, 0, 0
if hue and luma > 0 then if(hue and luma > 0) then
local h2 = hue * 6 local h2 = hue * 6
local x = chroma * (1 - abs(mod(h2, 2 - 1))) local x = chroma * (1 - math_abs(math.mod(h2, 2 - 1)))
if h2 < 1 then if(h2 < 1) then
r, g, b = chroma, x, 0 r, g, b = chroma, x, 0
elseif h2 < 2 then elseif(h2 < 2) then
r, g, b = x, chroma, 0 r, g, b = x, chroma, 0
elseif h2 < 3 then elseif(h2 < 3) then
r, g, b = 0, chroma, x r, g, b = 0, chroma, x
elseif h2 < 4 then elseif(h2 < 4) then
r, g, b = 0, x, chroma r, g, b = 0, x, chroma
elseif h2 < 5 then elseif(h2 < 5) then
r, g, b = x, 0, chroma r, g, b = x, 0, chroma
else else
r, g, b = chroma, 0, x r, g, b = chroma, 0, x
end end
local y = getY(r, g, b) local y = getY(r, g, b)
if luma < y then if(luma < y) then
chroma = chroma * (luma / y) chroma = chroma * (luma / y)
elseif y < 1 then elseif(y < 1) then
chroma = chroma * (1 - luma) / (1 - y) chroma = chroma * (1 - luma) / (1 - y)
end end
@@ -189,7 +185,7 @@ last 3 HCY values are returned.
--]] --]]
local function HCYColorGradient(...) local function HCYColorGradient(...)
local relperc, r1, g1, b1, r2, g2, b2 = colorsAndPercent(unpack(arg)) local relperc, r1, g1, b1, r2, g2, b2 = colorsAndPercent(unpack(arg))
if not relperc then if(not relperc) then
return r1, g1, b1 return r1, g1, b1
end end
@@ -198,15 +194,15 @@ local function HCYColorGradient(...)
local c = c1 + (c2 - c1) * relperc local c = c1 + (c2 - c1) * relperc
local y = y1 + (y2 - y1) * relperc local y = y1 + (y2 - y1) * relperc
if h1 and h2 then if(h1 and h2) then
local dh = h2 - h1 local dh = h2 - h1
if dh < -0.5 then if(dh < -0.5) then
dh = dh + 1 dh = dh + 1
elseif dh > 0.5 then elseif(dh > 0.5) then
dh = dh - 1 dh = dh - 1
end end
return self:HCYtoRGB(mod(h1 + dh * relperc, 1), c, y) return self:HCYtoRGB(math.mod(h1 + dh * relperc, 1), c, y)
else else
return self:HCYtoRGB(h1 or h2, c, y) return self:HCYtoRGB(h1 or h2, c, y)
end end
@@ -214,7 +210,7 @@ local function HCYColorGradient(...)
end end
--[[ Colors: oUF:ColorGradient(a, b, ...) or frame:ColorGradient(a, b, ...) --[[ Colors: oUF:ColorGradient(a, b, ...) or frame:ColorGradient(a, b, ...)
Used as a proxy to call the proper gradient function depending on the user"s preference. If `oUF.useHCYColorGradient` is Used as a proxy to call the proper gradient function depending on the user's preference. If `oUF.useHCYColorGradient` is
set to true, `:HCYColorGradient` will be called, else `:RGBColorGradient`. set to true, `:HCYColorGradient` will be called, else `:RGBColorGradient`.
* self - the global oUF object or a unit frame * self - the global oUF object or a unit frame