- Documentation
- Client functions
- dxDrawRectangle
Function
dxDrawRectangle
Draws a filled rectangle on the screen for one frame. Call it in onClientRender to keep it visible.
Syntax
bool dxDrawRectangle(float startX, float startY, float width, float height [, int color = tocolor(255, 255, 255), bool postGUI = false])Arguments
startXfloat- Left edge in pixels.
startYfloat- Top edge in pixels.
widthfloat- Width.
heightfloat- Height.
colorint, optional = tocolor(255, 255, 255)- Colour from
tocolor. postGUIbool, optional = falsetrue= above GUI windows.
Differences from MTA:SA
- These MTA:SA arguments are not here:
bool subPixelPositioning = false
In MTA:SA
dxDrawRectangle(float startX, float startY, float width, float height, int color = white, bool postGUI = false, bool subPixelPositioning = false)Returns
true if drawn.
Example
A health bar in the bottom-left corner.
local sw, sh = guiGetScreenSize()
addEventHandler("onClientRender", root, function()
local hp = getElementHealth(localPlayer)
dxDrawRectangle(30, sh - 60, 204, 18, tocolor(0, 0, 0, 160))
dxDrawRectangle(32, sh - 58, 2 * hp, 14, tocolor(200, 40, 40))
end)
See also
dxDrawRoundedRectangleDraws a rectangle with rounded corners. The radius is in pixels and never exceeds half of the shorter side.dxDrawTextDraws text on the screen for one frame. Call it inonClientRenderto keep it visible.tocolorPacks a colour from four components into one ARGB number used by thedxfunctions.