WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Legion Beta archived threads (https://www.wowinterface.com/forums/forumdisplay.php?f=177)
-   -   Texture:SetMask() (https://www.wowinterface.com/forums/showthread.php?t=53159)

zork 02-29-16 02:41 AM

Texture:SetMask()
 
Since when do we have this function?
http://wowprogramming.com/docs/widgets/Texture/SetMask

Is it a new api function in legion?

Until now we only had function to mask minimap textures.

semlar 02-29-16 04:23 AM

Heh, I knew this sounded familiar.

I extracted the exact same blp file that the interface uses this function with ("Interface\\CharacterFrame\\TempPortraitAlphaMask"), and it does nothing but make my texture disappear when I try to call SetMask with it.

It works when you reference the texture that's inside the game files, but it doesn't appear to be possible to create your own masks.

Resike 02-29-16 02:15 PM

You can use any built in Blizzard textures to mask another texture, SetPortraitTexture works very similar, it masks a round circle on the square race icons.

There is a hexagon texture, masked with the HOTS icon from the game:

Lua Code:
  1. local frame = CreateFrame("Frame", nil, UIParent)
  2. frame:SetPoint("Center", 0, 0)
  3. frame:SetSize(100, 100)
  4.  
  5. local icon = frame:CreateTexture("Texture", "Background")
  6. icon:SetTexture("Interface\\Icons\\Ability_Ambush")
  7. icon:SetMask("Interface\\ChatFrame\\UI-ChatIcon-HotS")
  8. icon:SetAllPoints(frame)

The problem is that the resolution/edges are highly based on the quailty of the masker AND the original image.

Another instresting masker images:

Lua Code:
  1. icon:SetMask("Interface\\DialogFrame\\DialogAlertIcon")
  2. icon:SetMask("Interface\\DialogFrame\\UI-Dialog-Icon-AlertNew")
  3. icon:SetMask("Interface\\GuildFrame\\GuildLogoMask_R")
  4. icon:SetMask("Interface\\ARCHEOLOGY\\Arch-Keystone-Mask")
  5. icon:SetMask("Interface\\GLUES\\Models\\UI_Dwarf\\UI_Goblin_GodRaysMask")
  6. icon:SetMask("Interface\\GLUES\\Models\\UI_DeathKnight\\IceCrown_CloudsA02_MASK01")
  7. icon:SetMask("Interface\\FriendsFrame\\PlusManz-Horde")

The possibilites are endless.

Miiru 03-04-16 04:17 AM

I noticed it being used in Blizzard_EncounterJournal.lua when they added the suggesting part.

lightspark 03-04-16 04:18 AM

Quote:

Originally Posted by zork (Post 313294)
Since when do we have this function?
http://wowprogramming.com/docs/widgets/Texture/SetMask

Is it a new api function in legion?

Until now we only had function to mask minimap textures.

For quite a while, I've been using it since late Cata or early MoP. There's a caveat though, if you want to crop/transform a texture by :SetTexCoord(), you first need to remove the mask, if any, transform the texture, and then re-apply the mask.

Lua Code:
  1. texture:SetMask(nil)
  2. texture:SetTexCoord(0, 1, 0, 1)
  3. texture:SetMask("texture-path-here")

zork 03-04-16 05:54 AM

lightspark can you post a more detailed example? Maybe even with screenshots?

lightspark 03-04-16 06:37 AM

Quote:

Originally Posted by zork (Post 313404)
lightspark can you post a more detailed example? Maybe even with screenshots?

I have an animated day/night indicator in my UI, it has round shape, cuz I made be a background of minimap calendar button, so I had to apply round mask to rectangular texture.

Old screenshot piece of an early prototype:


Here is code that adjusts texture according to daytime.

I used default blizz textures for both artwork and mask:

zork 03-04-16 06:45 AM

Thanks. To bad one can only use masks predefined wow textures. But good to know anyway. Cool idea btw.

lightspark 03-04-16 10:09 AM

Quote:

Originally Posted by zork (Post 313406)
Thanks. To bad one can only use masks predefined wow textures. But good to know anyway. Cool idea btw.

You are welcome :D Thank you :banana:

MunkDev 03-09-16 09:28 AM

The same mask works very well for creating round action buttons. Setting the mask on the icon texture removes the need of using that portrait function that Blizzard has for creating round textures. After setting the mask, the texture can just be updated as per usual with :SetTexture() and it seems it perfectly hides the square border on most icons.


MunkDev 04-12-16 07:29 PM

Has anybody found a way to recycle the masked textures? Once a mask is applied, Texture:GetTexture() returns a mask ID instead of the actual texture, but attempting to apply that texture reference elsewhere doesn't do anything.

I've noticed that the ID at the end keeps growing, even when you apply the same mask to the same texture, which means it keeps creating new masked textures instead of using the old ones. Since masking seems to be a very expensive task (try applying masks in an update script), I was hoping to find a way to re-use the masked textures I've already created.

Miiru 05-20-16 02:03 AM

What would be the safest way to completely remove the mask? (if there is any)


All times are GMT -6. The time now is 06:24 AM.

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