Jump to content

[HELP] Smoother dxDrawRoundedRectangle


Jokerbomb

Recommended Posts

Hello.

I want to get my roundedRectangle to show smoother like this:

  spacer.png

 

Mines looking like this at the moment:

spacer.png

Code is looking like this at the moment:


function renderInfobox()
 	dxDrawRoundedRectangles(sX/2 - width / 2 - 24, startY + 1, width - 2 + 25, height +20, tocolor ( 0,0,0,180 ), 8 )
	dxDrawText(text, sX/2 - width / 2 + width / 2, startY+20 + height / 2, _, _, tocolor(200, 200, 200, a), 1, font, "center", "center", false, false, false, true)
end
addEventHandler("onClientRender", root, renderInfobox)


function dxDrawRoundedRectangles(x, y, rx, ry, color, radius)
    rx = rx - radius * 2
    ry = ry - radius * 2
    x = x + radius
    y = y + radius
 
    if (rx >= 0) and (ry >= 0) then
        dxDrawRectangle(x, y, rx, ry, color)
        dxDrawRectangle(x, y - radius, rx, radius, color)
        dxDrawRectangle(x, y + ry, rx, radius, color)
        dxDrawRectangle(x - radius, y, radius, ry, color)
        dxDrawRectangle(x + rx, y, radius, ry, color)
 
        dxDrawCircle(x, y, radius, 180, 270, color, color, 7)
        dxDrawCircle(x + rx, y, radius, 270, 360, color, color, 7)
        dxDrawCircle(x + rx, y + ry, radius, 0, 90, color, color, 7)
        dxDrawCircle(x, y + ry, radius, 90, 180, color, color, 7)
    end
end

 

Link to comment
18 hours ago, Jokerbomb said:

Hello.

I want to get my roundedRectangle to show smoother like this:

  spacer.png

 

Mines looking like this at the moment:

spacer.png

Code is looking like this at the moment:


function renderInfobox()
 	dxDrawRoundedRectangles(sX/2 - width / 2 - 24, startY + 1, width - 2 + 25, height +20, tocolor ( 0,0,0,180 ), 8 )
	dxDrawText(text, sX/2 - width / 2 + width / 2, startY+20 + height / 2, _, _, tocolor(200, 200, 200, a), 1, font, "center", "center", false, false, false, true)
end
addEventHandler("onClientRender", root, renderInfobox)


function dxDrawRoundedRectangles(x, y, rx, ry, color, radius)
    rx = rx - radius * 2
    ry = ry - radius * 2
    x = x + radius
    y = y + radius
 
    if (rx >= 0) and (ry >= 0) then
        dxDrawRectangle(x, y, rx, ry, color)
        dxDrawRectangle(x, y - radius, rx, radius, color)
        dxDrawRectangle(x, y + ry, rx, radius, color)
        dxDrawRectangle(x - radius, y, radius, ry, color)
        dxDrawRectangle(x + rx, y, radius, ry, color)
 
        dxDrawCircle(x, y, radius, 180, 270, color, color, 7)
        dxDrawCircle(x + rx, y, radius, 270, 360, color, color, 7)
        dxDrawCircle(x + rx, y + ry, radius, 0, 90, color, color, 7)
        dxDrawCircle(x, y + ry, radius, 90, 180, color, color, 7)
    end
end

 

Heyo Bro, the best would be to use image or SVG. In case you need help understanding SVG, it's all in this thread Svg

Link to comment
  • 4 weeks later...

btw

On 20/02/2023 at 05:13, Kidzonio said:

Heyo Bro, the best would be to use image or SVG. In case you need help understanding SVG, it's all in this thread Svg

btw, how i can make the SVG fits with the text e.g : "note about your car : your car has been destroyed" another one "Wasted"
first one is too long but the 2nd is short how i can make one SVG fits with text length. or i have to make SVG for every note ?

Link to comment
function dxDrawRectangle(x, y, width, height, radius, color, postGUI)
    if not x or not y or not width or not height or not radius or not color then
        return
    end
    local radius = math.min(radius, width/2, height/2)
    dxDrawRectangle(x + radius, y, width - radius * 2, height, color, postGUI)
    dxDrawRectangle(x, y + radius, radius, height - radius * 2, color, postGUI)
    dxDrawRectangle(x + width - radius, y + radius, radius, height - radius * 2, color, postGUI)
    dxDrawCircle(x + radius, y + radius, radius, 180, 270, color, postGUI)
    dxDrawCircle(x + width - radius, y + radius, radius, 270, 360, color, postGUI)
    dxDrawCircle(x + radius, y + height - radius, radius, 90, 180, color, postGUI)
    dxDrawCircle(x + width - radius, y + height - radius, radius, 0, 90, color, postGUI)
end

 

Edited by STRANGEROUS
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...