Quantcast
gradient - WoWInterface
Thread Tools Display Modes
05-24-10, 12:03 AM   #1
mankeluvsit
An Onyxian Warder
 
mankeluvsit's Avatar
Join Date: Sep 2008
Posts: 354
gradient

having problems adding a gradient.
here is my code
Code:
llmodel:SetAlpha(1)
	llmodel:SetPoint("TOPLEFT", 15, -30)
	llmodel:SetPoint("TOPRIGHT", -15, -30)
	llmodel:SetHeight(12)
	llmodel:SetBackdrop({
				bgFile = "Interface\\AddOns\\!media\\bg", tile = true, tileSize = 46})
	llmodel:SetBackdropColor(0.2, 0.2, 0.2, 0.68)
and here is what im trying to do
Code:
llmodel:SetAlpha(1)
	llmodel:SetPoint("TOPLEFT", 15, -30)
	llmodel:SetPoint("TOPRIGHT", -15, -30)
	llmodel:SetHeight(12)
	llmodel:SetBackdrop({
				bgFile = "Interface\\AddOns\\!media\\bg", tile = true, tileSize = 46})
	llmodel:SetBackdropColor(0.2, 0.2, 0.2, 0.68)
        llmodel:SetGradientAlpha("VERTICAL",0,0,0,0,0,0,0,.6)
	llmodel:SetBlendMode("BLEND")
when i put the gradient inside, it messes everything up.


am i missing something i dont see?
  Reply With Quote
05-24-10, 12:37 AM   #2
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,638
I've not used Gradients myself but I did notice there are two functions... perhaps you need to use the other one ?



http://wowprogramming.com/docs/widge...re/SetGradient
•Texture:SetGradient("orientation", startR, startG, startB, endR, endG, endB) - Sets a gradient color shading for the texture

http://wowprogramming.com/docs/widge...tGradientAlpha
•Texture:SetGradientAlpha("orientation", startR, startG, startB, startAlpha, endR, endG, endB, endAlpha) - Sets a gradient color shading for the texture (including opacity in the gradient)

Or rather, set the R,G,B values or were wanting to only gradient the alpha value ?
__________________
  Reply With Quote
05-24-10, 12:45 AM   #3
mankeluvsit
An Onyxian Warder
 
mankeluvsit's Avatar
Join Date: Sep 2008
Posts: 354
Originally Posted by Xrystal View Post
I've not used Gradients myself but I did notice there are two functions... perhaps you need to use the other one ?



http://wowprogramming.com/docs/widge...re/SetGradient
•Texture:SetGradient("orientation", startR, startG, startB, endR, endG, endB) - Sets a gradient color shading for the texture

http://wowprogramming.com/docs/widge...tGradientAlpha
•Texture:SetGradientAlpha("orientation", startR, startG, startB, startAlpha, endR, endG, endB, endAlpha) - Sets a gradient color shading for the texture (including opacity in the gradient)

Or rather, set the R,G,B values or were wanting to only gradient the alpha value ?
nope, ive tried both ways, either or it doesnt really matter to me, but id like to do the alpha.
  Reply With Quote
05-24-10, 03:00 AM   #4
Ailae
A Rage Talon Dragon Guard
 
Ailae's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2007
Posts: 318
What do you mean when you say "it messes everything up"? Do you get any error(s)?

I'm guessing llmodel is a frame and not a texture, so you'll get "attempt to call method 'SetGradient' (a nil value)".
__________________
Oh, the simulated horror!
  Reply With Quote
05-24-10, 05:34 AM   #5
mankeluvsit
An Onyxian Warder
 
mankeluvsit's Avatar
Join Date: Sep 2008
Posts: 354
Originally Posted by Ailae View Post
What do you mean when you say "it messes everything up"? Do you get any error(s)?

I'm guessing llmodel is a frame and not a texture, so you'll get "attempt to call method 'SetGradient' (a nil value)".
kinda new to lua, yes llmodel is a frame, but "llmodel:SetBackdrop({
bgFile = "Interface\\AddOns\\!media\\bg", tile = true, tileSize = 46})"
is the texture?

or should i call the bg file as a local and do it that way? very puzzled.
  Reply With Quote
05-24-10, 06:09 AM   #6
Ailae
A Rage Talon Dragon Guard
 
Ailae's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2007
Posts: 318
Here's a basic example

lua Code:
  1. local frame = CreateFrame("Frame", nil, UIParent)
  2. frame:SetHeight(200)
  3. frame:SetWidth(400)
  4. frame:SetPoint("CENTER")
  5.  
  6. -- Instead of using a backdrop, you create a texture as the background
  7. frame.bg = frame:CreateTexture(nil, "BACKGROUND")
  8. frame.bg:SetAllPoints(frame)
  9. frame.bg:SetTexture("Interface/Tooltips/UI-Tooltip-Background")
  10. frame.bg:SetGradientAlpha("VERTICAL", 0, 0, 0, 0, 0, 0, 0, .6)

Looks like this (it's pinkish because of the color of the skybox):

__________________
Oh, the simulated horror!
  Reply With Quote
05-24-10, 06:32 AM   #7
mankeluvsit
An Onyxian Warder
 
mankeluvsit's Avatar
Join Date: Sep 2008
Posts: 354
misread,
this is what it looks like right now
Code:
llmodel:SetHeight(149)
llmodel:SetWidth(149)
llmodel:SetPoint("TOPLEFT", 15, -30)
llmodel.bg = llmodel:CreateTexture(nil, "BACKGROUND")
llmodel.bg:SetAllPoints(llmodel)
llmodel.bg:SetTexture("interface\\addons\\media\\bg.tga")
llmodel.bg:SetGradientAlpha("VERTICAL", 0, 0, 0, 0, 0, 0, 0, .6)
now if i use texture, it will overwrite the gradient. and vice versa.

Last edited by mankeluvsit : 05-24-10 at 06:38 AM.
  Reply With Quote
05-24-10, 06:53 AM   #8
hipjipp
A Cliff Giant
 
hipjipp's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 79
if i got you right you're trying to add a gradient to a texture? if so, why not create the texture like you have, then create a separate gradient texture like Ailae did and place it over the texture? wouldn't that work?
  Reply With Quote
05-24-10, 06:59 AM   #9
mankeluvsit
An Onyxian Warder
 
mankeluvsit's Avatar
Join Date: Sep 2008
Posts: 354
Originally Posted by hipjipp View Post
if i got you right you're trying to add a gradient to a texture? if so, why not create the texture like you have, then create a separate gradient texture like Ailae did and place it over the texture? wouldn't that work?
because the texture im using is tiled.

what im doing is have a portrait.
so its like this.

background -> gradient -> portrait
so you will see all 3 at once.

Last edited by mankeluvsit : 05-24-10 at 07:13 AM.
  Reply With Quote
05-24-10, 07:10 AM   #10
Ailae
A Rage Talon Dragon Guard
 
Ailae's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2007
Posts: 318
So, you want to have everything faded? The background with the portrait on it, and then fade the whole thing?
__________________
Oh, the simulated horror!
  Reply With Quote
05-24-10, 07:13 AM   #11
mankeluvsit
An Onyxian Warder
 
mankeluvsit's Avatar
Join Date: Sep 2008
Posts: 354
Originally Posted by mankeluvsit View Post
because the texture im using is tiled.

what im doing is have a portrait.
so its like this.

background -> gradient -> portrait
so you will see all 3 at once.
Originally Posted by Ailae View Post
So, you want to have everything faded? The background with the portrait on it, and then fade the whole thing?

whoops fixed it

edit again

i got it kinda....
*im sure itll hurt somes eyes.

its not tiling right ]:

Code:
mkButton = function (myframe,offset,nobg)
local offset = offset or 3
if nobg ~= true then
myframe.bg = myframe:CreateTexture(nil,"OVERLAY")

end
return myframe
end
	
	llmodel:SetAlpha(1)
	llmodel:SetPoint("TOPLEFT",4,-4)
	llmodel:SetPoint("BOTTOMRIGHT",-4,4)
	llmodel:SetFrameLevel(3)

	llmodel.bg = CreateFrame("Frame",nil,llmodel)
	llmodel.bg:SetAllPoints(llmodel)
	llmodel.bg = mkButton(llmodel.bg,0)
	llmodel.bg.bg:SetGradientAlpha("VERTICAL",.26,.26,.26,.14,color.r,color.g,color.b,.47)

	llmodel.bg.bg:SetBlendMode("BLEND")
	llmodel.bg:SetBackdrop{
	bgFile = iambg, tile = true, tileSize = 46,}
	llmodel.bg:SetAlpha(1)
	llmodel.bg:SetFrameLevel(3)

Last edited by mankeluvsit : 05-24-10 at 07:45 AM.
  Reply With Quote
05-24-10, 09:05 AM   #12
AlleyKat
A Warpwood Thunder Caller
 
AlleyKat's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 93
- you can cut off the "mkButton" function coz u don`t use it
- SetTexture is missed
- blend mode not needed coz "BLEND" is default
Code:
	llmodel:SetAlpha(1)
	llmodel:SetPoint("TOPLEFT",4,-4)
	llmodel:SetPoint("BOTTOMRIGHT",-4,4)
	llmodel:SetFrameLevel(3)

	llmodel.bg = CreateFrame("Frame",nil,llmodel)
	llmodel.bg:SetAllPoints(llmodel)
	llmodel.bg:SetBackdrop{
	bgFile = iambg, tile = true, tileSize = 46,}
        llmodel.bg:SetAlpha(1)
        llmodel.bg:SetFrameLevel(2)
       -- llmodel.bg:SetBackdropColor(color.r,color.g,color.b) -- ?

        llmodel.bg.bg = llmodel.bg:CreateTexture(nil,"OVERLAY")
        llmodel.bg.bg:SetTexture(1,1,1,1)
	llmodel.bg.bg:SetGradientAlpha("VERTICAL",.26,.26,.26,.14,color.r,color.g,color.b,.47)
	llmodel.bg.bg:SetAllPoints(llmodel.bg)

don`t know about ur "color.r,color.g,color.b"

Last edited by AlleyKat : 05-24-10 at 09:09 AM.
  Reply With Quote
05-24-10, 09:22 AM   #13
mankeluvsit
An Onyxian Warder
 
mankeluvsit's Avatar
Join Date: Sep 2008
Posts: 354
Originally Posted by AlleyKat View Post
- you can cut off the "mkButton" function coz u don`t use it
- SetTexture is missed
- blend mode not needed coz "BLEND" is default
Code:
	llmodel:SetAlpha(1)
	llmodel:SetPoint("TOPLEFT",4,-4)
	llmodel:SetPoint("BOTTOMRIGHT",-4,4)
	llmodel:SetFrameLevel(3)

	llmodel.bg = CreateFrame("Frame",nil,llmodel)
	llmodel.bg:SetAllPoints(llmodel)
	llmodel.bg:SetBackdrop{
	bgFile = iambg, tile = true, tileSize = 46,}
        llmodel.bg:SetAlpha(1)
        llmodel.bg:SetFrameLevel(2)
       -- llmodel.bg:SetBackdropColor(color.r,color.g,color.b) -- ?

        llmodel.bg.bg = llmodel.bg:CreateTexture(nil,"OVERLAY")
        llmodel.bg.bg:SetTexture(1,1,1,1)
	llmodel.bg.bg:SetGradientAlpha("VERTICAL",.26,.26,.26,.14,color.r,color.g,color.b,.47)
	llmodel.bg.bg:SetAllPoints(llmodel.bg)

don`t know about ur "color.r,color.g,color.b"

thanks again boss

color.r ect are player colors trying it out now.

it cuts the gradient out, and sit doesnt fix the tileset ]:
  Reply With Quote
05-24-10, 09:29 AM   #14
AlleyKat
A Warpwood Thunder Caller
 
AlleyKat's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 93
nwm. try

llmodel.bg:SetBackdropColor(color.r,color.g,color.b,1)
llmodel.bg.bg:SetGradientAlpha("VERTICAL",.26,.26,.26,.14,.26,.26,.26,.47)

or

llmodel.bg:SetBackdropColor(1,1,1,1)
llmodel.bg.bg:SetGradientAlpha("VERTICAL",color.r,color.g,color.b,.14,color.r,color.g,color.b,.47)

just advise
  Reply With Quote
05-24-10, 09:31 AM   #15
mankeluvsit
An Onyxian Warder
 
mankeluvsit's Avatar
Join Date: Sep 2008
Posts: 354
Originally Posted by AlleyKat View Post
nwm. try

llmodel.bg:SetBackdropColor(color.r,color.g,color.b,1)
llmodel.bg.bg:SetGradientAlpha("VERTICAL",.26,.26,.26,.14,.26,.26,.26,.47)

or

llmodel.bg:SetBackdropColor(1,1,1,1)
llmodel.bg.bg:SetGradientAlpha("VERTICAL",color.r,color.g,color.b,.14,color.r,color.g,color.b,.47)

just advise

i mean, the tile is still being stretched at the bottom
  Reply With Quote
05-24-10, 09:52 AM   #16
Ailae
A Rage Talon Dragon Guard
 
Ailae's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2007
Posts: 318
As far as I know, you can't use gradient on the backdrop so you can't use a backdrop to tile your texture if that's what you want.

You seem to do some crazy stuff though..

Here's an example of tilling a texture vertically and fading it (just used a random texture from WoW):

lua Code:
  1. local frame = CreateFrame("Frame", nil, UIParent)
  2. frame:SetHeight(512)
  3. frame:SetWidth(256)
  4. frame:SetPoint("CENTER")
  5.  
  6. -- Instead of using a backdrop, you create a texture as the background
  7. frame.bg = frame:CreateTexture(nil, "BACKGROUND")
  8. frame.bg:SetAllPoints(frame)
  9. frame.bg:SetTexture("Interface/OPTIONSFRAME/NvidiaLogo", true)
  10. frame.bg:SetTexCoord(0, 1, 0, frame:GetHeight()/64)
  11. -- the last bit above is basically <frame-height>/<tex-height>,
  12. -- to squeeze in as many full-sized tiles as possible, so you might
  13. -- have to tweak this to your preference. The original texture I
  14. -- used is 256x64 in size.
  15. frame.bg:SetGradientAlpha("VERTICAL", 1, 1, 1, 0, 1, 1, 1, .6)

Looks like this (again, the skybox):

__________________
Oh, the simulated horror!
  Reply With Quote
05-24-10, 10:00 AM   #17
AlleyKat
A Warpwood Thunder Caller
 
AlleyKat's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 93
Originally Posted by mankeluvsit View Post
i mean, the tile is still being stretched at the bottom
try another tileSize
64 or 32
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » gradient

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