WoW:API GetItemQualityColor: Difference between revisions

From AddOn Studio
Jump to navigation Jump to search
No edit summary
 
m (Move page script moved page API GetItemQualityColor to API GetItemQualityColor without leaving a redirect)
 
(12 intermediate revisions by 11 users not shown)
Line 1: Line 1:
<center>'''GetItemQualityColor''' ''-Documentation by Maldivia-''</center>
{{wowapi}}__NOTOC__


Returns RGB color codes for an item quality.
Returns RGB color codes for an item [[quality]].


  r, g, b, hex = GetItemQualityColor(quality)
  r, g, b, hex = GetItemQualityColor(quality)
== Parameters ==
== Arguments ==
=== Arguments ===
* quality (number) - The numeric ID of the quality from 0 (Poor) to 7 (Heirloom).
:quality


:;quality : Integer - The numeric ID of the quality from 0 (Poor) to 6 (Artifact).
== Returns ==
* r (number) - The Red component of the color (0 to 1, inclusive).
* g (number) - The Green component of the color (0 to 1, inclusive).
* b (number) - The Blue component of the color (0 to 1, inclusive).
* hex (string) - The 4 character hex [[UI escape sequences|UI escape sequence]] for this color


=== Returns ===
== Example ==
:r, g, b, hex
for i = 0, 8 do
  local r, g, b, hex = GetItemQualityColor(i)
  print(i, hex, _G["ITEM_QUALITY" .. i .. "_DESC"], hex:sub(5))
end


:;r : Float - The Red component of the color
=== Result ===
:;g : Float - The Green component of the color
: Will print all qualities, in their individual colors (example result from version 6.2.4).
:;b : Float - The Blue component of the color
0 <span style="color: #9d9d9d">Poor ff9d9d9d</span>
:;hex : String - Contains the hexidecimal representation of the string, as well as "|c" in the beginning.
1 <span style="color: #ffffff">Common ffffffff</span>
2 <span style="color: #1eff00">Uncommon ff1eff00</span>
3 <span style="color: #0070dd">Rare ff0070dd</span>
4 <span style="color: #a335ee">Epic ffa335ee</span>
5 <span style="color: #ff8000">Legendary ffff8000</span>
6 <span style="color: #e6cc80">Artifact ffe6cc80</span>
7 <span style="color: #e6cc80">Heirloom ffe6cc80</span>
8 <span style="color: #00ccff">WoW Token ff00ccff</span>


== Example ==
== Details ==
for i = 0, 6 do
: GetItemQualityColor() was added in 1.9.1
  local r, g, b, hex = GetItemQualityColor(i);
 
  DEFAULT_CHAT_FRAME:AddMessage(getglobal("ITEM_QUALITY" .. i .. "_DESC"), r, g, b);
:If an invalid quality index is specified, GetItemQualityColor() returns white (same as index 1):
end
::r = 1
::g = 1
::b = 1
::hex = |cffffffff


====Result====
== Changes ==
: Will write all qualities to the default chat frame, in their individual colors.
* Quality 7 was added in version [[Patch 3.0]] for heirloom items
* ITEM_QUALITY7_DESC is now defined as of [[Patch 3.1.1]]
* [[Patch 6.1.2]] introduced quality 8, WoW Token.
* [[Patch 7.0.3]] changed the Heirloom color from <span style="color: #e6cc80">Heirloom ffe6cc80</span> to <span style="color: #00ccff">Heirloom ff00ccff</span>. This was likely done to avoid confusion with <span style="color: #e6cc80">Artifact ffe6cc80.</span>


==Details==
== See also ==
: Added in 1.9.1
* [[API ITEM_QUALITY_COLORS]]
__NOTOC__
* [[API TYPE Quality|API TYPE Qualit]]y
{{Template:WoW API}}

Latest revision as of 04:46, 15 August 2023

WoW API < GetItemQualityColor

Returns RGB color codes for an item quality.

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

Arguments[edit]

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

Returns[edit]

  • r (number) - The Red component of the color (0 to 1, inclusive).
  • g (number) - The Green component of the color (0 to 1, inclusive).
  • b (number) - The Blue component of the color (0 to 1, inclusive).
  • hex (string) - The 4 character hex UI escape sequence for this color

Example[edit]

for i = 0, 8 do
  local r, g, b, hex = GetItemQualityColor(i)
  print(i, hex, _G["ITEM_QUALITY" .. i .. "_DESC"], hex:sub(5))
end

Result[edit]

Will print all qualities, in their individual colors (example result from version 6.2.4).
0 Poor ff9d9d9d
1 Common ffffffff
2 Uncommon ff1eff00
3 Rare ff0070dd
4 Epic ffa335ee
5 Legendary ffff8000
6 Artifact ffe6cc80
7 Heirloom ffe6cc80
8 WoW Token ff00ccff

Details[edit]

GetItemQualityColor() was added in 1.9.1
If an invalid quality index is specified, GetItemQualityColor() returns white (same as index 1):
r = 1
g = 1
b = 1
hex = |cffffffff

Changes[edit]

  • Quality 7 was added in version Patch 3.0 for heirloom items
  • ITEM_QUALITY7_DESC is now defined as of Patch 3.1.1
  • Patch 6.1.2 introduced quality 8, WoW Token.
  • Patch 7.0.3 changed the Heirloom color from Heirloom ffe6cc80 to Heirloom ff00ccff. This was likely done to avoid confusion with Artifact ffe6cc80.

See also[edit]