- color array
- rgb to hexcolor
- dump table
This commit is contained in:
Sumsebrum 2022-08-17 14:24:09 +02:00
parent afd5647807
commit 8b766c23d2

View File

@ -2,7 +2,8 @@ local pairs, ipairs = pairs, ipairs
local select = select
local type = type
local floor = math.floor
local str_find, str_gsub, str_sub, tinsert = string.find, string.gsub, string.sub, table.insert
local str_find, str_gsub, str_sub, str_format = string.find, string.gsub, string.sub, string.format
local tinsert = table.insert
local Gladdy = LibStub("Gladdy")
local L = Gladdy.L
local AuraUtil = AuraUtil
@ -229,3 +230,32 @@ function Gladdy:GetExceptionSpellName(spellID)
end
return select(1, GetSpellInfo(spellID))
end
local function toHex(color)
if not color or not color.r or not color.g or not color.b then
return "000000"
end
return str_format("%.2x%.2x%.2x", floor(color.r * 255), floor(color.g * 255), floor(color.b * 255))
end
function Gladdy:SetTextColor(text, color)
return "|cff" .. toHex(color) .. text or "" .. "|r"
end
function Gladdy:ColorAsArray(color)
return {color.r, color.g, color.b, color.a}
end
function Gladdy:Dump(table, space)
if type(table) ~= "table" then
return
end
if not space then
space = ""
end
for k,v in pairs(table) do
Gladdy:Print(space .. k .. " - ", v)
if type(v) == "table" then
Gladdy:Dump(v, space .. " ")
end
end
end