RoundedRectangle

From Multi Theft Auto: Wiki
Revision as of 06:08, 8 October 2020 by Woovie (talk | contribs)
Jump to navigation Jump to search

This function draws a rounded corner rectangle.

Syntax

nil dxDrawRoundedRectangle(x, y, width, height, radius, color, postGUI, subPixelPositioning)

Example

Click to collapse [-]
Client side
local data = {}
data.resolution = {}
data.resolution.x, data.resolution.y = guiGetScreenSize()
data.mainRect = {}
data.mainRect.width = 300
data.mainRect.height = 500

dxDrawRoundedRectangle(
    data.resolution.x-data.mainRect.width,
    data.resolution.y-data.mainRect.height,
    data.mainRect.width,
    data.mainRect.height,
    10,
    0xffffffff,
    false,
    false
)

Code

Click to collapse [-]
Client side
function dxDrawRoundedRectangle(x, y, width, height, radius, color, postGUI, subPixelPositioning)
    dxDrawRectangle(x+radius, y+radius, width-(radius*2), height-(radius*2), color, postGUI, subPixelPositioning)
    dxDrawCircle(x+radius, y+radius, radius, 180, 270, color, color, 16, 1, postGUI)
    dxDrawCircle(x+radius, (y+height)-radius, radius, 90, 180, color, color, 16, 1, postGUI)
    dxDrawCircle((x+width)-radius, (y+height)-radius, radius, 0, 90, color, color, 16, 1, postGUI)
    dxDrawCircle((x+width)-radius, y+radius, radius, 270, 360, color, color, 16, 1, postGUI)
    dxDrawRectangle(x, y+radius, radius, height-(radius*2), color, postGUI, subPixelPositioning)
    dxDrawRectangle(x+radius, y+height-radius, width-(radius*2), radius, color, postGUI, subPixelPositioning)
    dxDrawRectangle(x+width-radius, y+radius, radius, height-(radius*2), color, postGUI, subPixelPositioning)
    dxDrawRectangle(x+radius, y, width-(radius*2), radius, color, postGUI, subPixelPositioning)
end

Original by User:Extasy

Rewritten by User:Woovie