Go to Page... |
Thread Tools | Display Modes |
06-08-17, 04:11 AM | #1 |
Having an issue with edge of backdrop being disappeared when frame's size changes
Hi all,
I should have gone to 'Graphics Help' forum rather than here, 'Lua/XML Help', but I guess this is more like a Lua related issue. So, I've created a generic Template function for my frames like the following: Lua Code:
Then I applied this to frame and resized the that frame. Lua Code:
Since the template frame's size varies based on its anchor points, I thought this would work fine, but as you can see the image below, left & right borders are gone once I changed the width of parent frame, bar. (Well, they are definitely there, but is not rendered(?) properly) I also attempted to change those regions' draw layer, but that didn't solve the problem Could anyone please help me out regarding this? Thank you! *EDIT: Applying insets to backdrop didn't do the trick as well. Code:
insets = { left = 1, right = 1, top = 1, bottom = 1, }, **EDIT: Here I've attached those texture files! Last edited by Layback_ : 06-08-17 at 04:19 AM. |
|
06-08-17, 08:58 AM | #2 |
This happens because you're trying to fit a square peg into a round hole. Your edge file is being drawn on fractioned pixels, meaning the calculations by the UI engine are uneven to the point where your frame's edges end up in between pixels to be drawn on screen.
Normally, this aliasing effect isn't that big a of a deal if you're using larger edge textures, but when you're down to 2 px borders, it matters how large your frame is and where it's placed on screen. This function can eliminate one such case, by forcing your frame to only allow even numbers for width and height: Lua Code:
Note that this might cause an infinite loop since the size is set from within the handler that responds to size changes, but find a way to bake this function into your frame. The other case in which this happens is placing a frame so that its size causes one of the border to not fit perfectly onto a pixel. This can be fixed by the same approach as the function I just posted, but operating on the x and y offsets of your frame:GetPoint() values. Last edited by MunkDev : 06-08-17 at 09:05 AM. |
|
06-08-17, 09:07 AM | #3 |
It's because you have it anchored to the center. When you resized the frame, the left and right borders were no longer on complete pixels so they didn't get rendered properly.
If you want to keep it anchored in the center you have to resize it by increments of 2 |
|
06-08-17, 01:17 PM | #4 | |
Lua Code:
And if the frame is move complex or ancored to another frame than things get even more complicated. I've managed to do pixel perfect scaling but it's well complicated as hell. |
||
06-08-17, 11:09 PM | #5 |
mmmmmmmmmmmmmmmm....
That seems complex than I thought. Maybe I should avoid using border textures until I get confident with it. (For now, I'll just use a backdrop texture as my borders) Thank you all ! Last edited by Layback_ : 06-09-17 at 04:45 AM. |
|
06-09-17, 03:39 AM | #6 |
I can give you an example code how to properly do it, after i drunk my covfefe.
|
|
06-09-17, 04:45 AM | #7 |
06-09-17, 05:02 AM | #8 |
Lua Code:
This frame can be moved/resized on the fly, and it keeps it's pixel perfection sizes on all of it's elements all the time, even after any (SetSize|SetWidth|SetHeight|SetPoint) calls. |
|
06-09-17, 06:35 AM | #9 | |
So the core of part of the example would be: Lua Code:
as you've explained on previous comment. What if the parent of such frame is not UIParent, but another frame? Would L#5 and L#8 still be same? or should I change UIParent to another parent frame that we create? + I've been digging codes out of ElvUI and it also has some variables and functions about pixel perfect. Would that be a relevant info here? If so, do you have any clues regarding what it actually does? Last edited by Layback_ : 06-09-17 at 07:03 AM. |
||
06-09-17, 09:49 AM | #10 |
You can however thats a bit more complex, since you can never know if the relative frame is not positioned on fraction pixels, for that you have to get the relative frames (GetLeft|GetBottom|GetTop|GetRight) based on anchor points and substract those values from the actual frame's (GetLeft|GetBottom|GetTop|GetRight), and it even gets more complicated since every different anchor points need different calculations, however i have a function for that already, called GetRelativePoint:
Lua Code:
This time the frame is anchored to the PlayerFrame, every time you move the PlayerFrame the frame moves with it, if you position the PlayerFrame on fraction of pixes it does not matter for the frame, the frame still will be positioned pixel perfectly every time. You can also move the frame related to the player frame and it will also keep the pixel perfection that way, and also every time to resize/rescale the PlayerFrame or resize the frame itself. HOWEVER it won't keep the pixel perfection if you scale the frame itself, thats requires even more work. I don't think ElvUI has pixel perfection, at least not a "perfect" pixel perfection. They just using a hack to set you UI scale on a number which only makes the frames pixel perfect on a 1.0 scaling, however every other scale value will be still be ugly (mostly for frames with edges). The perfect pixel perfect scaling/resizing on any value is a lot more harder to achieve, i have such a function for my frames, however it only works on frames that you know well and you build in a proper way, it can't be generalised to work on every frame easily. Last edited by Resike : 06-09-17 at 01:36 PM. |
|
06-09-17, 06:59 PM | #11 | ||
I gotta look through it!
It seems like I've underestimated pixel perfection... Yep, it is absolutely an horror... Anyways, thank you so much for such a detailed explanation! |
|||
06-10-17, 11:01 PM | #12 |
The solution I prefer for RealUI is to simply anchor frames corner-to-corner. This way you always know that it's being placed on a full pixel. (this is assuming the UI scale is pixel perfect)
|
|
06-10-17, 11:42 PM | #13 |
But my solution works on every resolution every UIScale ratio and every scale value.
Last edited by Resike : 06-11-17 at 12:09 AM. |
|
06-11-17, 05:36 AM | #14 | |
__________________
"In this world nothing can be said to be certain, except that fractional reserve banking is a Ponzi scheme and that you won't believe it." - Mandrill |
||
06-11-17, 09:24 AM | #15 |
Well you don't have to have OCD for that (maybe just a little one :P), i just wanted a complete solution.
Lets say you have an unit frame with 204 pixel width, if the user want to scale that not a single scale value scales the width to an even number between 0.80 and 1.20 scale (which would be the most common values if you want the make your frames a bit bigger or smaller), and even if you find a scale value that would fit for the width, thats sure won't fit for the frame's heigth. I'll make a detailed post about my solution later when i'm exam free. |
|
WoWInterface » Developer Discussions » Lua/XML Help » Having an issue with edge of backdrop being disappeared when frame's size changes |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
Linear Mode |
Switch to Hybrid Mode |
Switch to Threaded Mode |
|
|