WoWInterface

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

mankeluvsit 05-24-10 12:03 AM

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?

Xrystal 05-24-10 12:37 AM

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 ?

mankeluvsit 05-24-10 12:45 AM

Quote:

Originally Posted by Xrystal (Post 189207)
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.

Ailae 05-24-10 03:00 AM

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)".

mankeluvsit 05-24-10 05:34 AM

Quote:

Originally Posted by Ailae (Post 189219)
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.

Ailae 05-24-10 06:09 AM

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):


mankeluvsit 05-24-10 06:32 AM

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.

hipjipp 05-24-10 06:53 AM

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?

mankeluvsit 05-24-10 06:59 AM

Quote:

Originally Posted by hipjipp (Post 189236)
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.

Ailae 05-24-10 07:10 AM

So, you want to have everything faded? The background with the portrait on it, and then fade the whole thing?

mankeluvsit 05-24-10 07:13 AM

Quote:

Originally Posted by mankeluvsit (Post 189237)
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.

Quote:

Originally Posted by Ailae (Post 189238)
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)


AlleyKat 05-24-10 09:05 AM

- 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"

mankeluvsit 05-24-10 09:22 AM

Quote:

Originally Posted by AlleyKat (Post 189250)
- 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 :cool: trying it out now.

it cuts the gradient out, and sit doesnt fix the tileset ]:

AlleyKat 05-24-10 09:29 AM

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

mankeluvsit 05-24-10 09:31 AM

Quote:

Originally Posted by AlleyKat (Post 189256)
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

Ailae 05-24-10 09:52 AM

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):


AlleyKat 05-24-10 10:00 AM

Quote:

Originally Posted by mankeluvsit (Post 189257)
i mean, the tile is still being stretched at the bottom

try another tileSize
64 or 32


All times are GMT -6. The time now is 11:01 PM.

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