Draws a straight line between two points.
Takes x1 (start X position in pixels, integer), y1 (start Y position in pixels, integer), x2 (end X position in pixels, integer), y2 (end Y position in pixels, integer).
Returns nothing.
2D Overlay
Parameters & Returns
Parameters
x1Int
y1Int
x2Int
y2Int
Returns
Void
Quick Summary
Draws a straight line between two points.
Takes x1 (start X position in pixels, integer), y1 (start Y position in pixels, integer), x2 (end X position in pixels, integer), y2 (end Y position in pixels, integer).
Returns nothing.
Technical Exegesis...
Draws a straight line between two points. Takes x1 (start X position in pixels, integer), y1 (start Y position in pixels, integer), x2 (end X position in pixels, integer), y2 (end Y position in pixels, integer). Returns nothing. Queues line draw command to deferred rendering buffer, executed during b3dRenderWorld. Uses current color state from b2dSetColor and alpha from b2dSetAlpha.
Draws a straight line between two points. Takes x1 (start X position in pixels, integer), y1 (start Y position in pixels, integer), x2 (end X position in pixels, integer), y2 (end Y position in pixels, integer). Returns nothing. Queues line draw command to deferred rendering buffer, executed during b3dRenderWorld. Uses current color state from b2dSetColor and alpha from b2dSetAlpha.
Line rendering: draws single-pixel-width line (width=1 pixel, antialiased), uses GPU line primitive (hardware accelerated), respects current color and alpha state, deferred rendering (queued not immediate).
Performance: very fast (~0.005ms per line), hardware accelerated GPU primitive, minimal CPU overhead, can draw thousands per frame.
Common patterns: horizontal line = b2dDrawLine(x, y, x+100, y); vertical line = b2dDrawLine(x, y, x, y+100); diagonal line = b2dDrawLine(x1, y1, x2, y2); colored line = b2dSetColor(255,0,0): b2dDrawLine(x1, y1, x2, y2); transparent line = b2dSetAlpha(0.5): b2dDrawLine(x1, y1, x2, y2).
Line clipping: lines extending offscreen are clipped automatically by GPU, no manual bounds checking required, partial lines visible if one endpoint offscreen.
Related: b2dSetColor sets line color, b2dSetAlpha sets line transparency, b2dDrawRect draws rectangle outline (4 lines), b2dDrawCircle draws circle outline (many line segments).