View Single Post
03-13-13, 11:56 AM   #9
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
Lol...SetRotation has a bug. It does sth to my ring texture.



To get it to work properly I had to use the SQRT trick posted by Saiket here:
http://www.wowinterface.com/forums/s...ad.php?t=36679

My code is:
Lua Code:
  1. -- // DiscoKugel2
  2.   -- // zork - 2013
  3.  
  4.   --get the addon namespace
  5.   local addon, ns = ...
  6.  
  7.   local unpack = unpack
  8.   local _G = _G
  9.   local CF = CreateFrame
  10.   local UIP = UIParent
  11.   local abs = math.abs
  12.   local sin = math.sin
  13.   local pi = math.pi
  14.  
  15.   -----------------------------
  16.   -- FUNCTIONS
  17.   -----------------------------
  18.  
  19.   local f = CF("Frame",nil,UIP)
  20.   f:SetSize(512,512)
  21.   f:SetScale(0.5)
  22.   f.w, f.h = f:GetSize()
  23.   f:SetPoint("CENTER")
  24.  
  25.   local t = f:CreateTexture(nil, "BACKGROUND", nil, -8)
  26.   t:SetTexture("Interface\\AddOns\\rTestRing2\\media\\ring")
  27.   t:SetAllPoints()
  28.   t:SetAlpha(0.2)
  29.  
  30.   local sf1 = CF("ScrollFrame",nil,f)
  31.   sf1:SetSize(f.w/2,f.h)
  32.   sf1:SetPoint("LEFT")
  33.  
  34.   local sc1 = CF("Frame")
  35.   sf1:SetScrollChild(sc1)
  36.   sc1:SetSize(f.w,f.h)
  37.  
  38.   local rt1 = sc1:CreateTexture(nil,"BACKGROUND",nil,-6)
  39.   rt1:SetTexture("Interface\\AddOns\\rTestRing2\\media\\ring_half")
  40.   rt1:SetSize(sqrt(2)*f.w,sqrt(2)*f.h)
  41.   rt1:SetPoint("CENTER")
  42.   rt1:SetVertexColor(1,0,0)
  43.   rt1:SetRotation(math.rad(40)) -- etc
  44.  
  45.   --local ag = rt1:CreateAnimationGroup()
  46.   --local anim = ag:CreateAnimation("Rotation")
  47.   --anim:SetDegrees(90)
  48.   --anim:SetDuration(10)
  49.   --ag:Play()

Maybe it has sth to do with the mysterious 1px I read about. Going to try to snip out 1px of my ring.
Afaik I read sth about it in Iriels ring theory. Thus every texture with a transparent outer edge needs to stay away from the texture edge by atleast 1px. Gonna try that. I think they did that to determine matching background colors or the like.

Loooool. That worked. I stripped the outer pixel and BÄÄÄM.



So when working with Texture:SetRotation() you have to make sure to do these:
  • Texture size has to be in SQRT
  • Texture rotation must be in rad
  • Texture file must not hit the other edge of the image or you will get background color copy behaviour that you may not want.
__________________
| 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 : 03-13-13 at 01:40 PM.
  Reply With Quote