Thread Tools Display Modes
01-30-11, 02:01 PM   #1
KepiGio
A Defias Bandit
 
KepiGio's Avatar
AddOn Compiler - Click to view compilations
Join Date: Nov 2009
Posts: 2
KGPanels Color by Class Switch ..

Ok tbh i have no idea how to script anything. My main thing i want is to be able to color the background for certain frames by class color have it change on any class you play.

What specific script should i be searching for?

Code:
local _, class = UnitClass("player");
	if class == "WARRIOR" then
        self.bg:SetVertexColor(0.95, 0.23, 0.23, self.bg:GetAlpha())
	elseif class == "PRIEST" then
        self.bg:SetVertexColor(1, 0.96, 0.98, self.bg:GetAlpha())
	elseif class == "MAGE" then
        self.bg:SetVertexColor(0.00, 1, 1, self.bg:GetAlpha())
	elseif class == "DRUID" then
        self.bg:SetVertexColor(1, 0.49, 0.04, self.bg:GetAlpha())
	elseif class == "PALADIN" then
        self.bg:SetVertexColor(0.92, 0.22, 0.46, self.bg:GetAlpha())
	elseif class == "HUNTER" then
        self.bg:SetVertexColor(0.33, 0.86, 0.00, self.bg:GetAlpha())
	elseif class == "ROGUE" then
        self.bg:SetVertexColor(1, 0.94, 0.16, self.bg:GetAlpha())
	elseif class == "SHAMAN" then
        self.bg:SetVertexColor(0.13, 0.42, 1, self.bg:GetAlpha())
	elseif class == "WARLOCK" then
        self.bg:SetVertexColor(0.36, 0.18, 1, self.bg:GetAlpha())
	end
I did find this code laying around here in the forums but the colors are all wrong from what i have in pitbull .. how do i get the color codes to be the exact ones from pitbull?

my colors in pitbull are in the following setting:
DK - c31d3a
Mage - 3ccbf0
Rogue - fff566
Warrior - c79c6d
Druid - ff7e0d
Paladin - f587b7
Shaman -208ade
Hunters - acd375
Priests - b2ebff
Warlocks - 9383c9

Last edited by KepiGio : 01-30-11 at 02:10 PM.
  Reply With Quote
01-30-11, 02:17 PM   #2
Waky
A Cobalt Mageweaver
 
Waky's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2010
Posts: 200
PitBull is using Hexadecimal color values which cannot be used as VertexColor's. You can go to WoWWiki(I know everyone uses WoWPedia but I haven't updated my bookmarks yet.) for the hexadecimal and RGB values of each class.

Ex.
Mage color hexadecimal = #69CCF0
Mage color RGB (in this case) = 0.41, 0.80, 0.94

EDIT: If you're looking for a hexadecimal to RGB color converter go here. The only problem is it gives you the full value (255) SetVertexColor needs a value between 0 and 1, so in order to obtain this just take the number it gives you and divide by 255.

If I put in "ff8844" into the converted I'd get back [R:255] [G:136] [B:68] then to put this into SetVertexColor just open up Calculator and do [255/255 = 1] [136/255 = 0.53] [68/255 = 0.27]
Then plug these in [self.bg:SetVertexColor(1, 0.53, 0.27, self.bg:GetAlpha())]

Last edited by Waky : 01-30-11 at 02:24 PM.
  Reply With Quote
01-30-11, 02:23 PM   #3
KepiGio
A Defias Bandit
 
KepiGio's Avatar
AddOn Compiler - Click to view compilations
Join Date: Nov 2009
Posts: 2
Originally Posted by Waky View Post
PitBull is using Hexadecimal color values which cannot be used as VertexColor's. You can go to WoWWiki(I know everyone uses WoWPedia but I haven't updated my bookmarks yet.) for the hexadecimal and RGB values of each class.

Ex.
Mage color hexadecimal = #69CCF0
Mage color RGB (in this case) = 0.41, 0.80, 0.94
hmm thanks for the info .. quick question if i want to add Death Knight to that list do i add the name like DeathKnight or Death Knight?

Hmm seems like it uses the RGB a different RGB color code than the ones i converted my hex into ... is there a way i can use the RGB codes i just got and convert them into the 0.00 format?

For instance these are the RGB Color Codes i got through a Hex to RGB Converter:

WARRIOR - 199,156,109
PRIEST - 178,235,255
MAGE - 60,203,240
DRUID - 255,126,13
PALADIN - 245,135,183
HUNTER - 172,211,117
ROGUE - 255,245,102
SHAMAN - 32,138,222
WARLOCK - 147,131,201
DeathKnight - 195,29,58

Last edited by KepiGio : 01-30-11 at 02:36 PM.
  Reply With Quote
01-30-11, 02:31 PM   #4
Nibelheim
local roygbi-
 
Nibelheim's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 1,600
Should work in OnLoad if it's just the player's class you're retrieving.

Code:
local _, Class = UnitClass("player")
local Color = RAID_CLASS_COLORS[Class]
self.bg:SetVertexColor(Color.r, Color.g, Color.b, self.bg:GetAlpha())
  Reply With Quote
03-14-14, 06:30 AM   #5
Tntdruid
Premium Member
 
Tntdruid's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Jan 2005
Posts: 55
Can you do that whit border color too?
  Reply With Quote
03-14-14, 04:16 PM   #6
Be3f.
A Theradrim Guardian
 
Be3f.'s Avatar
Join Date: Jan 2011
Posts: 65
Replacing "self.bg:SetVertexColor" with "self:SetBackdropBorderColor" should work.
__________________
-- Be3f.

Last edited by Be3f. : 03-14-14 at 04:22 PM.
  Reply With Quote
03-14-14, 04:32 PM   #7
Tntdruid
Premium Member
 
Tntdruid's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Jan 2005
Posts: 55
Originally Posted by Be3f. View Post
Replacing "self.bg:SetVertexColor" with "self:SetBackdropBorderColor" should work.

Thanks

Now i can use one layout for all alts.
  Reply With Quote
03-15-14, 02:50 AM   #8
Tntdruid
Premium Member
 
Tntdruid's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Jan 2005
Posts: 55
The code if someone else need it
local _, Class = UnitClass("player")
local Color = RAID_CLASS_COLORS[Class]
self:SetBackdropBorderColor(Color.r, Color.g, Color.b,)
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » KGPanels Color by Class Switch ..

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off