Bonsai Posted February 18, 2015 Share Posted February 18, 2015 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). 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
MTA Team botder Posted February 18, 2015 MTA Team Share Posted February 18, 2015 Try to use math.floor for the x/y position Link to comment
Bonsai Posted February 18, 2015 Author Share Posted February 18, 2015 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
Bonsai Posted February 19, 2015 Author Share Posted February 19, 2015 Meanwhile I discovered the problem is caused by the uppercase letter "Y" followed by, in this case, lowercase "o". It also happens with a few others. I guess that means its not related to my scripting, but a bug in general? Bonsai Link to comment
Addlibs Posted February 20, 2015 Share Posted February 20, 2015 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
Saml1er Posted February 20, 2015 Share Posted February 20, 2015 Nab bonana Mr.Tasty is right. Its because of that shadow. U need to remove hex codes from shadow string. Link to comment
Gallardo9944 Posted February 20, 2015 Share Posted February 20, 2015 You could try to create 1 render target with a text and then draw the render target twice: your colored one (use 255,255,255,255 color) and the shadow one (0,0,0,255 color) behind it. The lengths should be identical and the shadow should look better. Link to comment
Bonsai Posted February 20, 2015 Author Share Posted February 20, 2015 Nab bonana Mr.Tasty is right. Its because of that shadow. U need to remove hex codes from shadow string. ?! dxDrawText(clean(chat.line), function clean(text) return string.gsub(text, '#%x%x%x%x%x%x', '') end ... Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now