# dxDrawRectangle (Client)

> Draws a filled rectangle on the screen for one frame.

- **Platform**: MY Multiplayer (MYMP)
- **Kind**: Lua Function
- **Side**: Client
- **Category**: Screen drawing
- **URL**: https://wiki.mymp.gg/en/dxDrawRectangle

## Syntax

```lua
bool dxDrawRectangle(float x, y, float width, height [, color color = tocolor(255, 255, 255), bool postGUI = false, bool subPixelPositioning = false])
```

## Parameters

| Name | Type | Description |
| --- | --- | --- |
| `x, y` | `float` | Top-left corner, in pixels. A vec2 also works. |
| `width, height` | `float` | Size in pixels. A vec2 also works. |
| `color` | `color` | Colour, a `tocolor` value. *(default: `tocolor(255, 255, 255)`)* |
| `postGUI` | `bool` | Draw on top of the interface. *(default: `false`)* |
| `subPixelPositioning` | `bool` | Keep fractional positions instead of snapping to whole pixels. *(default: `false`)* |

## Returns

`true` once the drawing is queued.

## Example

```lua
local sx, sy = getScreenSize()

addEventHandler("onClientRender", root, function()
    dxDrawRectangle(sx - 220, 20, 200, 60, tocolor(0, 0, 0, 160))
end)
```

## See also

- [dxDrawImage (Client)](https://wiki.mymp.gg/en/dxDrawImage.md): Draws an image on the screen for one frame.
- [dxDrawCircle (Client)](https://wiki.mymp.gg/en/dxDrawCircle.md): Draws a filled circle, or a slice of one, on the screen for one frame.
- [getScreenSize (Client)](https://wiki.mymp.gg/en/getScreenSize.md): Returns the size of the game's screen in pixels.
- [onClientRender (Client)](https://wiki.mymp.gg/en/onClientRender.md): Fired every frame, when that frame's dx drawing should be done.
