Skip to content

Predefined Colors

Shadowfen edited this page Jul 30, 2026 · 1 revision

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}


Features

  • Ready-to-use SF_Color objects
  • Cached hexadecimal and RGB values
  • Consistent color naming
  • Suitable for chat messages, labels, and UI controls
  • Eliminates repeated color construction
  • Compatible with all SF_Color methods

Accessing Colors

The predefined colors are stored in:

local colors = LibSFUtils.colors

or

local SF = LibSFUtils

local colors = SF.colors

Each entry is an SF_Color instance.


Available Colors

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}


Examples

Colorize Chat Text

local SF = LibSFUtils

d(SF.colors.red("Danger!"))

Produces

|cFF0000Danger!|r

Set a Control's Color

local color = SF.colors.gold

control:SetColor(color:UnpackRGBA())

Clone a Predefined Color

local warning = SF.colors.red:Clone()

warning:SetAlpha(0.5)

The original predefined color is unchanged.


Convert to ZO_ColorDef

local zoColor = SF.colors.blue:ToZO_ColorDef()

Compare Colors

if currentColor:IsEqual(SF.colors.green) then
    d("Success")
end

Using SF_Color Methods

Because 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

Choosing Between Predefined and Custom Colors

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.

Performance Notes

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}


API Summary

Object Description
LibSFUtils.colors Table of predefined SF_Color objects

Each entry supports the complete SF_Color API documented in the Color Utilities section.


Implementation Notes

  • Every predefined color is an SF_Color instance.
  • 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.

Clone this wiki locally