How to add a thin border to a frame?
Hello,
Is there a simple way to draw/add a thin border to a frame, without any .tga file? Something like CSS attribute border: 1px solid #00ff00 I tried with Backdrop's edgeFile with some built-in texture files but the result is not accurate (the border is not well drawn), at least with small frames like buttons. My final goal is to write a function like .addBorder(frame, borderWidth, borderColor) |
Look at one of the preset backdrop examples that are used with the built in frames.
https://www.townlong-yak.com/framexml/live/Backdrop.lua You may have to look at the inset value as well. Find a blizzard frame that does something similar to what you want to do and see which of the backdrops they have set up for it. And then go from there. |
Very interesting link, Xrystal.
Thank you. |
Just to piggyback onto Xrystal; here is a small sample of frame templates.
Options box template has the finest line, so that may be a great place to start.. |
Nice :)
Thank you. |
1 Attachment(s)
If you want something simple and direct, this is what I use to add a 1pixel black border around my chat frame with a single pixel missing at the corners:
Lua Code:
A blank "background" container with four black textures anchored to the four corners. With the way this lays out, these lines rest right on the edges of the parent frame, leaving the blank corners clear from the parent frame's own background. Attached is a screenshot of my chatframes. I repeat this code for each chatframe separately. |
Interesting trick! Thank you Kanegasi.
I tried this, but the result is sometime not very accurate: Code:
-- params |
The code you tested is correct; I'm guessing you've run into what I've run into and sometimes it's a pixel bigger or smaller than it should be in some places while in others it's perfect?
|
Quote:
|
I have the same issue. I draw lots of boxes (bags/items in the bags) and even with changing the scaling I could never get it draw everything perfect. Super annoying.
|
DISCLAIMERB: I might not use the correct terms, but, this has happened to me also.
I had this issue with one of my laptops - turned out that it was just not "pixel perfect", only I didn't know that until I got a new laptop and everything (all of the borders and such) were perfect. I don't think that is your problem, though. It's my understanding that WoW's parent company has fixed that particular problem. But, I could always be wrong. :o In my defense I must tell you that I'm 67 years of age and live in an assisted living facility, and I haven't played WoW in four and a half years and I don't believe I ever will again. |
Something else to try:
Lua Code:
It's along the same lines as Kanegasi's solution. |
Maybe it should be intensively tested but Fizzlemizz's solution seems perfect :)
Though, I don't understand why corners are rounded (it's obvious with thickness > 1) |
If you're using the backdrop method, the API behind that is called "NineSlice". This is a method of creating resizeable textured frames of nine pieces, consisting of four static corners, four repeatable edge textures, and a repeatable background. The corners are rounded because they are separate textures, the roundness not noticeable at really tiny sizes.
|
Considring Fizzlemizz's script, is there a way to modify border color of an existing border, previously created with his script?
Lua Code:
|
The textures are stored as indexes in the borders key of the parent frame. If you were to do ZaxBorders=CreateFrame("frame") instead of local f=CreateFrame("frame"), you can change the colors like so:
Lua Code:
Also, the way the code is currently ordered, 1 is top, 2 is right, 3 is bottom, and 4 is left. You can change the color of, say, just the bottom with this: ZaxBorders.borders[3]:SetColorTexture(r,g,b,a) |
Again, the same as Kanegasi but slightly different in order to bake the border colouring into your created frames:
Lua Code:
|
Great :)
Thank you very much Fizzlemizz and Kanegasi for your scripts, and also for your time and patience. |
Quote:
Do the corners have parentkeys too? Currently I'm accesing them with GetRegions() lol. |
Quote:
TopLeftCorner TopRightCorner BottomLeftCorner BottomRightCorner TopEdge BottomEdge LeftEdge RightEdge Center However, the pieces are accessed via: Lua Code:
The only two places I found using GetNineSlicePiece were for Blizzard_BFAMissionUI and Blizzard_CovenantMissionUI which had keys: TopLeftCorner TopRightCorner BotLeftCorner BotRightCorner TopBorder BottomBorder LeftBorder RightBorder |
All times are GMT -6. The time now is 08:14 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI