Achieving pixel perfection
View Single Post
12-16-18, 06:33 AM
A Pyroguard Emberseer
Join Date: Oct 2008
While I have never tested it, I'm going to assume that your pmult example will be not what you want if you multiply height and width.
Height and width are integers representing pixels. If pmult is not an integer (it will always be a real or whole number, never an integer) then there is no possible way for either height or width to sit on a pixel. Instead, height and width will sit in between pixels, and look wrong.
That's why I suggested to never apply pmult to height or width. Scale on the other hand is a whole or real number, which means it includes integers, albeit as 1.0, 2.0, 3.0 rather than 1, 2, 3.
Should you be hellbent on allowing pmult on height or width, then you need to round up or down to the nearest integer after you multiply by pmult. It's a couple of extra steps.
When rounding, I further suggest a couple of sanity checks:
Use advanced rounding. If < 0.5 then round down, if >= 0.5 round up.
Use SetClampedToScreen(true). It becomes your friend.
Check that your rounded value is >=1 and <= (width - frameSize). You are trying to get the frame to fit on UIParent.
Double check height and width are modulo 2 == 0 (% 2 == 0). Should the result <= 1 and you are trying to center the frame, use math.ceil. That's the best you can do.
Last edited by myrroddin : 12-16-18 at
. Reason: typo
View Public Profile
Send a private message to myrroddin
Visit myrroddin's homepage!
Find More Posts by myrroddin