Thread: The ring v3
View Single Post
01-26-18, 08:30 AM   #1
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
The ring v3

In reference to http://www.wowinterface.com/forums/s...highlight=ring I would like to talk about rings in WoW patch >= 7.3.5.

We have MaskTexture now.
http://www.wowinterface.com/forums/s...ht=MaskTexture

It does allow us to create a mask texture that will render all textures it is applied to invisible.

On top of that we now have SetClipsChildren which can be applied to frames. There is no need for a scrollFrame any more to mask frames.

What I'm currently asking myself if it is possible to apply an animationgroup to the mask. Sort of like this:
Lua Code:
  1. local A, L = ...
  2. local mediapath = "interface\\addons\\"..A.."\\"
  3.  
  4. --container
  5. local f = CreateFrame("Frame",nil,UIParent)
  6. f:SetPoint("CENTER")
  7. f:SetSize(256,256)
  8.  
  9. --left ring frame with clip children
  10. local lr = CreateFrame("Frame",nil,f)
  11. lr:SetPoint("LEFT")
  12. local w,h = f:GetSize()
  13. lr:SetSize(w/2,h)
  14. lr:SetClipsChildren(true)
  15.  
  16. --half pie/square mask texture
  17. local m = lr:CreateMaskTexture()
  18. m:SetTexture(mediapath.."half")
  19. --m:SetTexture(mediapath.."half","CLAMP","CLAMP")
  20. --CLAMP, REPEAT, CLAMPTOBLACK, CLAMPTOBLACKADDITIVE, CLAMPTOWHITE, MIRROR
  21. m:SetSize(f:GetSize())
  22. m:SetPoint("CENTER",f,"CENTER",0,0)
  23.  
  24. --ring texture
  25. local t = lr:CreateTexture(nil,"BACKGROUND",nil,-8)
  26. t:SetTexture(mediapath.."ring")
  27. t:SetSize(f:GetSize())
  28. t:SetPoint("CENTER",f,"CENTER",0,0)
  29. t:SetVertexColor(1,0,0)
  30. t:AddMaskTexture(m)
  31. --t:RemoveMaskTexture(m)
  32.  
  33. --you can create additional textures on different layers and use the same mask
  34.  
  35. --animation group
  36. local ag = m:CreateAnimationGroup()
  37. local anim = ag:CreateAnimation("Rotation")
  38. anim:SetDegrees(360)
  39. anim:SetDuration(10)
  40. ag:Play()
  41. ag:SetLooping("REPEAT")

The frame itself is clipped. Inside the frame lives a number of textures. Each texture can have the same mask.
If the mask is a half-pie and we start to rotate it...it should crop all textures.

Sort of like this. The example above is just a half ring.


Yellow = frame
Purple = mask texture
Green = ring texture

Now that I see the images. Not sure if the mask has to be a half-pie at all. A half-square will be fine too.

A different approach could be to just use a circular shaped mask and let your textures be half-squares.

How would you do it?

On top of that how would you do it if you want textures animated?

I had the following idea. On top of the ring texture I put another ring texture which I will set to rotate 24/7. It is a blend texture that will multiply with the color texture below. Thanks to the mask both will be clipped. On top of that you get the feeling of an animated texture.

The mask does not apply to model frames, no?
__________________
| 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 : 01-26-18 at 12:13 PM.
  Reply With Quote