-
Notifications
You must be signed in to change notification settings - Fork 0
Predefined Colors
LibSFUtils includes a collection of predefined SF_Color objects for commonly used colors.
These colors are created once when the library is loaded and are available through the LibSFUtils.colors table.
Using predefined colors avoids repeatedly creating SF_Color or ZO_ColorDef objects at runtime and provides consistent color definitions throughout your addon. :contentReference[oaicite:1]{index=1}
- Ready-to-use
SF_Colorobjects - Cached hexadecimal and RGB values
- Consistent color naming
- Suitable for chat messages, labels, and UI controls
- Eliminates repeated color construction
- Compatible with all
SF_Colormethods
The predefined colors are stored in:
local colors = LibSFUtils.colorsor
local SF = LibSFUtils
local colors = SF.colorsEach entry is an SF_Color instance.
| Name | Hex |
|---|---|
gold |
FFD700 |
red |
FF0000 |
teal |
00EFBB |
lime |
00E600 |
green |
2DC50E |
goldenrod |
EECA00 |
blue |
0000FF |
purple |
B000FF |
bronze |
FF9900 |
ltskyblue |
87CEFA |
lemon |
FFFACD |
mocassin |
FFE4B5 |
frangipani |
FAD7A0 |
aquamarine |
7FFFD4 |
lightsalmon |
FFA07A |
junk |
7F7F7F |
normal |
FFFFFF |
magic |
(magic-quality color) |
arcane |
(arcane-quality color) |
artifact |
(artifact-quality color) |
legendary |
(legendary-quality color) |
Note
The exact list may grow as additional commonly used colors are added in future versions of LibSFUtils. :contentReference[oaicite:2]{index=2}
local SF = LibSFUtils
d(SF.colors.red("Danger!"))Produces
|cFF0000Danger!|r
local color = SF.colors.gold
control:SetColor(color:UnpackRGBA())local warning = SF.colors.red:Clone()
warning:SetAlpha(0.5)The original predefined color is unchanged.
local zoColor = SF.colors.blue:ToZO_ColorDef()if currentColor:IsEqual(SF.colors.green) then
d("Success")
endBecause every predefined color is an SF_Color object, all SF_Color methods are available.
Examples include:
| Method | Description |
|---|---|
Colorize() |
Wrap text in ESO color tags |
ToHex() |
Return the hexadecimal string |
Clone() |
Create a copy |
IsEqual() |
Compare colors |
ToZO_ColorDef() |
Create a ZO_ColorDef
|
UnpackRGB() |
Return RGB values |
UnpackRGBA() |
Return RGBA values |
SetAlpha() |
Change transparency |
Use a predefined color when:
- The color is used frequently.
- The color has a well-known meaning.
- Multiple parts of your addon should use the same appearance.
Create a custom SF_Color when:
- The color is dynamic.
- The color is user-configurable.
- The color is generated at runtime.
Every predefined color is instantiated once when LibSFUtils loads.
Using these shared objects avoids repeatedly converting hexadecimal strings, RGB values, or creating temporary ZO_ColorDef objects during normal addon execution. This can reduce allocation and conversion overhead in code that performs frequent UI updates or chat output. :contentReference[oaicite:3]{index=3}
| Object | Description |
|---|---|
LibSFUtils.colors |
Table of predefined SF_Color objects |
Each entry supports the complete SF_Color API documented in the Color Utilities section.
- Every predefined color is an
SF_Colorinstance. - Colors are created once during library initialization.
- Color objects are intended to be reused rather than recreated.
- If you need to modify a predefined color, call
Clone()first to avoid changing the shared instance.