AlvarO Posted April 13, 2020 Share Posted April 13, 2020 Hello guys, I'm trying to draw rounded rectangle on my script, but the question is, is there a way to modify the curvature of the corners? I mean, there's default curvature, but I would change it. Long time ago, there was a function which has an argument to modify this. This is the code I'm using: function roundedRectangle(x, y, w, h, borderColor, bgColor, postGUI) if (x and y and w and h) then if (not borderColor) then borderColor = tocolor(0, 0, 0, 200); end if (not bgColor) then bgColor = borderColor; end dxDrawRectangle(x, y, w, h, bgColor, postGUI); dxDrawRectangle(x + 2, y - 1, w - 4, 1, borderColor, postGUI); dxDrawRectangle(x + 2, y + h, w - 4, 1, borderColor, postGUI); dxDrawRectangle(x - 1, y + 2, 1, h - 4, borderColor, postGUI); dxDrawRectangle(x + w, y + 2, 1, h - 4, borderColor, postGUI); end end Link to comment
Scripting Moderators thisdp Posted April 13, 2020 Scripting Moderators Share Posted April 13, 2020 https://github.com/thisdp/dgs/blob/master/plugin/roundRect.Lua Link to comment
AlvarO Posted April 13, 2020 Author Share Posted April 13, 2020 Well, I know already about dgs' library, but the question is, is there any drawing function which makes the same? I mean, not using shaders. Link to comment
iwalidza Posted April 13, 2020 Share Posted April 13, 2020 i have good code its will give you good think function DrawRoundedRectangle(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) -- bar 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
Moderators Patrick Posted April 13, 2020 Moderators Share Posted April 13, 2020 Example on https://wiki.multitheftauto.com/wiki/DxDrawCircle Link to comment
AlvarO Posted April 13, 2020 Author Share Posted April 13, 2020 OH, THAT IS WHAT I'M SEARCHING FOR!! Thanks for your time guys! SOLVED Link to comment
Scripting Moderators thisdp Posted April 14, 2020 Scripting Moderators Share Posted April 14, 2020 I mean.. you can just take the shader Link to comment
iwalidza Posted April 14, 2020 Share Posted April 14, 2020 (edited) 32 minutes ago, thisdp said: I mean.. you can just take the shader i am try to take a shader but XD i cant say that Edited April 14, 2020 by iwalidza Link to comment
Scripting Moderators thisdp Posted April 14, 2020 Scripting Moderators Share Posted April 14, 2020 (edited) 1 hour ago, iwalidza said: i am try to take a shader but XD i cant say that The reason why I use shader is that with dx functions, I will get a non-smooth round rectangle XD Edited April 14, 2020 by thisdp Link to comment
iwalidza Posted April 14, 2020 Share Posted April 14, 2020 10 hours ago, thisdp said: The reason why I use shader is that with dx functions, I will get a non-smooth round rectangle XD This is so annoying as pixles, I didn't know how to take yours and didn't know how to make one 1 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