WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   General Authoring Discussion (https://www.wowinterface.com/forums/forumdisplay.php?f=20)
-   -   How to make pixel-accurate interface? (https://www.wowinterface.com/forums/showthread.php?t=56349)

Basil2 07-11-18 05:58 AM

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?

Tim 07-11-18 12:38 PM

Take a look at ElvUI's way..

https://git.tukui.org/elvui/elvui/bl...xelperfect.lua

runamonk 07-11-18 01:35 PM

Quote:

Originally Posted by Basil2 (Post 328597)
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

elcius 07-11-18 10:39 PM

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.

Basil2 08-28-18 06:01 AM

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


p3lim 08-28-18 09:21 AM

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


All times are GMT -6. The time now is 08:21 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI