Thread Tools Display Modes
11-10-10, 04:34 PM   #1
lilgulps
A Theradrim Guardian
 
lilgulps's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 62
How to rotate a frame?

Code:
local addon = CreateFrame("Frame", "Base2", UIParent)
addon:SetHeight(128)
addon:SetWidth(128)
addon:SetUserPlaced(true)
addon:SetPoint("Center", 100, 0)

local tex = addon:CreateTexture(nil, "ARTWORK")
tex:SetTexture(file)
tex:SetAllPoints(addon)
Is what I have right now creating a frame filled with a picture

What I want to do is rotate the picture to a certain angle
What can I do to accomplish this?

I thinkg SetDegrees() only works with animations?
  Reply With Quote
11-10-10, 04:46 PM   #2
Kjado
A Deviate Faerie Dragon
 
Kjado's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 10
You will need to use SetTexCoord() and linear transformations to rotate a texture. This wowpedia link has some mathematical background associated with it, but if you are only interested in grabbing some code to rotate you can probably skip towards the bottom.
__________________
My projects - Primal Defense | EchoPort | QuickTradeskill
  Reply With Quote
11-10-10, 05:05 PM   #3
lilgulps
A Theradrim Guardian
 
lilgulps's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 62
Code:
local angle = math.rad(90)
local cos, sin = math.cos(angle), math.sin(angle)
tex:SetTexCoord((sin - cos), -(cos + sin), -cos, -sin, sin, -cos, 0, 0)
Added this code in, except now my texture doesn't show up in game. Am I missing something?
  Reply With Quote
11-10-10, 05:17 PM   #4
Xubera
A Cobalt Mageweaver
 
Xubera's Avatar
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 207
myTexture:SetRotation(math.rad(90))
__________________
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
11-10-10, 05:26 PM   #5
lilgulps
A Theradrim Guardian
 
lilgulps's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 62
Code:
local addon = CreateFrame("Frame", "Base2", UIParent)
addon:SetHeight(128)
addon:SetWidth(128)
addon:SetUserPlaced(true)
addon:SetPoint("Center", 100, 0)

local tex = addon:CreateTexture(nil, "ARTWORK")
tex:SetTexture(file)
tex:SetAllPoints(addon)
tex:SetRotation(math.rad(90))
Rotated it 90 degrees but skews the image slightly, any idea why?

The height and width are the same are they not?

So I assume this shouldn't happen... : /
  Reply With Quote
11-10-10, 05:37 PM   #6
Duugu
Premium Member
 
Duugu's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 851
[quote=lilgulps;217270Rotated it 90 degrees but skews the image slightly, any idea why?[/QUOTE]

Try to add one transparent pixel at all sides of you texture. Without this SetTexCoord can "distort" the texture.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » How to rotate a frame?


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