WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Gradients in LUA (https://www.wowinterface.com/forums/showthread.php?t=39707)

Lordyfrb 04-19-11 05:35 PM

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?

Monolit 04-19-11 06:16 PM

Quote:

Originally Posted by Lordyfrb (Post 235024)
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)

Xubera 04-26-11 04:16 AM

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.


All times are GMT -6. The time now is 04:48 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI