Thread Tools Display Modes
02-29-16, 02:41 AM   #1
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
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.
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)
 
02-29-16, 04:23 AM   #2
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
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.
 
02-29-16, 02:15 PM   #3
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
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.

Last edited by Resike : 02-29-16 at 02:39 PM.
 
03-04-16, 04:17 AM   #4
Miiru
A Flamescale Wyrmkin
 
Miiru's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2008
Posts: 138
I noticed it being used in Blizzard_EncounterJournal.lua when they added the suggesting part.
__________________
◘◘ Author of MiirGui Texture Pack - [Core] [Blue] [Grey] ◘◘
 
03-04-16, 04:18 AM   #5
lightspark
A Rage Talon Dragon Guard
 
lightspark's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2012
Posts: 341
Originally Posted by zork View Post
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")
__________________

Last edited by lightspark : 03-04-16 at 04:28 AM. Reason: i need some coffee...
 
03-04-16, 05:54 AM   #6
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
lightspark can you post a more detailed example? Maybe even with screenshots?
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)
 
03-04-16, 06:37 AM   #7
lightspark
A Rage Talon Dragon Guard
 
lightspark's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2012
Posts: 341
Originally Posted by zork View Post
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:
__________________
 
03-04-16, 06:45 AM   #8
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
Thanks. To bad one can only use masks predefined wow textures. But good to know anyway. Cool idea btw.
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)
 
03-04-16, 10:09 AM   #9
lightspark
A Rage Talon Dragon Guard
 
lightspark's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2012
Posts: 341
Originally Posted by zork View Post
Thanks. To bad one can only use masks predefined wow textures. But good to know anyway. Cool idea btw.
You are welcome Thank you
__________________
 
05-20-16, 02:03 AM   #10
Miiru
A Flamescale Wyrmkin
 
Miiru's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2008
Posts: 138
What would be the safest way to completely remove the mask? (if there is any)
__________________
◘◘ Author of MiirGui Texture Pack - [Core] [Blue] [Grey] ◘◘
 
 

WoWInterface » Site Forums » Archived Beta Forums » Legion Beta archived threads » Texture:SetMask()


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