Reply
Thread Tools Display Modes
Unread 10-25-10, 11:35 PM   #1
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,391
How to handle SetBackdrop and do 1px stuff in just one call

Made a tutorial addon to let you experiment with settings.

http://www.wowinterface.com/download...tBackdrop.html

SetBackdrop allows
- glows/shadow
- inner glow/inner shadow
- border
- background

If you trick with the texture color and alpha layer you can even combine three effect at once.

Example

Flat texture:


The alpha layer:


Result:


So you get 3 effects at once. 1px outer shadow, 1px inner shadow and 1px border. Plus you can even change that white area to any color you want with SetBackdropBorderColor(r,g,b,a).

Additinally a texture to show how the borders are aligned:


It is LEFT, RIGHT, TOP, BOTTOM

Your texture need to keep the width/height ratio of 8:1, otherwise it will not work.

To get no anti-aliasing: If you are using a edge texture with 16px height your edgeSize must be 16 to get no scaling. If you are using glows scaling is allowed because id does not matter and has the effect of shortening the glow effect.

Why should I use SetBackdrop instead of SetTexture
The biggest plus of that is that your border will always be the same. It will not change it's width. So if you increase/decrease the size of a frame with that border, the border will stay constant.

If you use the trick of overlaying frame you can even create the illusion of a button. Lower layer will have a backdrop with an outer glow texture and a flat background. A layer above will have a different backdrop with just a border.

Check the mod and you will get it.

WOW API
http://wowprogramming.com/docs/widge...me/SetBackdrop
http://wowprogramming.com/docs/widge...ropBorderColor
http://wowprogramming.com/docs/widge...tBackdropColor
__________________
| Simple is beautiful.
| Roth UI | Roth UI FAQ | GoogleCode | Zork | TDMOG

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)

Last edited by zork : 10-25-10 at 11:49 PM.
zork is offline   Reply With Quote
Unread 05-22-11, 03:51 PM   #2
Goldpaw
A Cyclonian
 
Goldpaw's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 47
Originally Posted by zork View Post
Your texture need to keep the width/height ratio of 8:1, otherwise it will not work.

To get no anti-aliasing: If you are using a edge texture with 16px height your edgeSize must be 16 to get no scaling. If you are using glows scaling is allowed because id does not matter and has the effect of shortening the glow effect.
I've experienced some more or less interesting problems when creating border textures with 1px stuff in them. And it appears to be connected to how WoW handles its backdrop borders.

My 128x16px border file is divided into 8 parts, all 16x16 pixels in size. But only the center 14x14 pixels in each of those 8 parts are used by WoWs backdrops. The outer 1px rectangle is totally ignored. And this also affects the edgeSize. Because to WoW, the thickness of my border is 14, not 16.

So when setting the edgeSize in my backdrop, I have to put it to 14, even though my actual texture file has a height of 16. If I put it to 16, it gets blurry and antialiased, because to WoW, the height is 14.

EDIT:
This doesn't appear to be the case for tooltip borders. For my tooltips I have to set the edgeSize to the actual size in order for it to be displayed correctly. And yes, everything is scaled correctly.

Last edited by Goldpaw : 05-22-11 at 04:58 PM.
Goldpaw is offline   Reply With Quote
Unread 05-27-11, 06:18 AM   #3
hankthetank
A Theradrim Guardian
AddOn Author - Click to view addons
Join Date: Jul 2009
Posts: 64
I like the example. I did something similar with my UI to apply an inner glow from within Skinner's frame factory after realizing that SetBackdrop ist nothing more than a convenience function for 9 :CreateTextures, some :SetPoints and affine transformations via SetTexCoords (rotating the border tiles). You can reverse engineer it pretty easily when looking at the regions of a new frame after setting the backdrop.

skinner.lua

imaging.lua

And I have to agree with Goldpaw that creating clean borders is a somewhat difficult endeavor from time to time. I sometimes had issues with spacing between the border and the background when there shouldn't be any.

Last edited by hankthetank : 05-27-11 at 06:35 AM.
hankthetank is offline   Reply With Quote
Reply

Go BackWoWInterface » Developer Discussions » Tutorials & Other Helpful Info. » How to do SetBackdrop and handle 1px stuff in just one call.

Thread Tools
Display Modes

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