Thread Tools Display Modes
07-11-18, 05:58 AM   #1
Basil2
An Aku'mai Servant
Join Date: Feb 2015
Posts: 30
How to make pixel-accurate interface?

I am trying to output some pixels and have two problems.


1. Frame:SetSize(x, y) in real pixels is not exactly x and y.

I can compensate it by using Frame:SetScale(768/real_resolution). But how can I get <real_resolution> within addon?


2. I cannot set exact pixel color.

I have
Code:
function SetColor256(obj, r, g, b)
    obj:SetColorTexture(r/255, g/255, b/255)
end
However, when I call it like SetColor256(1, 2, 3), real pixel might have (0, 1, 3). Or (1,2,3) as planned. Why? How to compensate it?
  Reply With Quote
07-11-18, 12:38 PM   #2
Tim
A Rage Talon Dragon Guard
 
Tim's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 308
Take a look at ElvUI's way..

https://git.tukui.org/elvui/elvui/bl...xelperfect.lua
__________________
AddOns: Tim @ WoWInterface
Characters: Mage, Priest, Devoker, Pally
Battle Tag: Mysterio#11164
Current PC Setup: PCPartPicker List
  Reply With Quote
07-11-18, 01:35 PM   #3
runamonk
A Theradrim Guardian
 
runamonk's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2007
Posts: 61
Originally Posted by Basil2 View Post
I am trying to output some pixels and have two problems.


1. Frame:SetSize(x, y) in real pixels is not exactly x and y.

I can compensate it by using Frame:SetScale(768/real_resolution). But how can I get <real_resolution> within addon?


2. I cannot set exact pixel color.

I have
Code:
function SetColor256(obj, r, g, b)
    obj:SetColorTexture(r/255, g/255, b/255)
end
However, when I call it like SetColor256(1, 2, 3), real pixel might have (0, 1, 3). Or (1,2,3) as planned. Why? How to compensate it?
Check out oUF.
and
Check out oUF p3lim
  Reply With Quote
07-11-18, 10:39 PM   #4
elcius
A Cliff Giant
AddOn Author - Click to view addons
Join Date: Sep 2011
Posts: 75
Most of the sub pixel issues in wow stem from loss of precision on frame dimensions & position, check the actual position and size of whatever you're having issues with, most likely there will be floating point errors, textures will go through the filter if they are not correctly positioned & scaled.
the issue is most noticeable in text (as text does not filter, it just floors the position).
for example, take the ElvUI options window (or any frame with a lot of text anchored to it) and drag it around slowly, you'll notice the text shifts up & down.
then increase the width & height of the frame by 0.01, and you'll notice the text stops wiggling and all the textures sharpen up.

It's also worth mentioning that you can put your textures and shit directly in WorldFrame to avoid ui scaling.

Last edited by elcius : 07-11-18 at 10:46 PM.
  Reply With Quote
08-28-18, 06:01 AM   #5
Basil2
An Aku'mai Servant
Join Date: Feb 2015
Posts: 30
Tnank you for answers, the problems were solved:

1: By using GetPhysicalScreenSize()

2: By using the following code:

Code:
local function SetColor256(obj, r, g, b)
    local function to01(value0255)
        if (value0255 ~= 255) then
            value0255 = value0255 + 0.4
        end
        return value0255 / 255
    end
    obj:SetColorTexture(to01(r), to01(g), to01(b))
end
  Reply With Quote
08-28-18, 09:21 AM   #6
p3lim
A Pyroguard Emberseer
 
p3lim's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,710
From https://github.com/p3lim-wow/Inomena...er/scaling.lua

Lua Code:
  1. function E:PLAYER_LOGIN()
  2.     local width, height = GetPhysicalScreenSize()
  3.     if((768 / height) < (768 / 1200)) then
  4.         -- Game can't scale further than 0.64
  5.         -- Instead we change the UI scale to 1 and the UIParent scale to the correct one
  6.         SetCVar('useuiscale', 1)
  7.         SetCVar('uiscale', 1)
  8.         UIParent:SetScale(768 / height)
  9.     else
  10.         SetCVar('useuiscale', 0)
  11.     end
  12. end
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » How to make pixel-accurate interface?

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