Jump to content

Dx Quality Problem


Bonsai

Recommended Posts

Hey,

I'm using dx functions to draw a line of text on the screen.

With a little offset I draw the same line with black color behind it (shadow).

GykktOR.png

The first line starts to look weird after the first color code at "/block" is applied.

It looks worse when the background changes due to camera movement.

I have no idea whats causing this problem.

I draw it as described in here: https://wiki.multitheftauto.com/wiki/DxSetBlendMode

Bonsai

Link to comment
if chatbox.useNewMessageScrollAnimation then 
  
    dxSetRenderTarget(chatbox.renderTarget, true) 
    dxSetBlendMode("modulate_add") 
  
end 
  
--Lines 
for i, chat in ipairs(chatbox.tabs[chatbox.selectedTabIndex].chats) do 
  
    dxDrawText(clean(chat.line), chatbox.textPosX+1, chatbox.textPosY+chatbox.height-(chatbox.lineHeight*(i-chatbox.scroll))+(chatbox.lineHeight*chatbox.newMessageScrollValue)+1, chatbox.width, chatbox.height, tocolor(0, 0, 0, chat.alpha), chatbox.fontSizeX, chatbox.fontSizeY, chatbox.font, "left", "top", false, false, false, true)  
    dxDrawText(chat.line, chatbox.textPosX, chatbox.textPosY+chatbox.height-(chatbox.lineHeight*(i-chatbox.scroll))+(chatbox.lineHeight*chatbox.newMessageScrollValue), chatbox.width, chatbox.height, tocolor(255, 255, 255, chat.alpha), chatbox.fontSizeX, chatbox.fontSizeY, chatbox.font, "left", "top", false, false, false, true)  
     
end 
  
dxSetBlendMode("blend")   
  
if chatbox.useNewMessageScrollAnimation then 
     
    dxSetRenderTarget() 
     
    dxSetBlendMode("add") 
    dxDrawImage(chatbox.posX, chatbox.posY, chatbox.width, chatbox.height, chatbox.renderTarget, 0, 0, 0, tocolor(255,255,255,255), chatbox.postGUI) 
    dxSetBlendMode("blend") 
     
end 
  
function clean(text) 
  
    return string.gsub(text, '#%x%x%x%x%x%x', '') 
  
end 
  

Link to comment

For me, it looks as though HEX colour coding makes the new coloured text appear like 1px further (as if the hex was replaced with a 1px-long character). Shadowed texts completely remove HEX colour codes via string.gsub (without leaving that 1px-long character). Although I might be wrong ^^

It seems that the actual dx text drawing codes don't use sub-pixel positioning, therefore text-parts are rounded to the nearest pixel - meaning that sometimes the normal, coloured text appears to be slightly longer (due to rounding up) than text without separation for colouring. Of course, I don't know how the actual code works but this assumption is based on that the dx text is split into parts, every part for every colour used.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...