Quantcast
Gradients in LUA - WoWInterface
Thread Tools Display Modes
04-19-11, 05:35 PM   #1
Lordyfrb
A Cliff Giant
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 71
Gradients in LUA

Hey guys, just wondering how to create gradients using LUA.

For example, I have a panel created using CreateFrame(), how can I make this panel fade from one side to another?
__________________
  Reply With Quote
04-19-11, 06:16 PM   #2
Monolit
A Black Drake
AddOn Author - Click to view addons
Join Date: Jan 2006
Posts: 81
Originally Posted by Lordyfrb View Post
Hey guys, just wondering how to create gradients using LUA.

For example, I have a panel created using CreateFrame(), how can I make this panel fade from one side to another?
short answer:
SetGradientAlpha()

so in a nutshell, you just have to create a texture for your frame and then apply SetGradientAlpha method to it.
e.g.
local f = CreateFrame"Frame"
f.t = f:CreateTexture(nil, "PARENT")
f.t = SetTexture(some_texture or 1,1,1,1)
f.t:SetAllPoints(f)
f.t:SetGradientAlpha("HORIZONTAL", 0,0,0,1, 0,0,0,0)
f:SetWidth(some_width_value)
f:SetHeight(some_height_value)
  Reply With Quote
04-26-11, 04:16 AM   #3
Xubera
A Cobalt Mageweaver
 
Xubera's Avatar
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 207
I use this


Code:
local frame = CreateFrame("Button")

--[[frame definitions here]]--

frame.leftGrad = frame:CreateTexture(nil, "BORDER")
frame.leftGrad:SetWidth(16)
frame.leftGrad:SetHeight(14)
frame.leftGrad:SetPoint("LEFT", 0, -5)
frame.leftGrad:SetTexture(1,0,0,1)
frame.leftGrad:SetGradientAlpha("Horizontal", 0, 0, 0, 0.2, 0, 0, 0, 1)

frame.rightGrad = frame:CreateTexture(nil, "BORDER")
frame.rightGrad:SetWidth(16)
frame.rightGrad:SetHeight(14)
frame.rightGrad:SetPoint("RIGHT", 0, -5)
frame.rightGrad:SetTexture(0,1,0,1)
frame.rightGrad:SetGradientAlpha("Horizontal", 0, 0, 0, 1, 0, 0, 0, 0.2)
this makes a 32x14 black gradient that starts from transparent to solid to transparent.
__________________
Chat Consolidate is the solution to any out of control trade chat. Ignore lines, throttle chat, consolidate posts!Follow the link to find out how!

▲ ▲ WoWInterface wont let me triforce >.>
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Gradients in LUA

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