View Single Post
10-13-17, 06:15 AM   #17
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Originally Posted by semlar View Post
A pixel-perfect texture is, by definition, a specific number of pixels. Every pixel is drawn where it's supposed to be.

You can have a repeating pixel-perfect image, like a 1px border around a resizable frame, but scaling a pixel-perfect texture doesn't make any sense.
It does just not the way you imagined it. Lets say You have a resizable frame with a 1px border around it just like you said:

Lua Code:
  1. frame
  2. frame.border
  3. frame.scaled

You start sizing the frame, and you determine a scaling value by it's initial width/height value and the current one, the frame itself never gets scaled just sized, however you apply this scale value to the frame.scaled frame which is basically a virtual clone frame of the frame itself and all of it's child elements also gets scaled properly.

Every time the the sizing is done you make sure the frame is in pixel perfect conditions. (Anchored correctly with integer x, y values and have integer width and height values).
Anything you want to be scaled you parent to frame.scaled, BUT you anchor them to the frame! Which is always on a pixel perfect position. (FontStrings/etc).
Anything you DONT want to scale you parent it the the frame, and you also anchor to the frame too. (StatusBars/SubFrames/etc)

Now all you have left to do is to round the 1px edge size with this scaling value to an even number, means this 1px border only gets 2px big if the scaling value is >=1.5.
You can also use custom values here to set/determine when you want to add another pixel to this border.

This is how it works in action:

https://youtu.be/9EzZ_nUwUV0?t=38

This still does not cover every issue, however it does deals with most of them.

Like if the frame height is 10 pixel and you scale it by an extra 50% to 15 pixel, and initially you had a 4 pixel height FontString centered which fits perfectly, however the scaled FontString becomes 6 pixel height and you cannot fit this even number to the uneven 15 pixel by any way. So the centered FontString will jump a pixel up and down based on the engine's rounding. (If you have a good eye you can see this on the video.)

I can throw an example code for you about this, but i guess you get it how does this works.

Last edited by Resike : 10-13-17 at 06:51 AM.
  Reply With Quote