Thread Tools Display Modes
10-16-13, 03:07 PM   #1
Mayron
A Frostmaul Preserver
 
Mayron's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 275
Very Simple Q: How can I flip a frame vertically?

Hi this may sound dumb but I've created a frame and gave it a backdrop with the texture however the texture is the wrong way up so I want to flip it vertically to show the right way. I do not want to recreate the .tga file with the texture the right way since I will need to use it again in the way it currently is.

Is there a method I can use to simply rotate it 180 degrees or flip a frame? The only one I could find was for an animation but I want it always to load and stay that way.

Thank you and I hope I explained that well enough.

With kgPanles I was able to use the "Flip Vertically" check box for a frame but I do not want to use that addon anymore.
  Reply With Quote
10-16-13, 03:29 PM   #2
Dridzt
A Pyroguard Emberseer
 
Dridzt's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2005
Posts: 1,360
This SetRotation should do what you want.
  Reply With Quote
10-16-13, 03:35 PM   #3
Mayron
A Frostmaul Preserver
 
Mayron's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 275
Thank you, I really do not understand why but I could not find it in the list of API's on wowwiki and other sites at all and still can't find a way to get to that page you linked. But at least now I know such a thing exists
  Reply With Quote
10-16-13, 04:38 PM   #4
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
I would use texture:SetTexCoord if you're trying to just flip it around.

SetTexCoord(1, 0, 0, 1) would flip it horizontally, SetTexCoord(0, 1, 1, 0) would flip it vertically.
  Reply With Quote
10-17-13, 02:22 AM   #5
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
A simple flip function can be found in http://wowprogramming.com/utils/xmlb...ionOverlay.lua
Lua Code:
  1. local texLeft, texRight, texTop, texBottom = 0, 1, 0, 1;
  2.     if ( vFlip ) then
  3.         texTop, texBottom = 1, 0;
  4.     end
  5.     if ( hFlip ) then
  6.         texLeft, texRight = 1, 0;
  7.     end
  8.     texture:SetTexCoord(texLeft, texRight, texTop, texBottom);

If you want to use rotation you can do this. Not sure how the effect is if you apply a flip-settexcoord beforehand:
Lua Code:
  1. local sqrt2 = sqrt(2)
  2.   texture:SetSize(sqrt2 *frame:GetWidth(),sqrt2 *frame:GetHeight())
  3.   texture:SetPoint("CENTER")
  4.   texture:SetRotation(math.rad(200))

If you are using SetRotation make sure you multiply the texture size with sqrt(2). Additionally make sure no pixel of your texture touches the outer edge of the texture image. The outmost pixel is used for color transmutation.

Another option is using AnimationGroups: http://www.wowinterface.com/forums/s...ad.php?t=35104
Lua Code:
  1. texture.ag = texture:CreateAnimationGroup()
  2.   texture.ag.a1 = t.ag:CreateAnimation("Rotation")
  3.   texture.ag.a1:SetDegrees(-360)
  4.   texture.ag.a1:SetDuration(60)
  5.   texture.ag:SetLooping("REPEAT")
  6.   texture.ag:Play()
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)

Last edited by zork : 10-17-13 at 02:32 AM.
  Reply With Quote
10-17-13, 02:34 AM   #6
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Just use SetTexCoords if all you want is a straight horizontal or vertical flip. There's no need to use special custom functions, multiple math operations, or (wtf) animations for something so simple.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
10-17-13, 03:56 AM   #7
Mayron
A Frostmaul Preserver
 
Mayron's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 275
Thank you, this is really helpful. The issue I have is that the artwork is using a backdrop rather than a SetTexture() method because I wanted to also use SetBackdropColor()

Have I done this wrong? Is it possible to either rotate a frame or the backdrop or make it using a texture and then alter the colour without just overlaying a colour. Because when I alter the colour using a backdrop it alters the white areas which looks great but changing the textures colour will remove the actual graphical artwork.

Sorry if my description is bad
  Reply With Quote
10-17-13, 10:34 AM   #8
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
Not sure if you can rotate a backdrop. You might have to resort to using animations to rotate the entire frame, then. Don't think you can rotate a frame any other way.

Anyway you're probably better off making a normal texture instead of backdrop. Can you post a screenshot of how it looks when it's working as you want and when it's not?
__________________
Grab your sword and fight the Horde!
  Reply With Quote
10-17-13, 01:10 PM   #9
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
You can use texture:SetVertexColor in the same way you use backdrop:SetBackdropColor if that's the only reason you're using a backdrop instead of a texture.

If your border needs to be flipped you might have a more complicated problem.
  Reply With Quote
10-17-13, 01:53 PM   #10
Mayron
A Frostmaul Preserver
 
Mayron's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 275
Originally Posted by semlar View Post
You can use texture:SetVertexColor in the same way you use backdrop:SetBackdropColor if that's the only reason you're using a backdrop instead of a texture.

If your border needs to be flipped you might have a more complicated problem.
Ah well then that will work out perfectly! Brilliant thank you! And no I do not need a border, I only used a backdrop because I haven't really experimented much with the SetVertexColor method, I just assumed it worked like "texture:SetTexture(r, g, b[, a]);". I use to know this but haven't played around with this topic of lua programming in a long time.

Thanks again, will try it out later.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Very Simple Q: How can I flip a frame vertically?


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