Provides functionality for giving meaningful names to colors and applying those colors to pieces of text. TweakerColorizer objects can inherit from other TweakerColorizer objects and access their colors. The base TweakerColorizer object defines many standard colors.
Instantiates a new TweakerColorizer object.
TweakerColorizer:new([colors])
local colorizer = TweakerColorizer:new({
cooldude = "8080af",
coolchick = "af8080",
})
local new_colorizer = colorizer:new({
lamedude = "afaf80",
lamechick = "80afaf",
})
Receives the name of a color and returns its hexadecimal representation. Parent classes are searched recursively until a match is found, or else returns nil.
TweakerColorizer:GetColor(name)
local colorizer = TweakerColorizer:new()
colorizer:GetColor("red") -- returns "ff0000"
local blues = TweakerColorizer:new({
blue1 = "000033",
blue2 = "000066",
blue3 = "000099",
})
local blues_and_purples = blues:new({
purple1 = "330033",
purple2 = "660066",
purple3 = "990099",
})
blues_and_purples:GetColor("red") -- returns "ff0000"
blues_and_purples:GetColor("blue2") -- returns "000066"
blues_and_purples:GetColor("cardboard") -- returns nil
Works like GetColor but accepts multiple names and returns a color for each name. Values are returned in the same order and manner in which the names are supplied. If no names are supplied, all colors are returned in a hash table of name/color pairs.
TweakerColorizer:GetColors()
-- or --
TweakerColorizer:GetColors(names)
-- or --
TweakerColorizer:GetColors(name1[, name2[, name3[, ...]]])
local a = TweakerColorizer:new()
local b = a:new({skyblue = "87ceeb"})
local c = b:new({powderblue = "b0e0e6"})
local colors = c:GetColors() -- returns { powderblue = "b0e0e6", skyblue = "87ceeb", ... } where the ellipsis represents all colors defined by the base TweakerColorizer class
local a = TweakerColorizer:new()
local colors = a:GetColors(["red", "green", "blue"]) -- returns { red = "ff0000", green = "00ff00", blue = "0000ff" }
local a = TweakerColorizer:new()
local red, green, blue = a:GetColors("red", "green", "blue") -- returns "ff0000", "00ff00", "0000ff"
Returns all the colors custom defined by the colorizer. Unlike GetColor and GetColors, does not include colors defined by any parents of the colorizer.
TweakerColorizer:GetCustomColors()
local a = TweakerColorizer:new({skyblue = "87ceeb", powderblue = "b0e0e6"})
local custom_colors = a:GetCustomColors() -- returns { skyblue = "87ceeb", powderblue = "b0e0e6" }
Defines a new color for the colorizer, using the given name.
TweakerColorizer:SetColor(name, color)
local colorizer = TweakerColorizer:new()
colorizer:SetColor("sky blue", "87ceeb")
Defines new colors for the colorizer
TweakerColorizer:SetColors(colors)
local colorizer = TweakerColorizer:new()
colorizer:SetColors({ ["sky blue"] = "87ceeb", ["powder blue"] = "b0e0e6" })
Converts rgb values to a hex string appropriate for storage in a colorizer
TweakerColorizer:ToHexString(r,g,b)
local colorizer = TweakerColorizer:new()
colorizer:SetColor("sky blue", colorizer:ToHexString(135, 206, 235))
Converts a hexadecimal number to a decimal number
TweakerColorizer:ToDecimal(hex)
local colorizer = TweakerColorizer:new()
colorizer:ToDecimal("87ceeb") -- returns 8900331
Applies a color to a string of text. The text supports string.format functionality.
TweakerColorizer:Apply(name, text, ...)
local colorizer = TweakerColorizer:new()
function print_error(msg)
DEFAULT_CHAT_FRAME:AddMessage(colorizer:Apply("red", "An error has occured: %s", msg))
end
Performs string.format then applies the specified color to the parts of the result that match the regex
TweakerColorizer:RegexApply(name, regex, text, ...)
local colorizer = TweakerColorizer:new()
local argument_list = "arg1[, arg2[, arg3[, ...[, argN]]]]"
argument_list = colorizer:RegexApply("blue", "[^\[\] ,\.]+", argument_list)