ColorMixin
Defined in FrameXML/Util.lua
, the ColorMixin interface represents a color with red, green, blue and optional alpha.
Construction
- CreateColor(r, g, b [, a]) - Creates a new color with three or four values between 0 and 1.
- CreateColorFromHexString(hexColor) - Creates a new color from a string of eight hexademical characters as AARRGGBB.
- CreateColorFromBytes(r, g, b, a) - Creates a new color with four values between 0 and 255.
Methods
- Fundamental
- ColorMixin:GetRGB() - Returns three values between 0 and 1.
- ColorMixin:GetRGBA() - Returns three or four values between 0 and 1.
- ColorMixin:GetRGBAsBytes() - Returns three values between 0 and 255.
- ColorMixin:GetRGBAAsBytes() - Returns four values between 0 and 255.
- ColorMixin:SetRGB(r, g, b) - Changes the color using new values between 0 and 1, while setting alpha to nil.
- ColorMixin:SetRGBA(r, g, b [,a ]) - Changes the color and alpha using new values between 0 and 1.
- String output
- ColorMixin:GenerateHexColor() - Returns
ff
followed by six hexadecimal characters representing the color (ignoring alpha). - ColorMixin:GenerateHexColorMarkup() - Returns an escape sequence usable in front of text to set its color (ignoring alpha).
- ColorMixin:WrapTextInColorCode(text) - Wraps the text with
|cAARRGGBB
and|r
escape sequences (ignoring alpha).
- Calculation
- ColorMixin:IsEqualTo(otherColor) - Indicates if two colors have equal red, green, blue and alpha components.
Example
local color = CreateColor(1, 1, 0)
print("Did someone say " .. color:WrapTextInColorCode("yellow") .. "?") -- Did someone say yellow?
Patch changes
Patch 8.1.0 (2018-12-11): Added CreateColorFromHexString() and CreateColorFromBytes().[1]
Patch 8.0.1 (2018-07-17): Added GenerateHexColorMarkup().[2]
Patch 7.0.3 (2016-07-19): Added.[3]
See also
- GetClassColor(classFilename)
External Links
Globe "wut?" Tool, Townlong-Yak
GitHub FrameXML, Gethe
References
- ^ 2018-12-07, Util.lua, version 8.1.0.28724, near line 628, archived at Townlong-Yak
- ^ 2018-07-16, Util.lua, version 8.0.1.27101, near line 646, archived at Townlong-Yak
- ^ 2016-07-19, Util.lua, version 7.0.3.22267, near line 621, archived at Townlong-Yak