bz_ Posted July 7 Share Posted July 7 Hi. I've been trying to create a render target that I will be able to scroll the text and images that are inside of if (like a website). The problem is the image that I want the date to be on is in right position, but the text itself is in top left corner of the screen. (https://imgur.com/a/zJvhnRM) local sx, sy = guiGetScreenSize() local zoom = (sx < 2048) and math.min(2.2, 2048/sx) or 1 font = exports.hv_fonts local changes = { {date = '06/07/2024', text = 'Change 1'}, {date = '06/07/2024', text = 'Change 1'}, {date = '06/07/2024', text = 'Change 1'}, {date = '06/07/2024', text = 'Change 1'}, } local renderTargetWidth = 450 / zoom local renderTargetHeight = 250 / zoom local scrollOffset = 0 local scrollSpeed = 10 local maxScrollOffset = sy/2 - (#changes * 40) - renderTargetHeight/zoom function handleMouseWheel(button) if button == "mouse_wheel_up" then scrollOffset = math.min(scrollOffset + scrollSpeed, 0) elseif button == "mouse_wheel_down" then scrollOffset = math.max(scrollOffset - scrollSpeed, -maxScrollOffset) end end addEventHandler('onClientKey', root, handleMouseWheel) local changesTarget = dxCreateRenderTarget(renderTargetWidth, renderTargetHeight) function drawRender() dxSetRenderTarget(changesTarget, true) dxSetBlendMode("modulate_add") for i, change in ipairs(changes) do local offset = (i - 1) * 40 + scrollOffset dxDrawImage(20 / zoom, offset, 101 / zoom, 20 / zoom, 'data.png', 0, 0, 0, tocolor(255, 255, 255, 255), false) dxDrawText(change.date, 130 / zoom, offset, renderTargetWidth, offset + 20 / zoom, tocolor(255, 255, 255, 255), 1 / zoom, font:getFont('Inter-Regular', 12 / zoom), "left", "center", false, false, true, false, false) dxDrawText(change.text, 130 / zoom, offset + 20 / zoom, renderTargetWidth, offset + 40 / zoom, tocolor(255, 255, 255, 255), 1 / zoom, font:getFont('Inter-Regular', 12 / zoom), "left", "center", false, false, true, false, false) end dxSetBlendMode("blend") dxSetRenderTarget() dxDrawImage(sx/2 - renderTargetWidth/2, sy/2 - renderTargetHeight/2, renderTargetWidth, renderTargetHeight, changesTarget) end addEventHandler('onClientRender', root, drawRender) Can anyone suggest what is wrong in this code? Thanks in advance Link to comment
Moderators IIYAMA Posted July 7 Moderators Share Posted July 7 3 hours ago, bz_ said: Can anyone suggest what is wrong in this code? You could try: To remove the blend mode: dxSetBlendMode Not using a custom font Link to comment
bz_ Posted July 8 Author Share Posted July 8 On 07/07/2024 at 12:14, IIYAMA said: You could try: To remove the blend mode: dxSetBlendMode Not using a custom font Have tried what you have suggested, but it still does not work as I want (nothing changed) 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