WoW screen is using these sort of floating point virtual pixels, they go up to 768 in height and proportionally for aspect ratio in width, and they map onto your real resolution. And then there's possibly global UI scale in the mix. In the end the line that you wanted to be 2 virtual pixels wide ends up snapping to either 2 or 3 real pixels depending on where it is
So you need to reverse this process and find out what amount of virtual pixels is corresponding to real pixels
Here's what i use to find it:
Code:
local res = GetCVar("gxWindowedResolution")
if res then
local w,h = string.match(res, "(%d+)x(%d+)")
pmult = (768/h) / UIParent:GetScale()
end
Not sure if consistently using whole number of real pixels guarantees perfection, but in my experience it makes it better at least. Also ideally you don't want to use UI scale