Quantcast
Pixel Perfect 1px borders - WoWInterface
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
12-27-20, 04:19 AM   #1
gempir
A Black Drake
 
gempir's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2015
Posts: 84
Pixel Perfect 1px borders

I'm trying to create a pixel perfect border that is 1px. My method was working perfectly in Legion, but seems broken now in Shadowlands.



Here you can see an example of what works and what doesn't. The buffs and Unitframes are a custom oUF Layout.
And in the screenshot you can see they have 2px of Border on the bottom.

The Panel in the middle (behind the actionbars) uses the same function to create borders and is doing just fine with borders, no 2px thickness anywhere.

Lua Code:
  1. function F.createBorder(self, anchor, extend)
  2.     spacing = 0
  3.     if extend then
  4.         spacing = 1
  5.     end
  6.  
  7.     if not anchor then
  8.         anchor = parent
  9.     end
  10.  
  11.     if self:GetObjectType() == "StatusBar" then
  12.         self = CreateFrame("Frame", nil, self)
  13.         self:SetPoint("TOPLEFT", anchor, "TOPLEFT", 0, 0)
  14.         self:SetPoint("BOTTOMRIGHT", anchor, "BOTTOMRIGHT", 0, 0)
  15.     end
  16.  
  17.     if not self.borders then
  18.         self.borders = {}
  19.         for i=1, 4 do
  20.             self.borders[i] = self:CreateLine(nil, "LOW", nil, 0)  
  21.             local l = self.borders[i]
  22.             l:SetThickness(1)
  23.             l:SetColorTexture(unpack(G.colors.border))
  24.             if i==1 then
  25.                 l:SetStartPoint("TOPLEFT", -spacing, spacing)
  26.                 l:SetEndPoint("TOPRIGHT", spacing, spacing)
  27.             elseif i==2 then
  28.                 l:SetStartPoint("TOPRIGHT", spacing, spacing)
  29.                 l:SetEndPoint("BOTTOMRIGHT", spacing, -spacing)
  30.             elseif i==3 then
  31.                 l:SetStartPoint("BOTTOMRIGHT", spacing, -spacing)
  32.                 l:SetEndPoint("BOTTOMLEFT", -spacing, -spacing)
  33.             else
  34.                 l:SetStartPoint("BOTTOMLEFT", -spacing, -spacing)
  35.                 l:SetEndPoint("TOPLEFT", -spacing, spacing)
  36.             end
  37.         end
  38.     end
  39.  
  40.     return self
  41. end

This is the function to create borders for my frames. When hardcoding spacing to like 5 or so to play around with the position, I noticed the border of 2px sometimes being on top. Other UI Elements like my Tooltip have it on 2 sides.
(Although I don't use the same border function for that on the tooltip)



Here is the code for the tooltip (and rest of my code) if it helps giving any context. https://github.com/gempir/gempUI/blo...es/tooltip.lua


I have read several older threads about this on here, but can't find one that helps me with my problem.
I have played around with UI scaling with stuff like this

Lua Code:
  1. SetCVar('useuiscale', 1)
  2. SetCVar('uiscale', 1)
  3. local _, height = GetPhysicalScreenSize()
  4. UIParent:SetScale(768 / height)

This seems to work but generally just makes everything too big on my 1440p screen. Preffered Solution would be with the UI Scaling option off, that looks best to me.

Setting the UI scale to the minimum possible via the UI seems to make it a bit better, but there are still some vertical borders that are too big.

Last edited by gempir : 12-27-20 at 05:52 AM. Reason: Add more debug info
  Reply With Quote
 

WoWInterface » Developer Discussions » Lua/XML Help » Pixel Perfect 1px borders

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off