Draws a rectangle with specified position, size, and fill mode.
Takes x (top-left X position in pixels, integer), y (top-left Y position in pixels, integer), width (rectangle width in pixels, positive integer), height (rectangle height in pixels, positive integer), fill (fill mode: 0=outline only, 1=filled solid).
Returns nothing.
2D Overlay
Parameters & Returns
Parameters
xInt
yInt
widthInt
heightInt
fillInt
Returns
Void
Quick Summary
Draws a rectangle with specified position, size, and fill mode.
Takes x (top-left X position in pixels, integer), y (top-left Y position in pixels, integer), width (rectangle width in pixels, positive integer), height (rectangle height in pixels, positive integer), fill (fill mode: 0=outline only, 1=filled solid).
Returns nothing.
Technical Exegesis...
Draws a rectangle with specified position, size, and fill mode. Takes x (top-left X position in pixels, integer), y (top-left Y position in pixels, integer), width (rectangle width in pixels, positive integer), height (rectangle height in pixels, positive integer), fill (fill mode: 0=outline only, 1=filled solid). Returns nothing. Queues rectangle draw command to deferred rendering buffer, executed during b3dRenderWorld. Uses current color state from b2dSetColor and alpha from b2dSetAlpha.
Draws a rectangle with specified position, size, and fill mode. Takes x (top-left X position in pixels, integer), y (top-left Y position in pixels, integer), width (rectangle width in pixels, positive integer), height (rectangle height in pixels, positive integer), fill (fill mode: 0=outline only, 1=filled solid). Returns nothing. Queues rectangle draw command to deferred rendering buffer, executed during b3dRenderWorld. Uses current color state from b2dSetColor and alpha from b2dSetAlpha.
Rectangle rendering: outline mode (fill=0 draws 4-line perimeter only), filled mode (fill=1 draws solid rectangle using 2 triangles), position is top-left corner (x,y specify anchor point), dimensions define size (width x height in pixels).
Use cases: (1) UI elements (buttons, panels, borders, health bars), (2) Debug visualization (collision boxes, trigger areas, bounds), (3) Background elements (panels, overlays, masks), (4) Selection boxes (drag-select, highlighting, focus indicators).
Performance: filled rectangles are very fast (~0.005ms, 2 triangles), outlined rectangles slightly slower (~0.008ms, 4 lines), hardware accelerated GPU primitives, minimal CPU overhead.
Common patterns: filled panel = b2dSetColor(50,50,50): b2dDrawRect(x,y,200,100,1); outlined box = b2dSetColor(255,255,255): b2dDrawRect(x,y,150,80,0); transparent overlay = b2dSetAlpha(0.5): b2dDrawRect(0,0,screenW,screenH,1); health bar = b2dSetColor(255,0,0): b2dDrawRect(x,y,health*2,20,1).
Rectangle clipping: rectangles extending offscreen are clipped automatically by GPU, no manual bounds checking required, partial rectangles visible if partially offscreen.