API GetItemQualityColor

From Wowpedia
Jump to: navigation, search

Returns RGB color codes for an item quality.

r, g, b, hex = GetItemQualityColor(quality)


Number - The numeric ID of the quality from 0 (Poor) to 7 (Heirloom).


Number - The Red component of the color (0 to 1, inclusive).
Number - The Green component of the color (0 to 1, inclusive).
Number - The Blue component of the color (0 to 1, inclusive).
String - The UI escape sequence for this color, without the leading "|c".


for i = 0, 7 do
  local r, g, b, hex = GetItemQualityColor(i)
  print(i, '|c'..hex, _G["ITEM_QUALITY" .. i .. "_DESC"], string.sub(hex,3))


Will print all qualities, in their individual colors. If you are doing this via /script in-game, you will need to type "\124" instead of a "|".

0 Poor 9d9d9d
1 Common ffffff
2 Uncommon 1eff00
3 Rare 0070dd
4 Epic a335ee
5 Legendary ff8000
6 Artifact e6cc80
7 Heirloom e6cc80


It is recommended to use the global ITEM_QUALITY_COLORS array instead of repeatedly calling this function.
If an invalid quality index is specified, GetItemQualityColor() returns white (same as index 1):
r = 1
g = 1
b = 1
hex = |cffffffff
The hex string included the leading "|c" until 4.2 when it was removed. If you use ITEM_QUALITY_COLORS instead, the ".hex" field will include the leading escape sequence.
GetItemQualityColor() was added in 1.9.1.

See also