2D Drawing

Pixels, lines, circles, ellipses, rings, rectangles, triangles, polygons, splines + modes.

DRAW2D-01..16 reference

Every 2D primitive raylib exposes — pixels, lines, circles, ellipses, rings, rectangles, triangles, polygons, splines — plus the frame / camera / texture / shader / blend / scissor mode brackets.

Frame (DRAW2D-01)

Draw.begin() / Draw.end()

Category: Frame · raylib: BeginDrawing / EndDrawing

Bracket every frame's render commands. Draw.end presents the framebuffer.

Draw.begin()
Draw.clear(BLACK)
-- primitives here
Draw.end()

raylib cheatsheet · Iron source · Test usage

Modes (DRAW2D-02..06)

Draw.begin_mode_2d(camera: Camera) / end_mode_2d()

Category: Modes · raylib: BeginMode2D / EndMode2D

Apply a Camera2D view transform to subsequent 2D draws.

Draw.begin_mode_2d(cam2)
Draw.rectangle(10, 10, 50, 50, BLUE)
Draw.end_mode_2d()

raylib cheatsheet · Iron source · Test usage

Draw.begin_texture_mode(target: RenderTexture) / end_texture_mode()

Category: Modes · raylib: BeginTextureMode / EndTextureMode

Route subsequent draws to an offscreen RenderTexture. Core pattern for post-FX pipelines.

Draw.begin_texture_mode(rt)
Draw.clear(RAYWHITE)
Draw.end_texture_mode()

raylib cheatsheet · Iron source · Test usage

Draw.begin_shader_mode(shader: Shader) / end_shader_mode()

Category: Modes · raylib: BeginShaderMode / EndShaderMode

Subsequent draws go through shader's fragment stage. See Shaders.

Draw.begin_shader_mode(fx)
Texture.draw_rec(rt.texture, src_rec, pos, WHITE)
Draw.end_shader_mode()

raylib cheatsheet · Iron source · Test usage

Draw.begin_blend_mode(mode: BlendMode) / end_blend_mode()

Category: Modes · raylib: BeginBlendMode / EndBlendMode

Switch fragment blending for subsequent draws. See BlendMode.

Draw.begin_blend_mode(BlendMode.ADDITIVE)
Draw.circle(100, 100, Float32(50.0), RED)
Draw.end_blend_mode()

raylib cheatsheet · Iron source · Test usage

Draw.begin_scissor_mode(x, y, w, h: Int32) / end_scissor_mode()

Category: Modes · raylib: BeginScissorMode / EndScissorMode

Clip subsequent draws to a rectangular scissor window.

Draw.begin_scissor_mode(Int32(50), Int32(50), Int32(200), Int32(200))
Draw.end_scissor_mode()

raylib cheatsheet · Iron source · Test usage

Pixels (DRAW2D-07)

Draw.pixel(x, y, color) / pixel_v(position: Vector2, color)

Category: Pixels · raylib: DrawPixel / DrawPixelV

Single-pixel plot. Slow at scale — use textures for bulk plots.

Draw.pixel(Int32(10), Int32(10), RED)

raylib cheatsheet · Iron source · Test usage

Lines (DRAW2D-08)

Draw.line(x1, y1, x2, y2: Int32, color: Color)

Category: Lines · raylib: DrawLine

1px line between two integer points.

Draw.line(400, 0, 400, 600, divider)  -- pong center divider

raylib cheatsheet · Iron source · Test usage

Draw.line_v / line_ex / line_bezier / line_strip

Category: Lines · raylib: DrawLineV / Ex / Bezier / Strip

Vector2 endpoints (line_v); thickness (line_ex); Bezier curve (line_bezier); connected polyline from array (line_strip).

Draw.line_ex(start, finish, Float32(3.0), BLACK)

raylib cheatsheet · Iron source · Test usage

Circles (DRAW2D-09)

Draw.circle_sector / circle_sector_lines / circle_gradient / circle_v / circle_lines / circle_lines_v

Category: Circles · raylib: DrawCircleSector / ...Gradient / ...Lines

Sectors (pie slices); radial gradient; Vector2-center variants; outline-only variants.

Draw.circle_lines(Int32(400), Int32(300), Float32(20.0), WHITE)

raylib cheatsheet · Iron source · Test usage

Ellipses (DRAW2D-10)

Draw.ellipse(cx, cy: Int32, rh, rv: Float32, color) / ellipse_lines

Category: Ellipses · raylib: DrawEllipse / DrawEllipseLines

Filled + outlined ellipse.

Draw.ellipse(Int32(200), Int32(200), Float32(40.0), Float32(20.0), BLUE)

raylib cheatsheet · Iron source · Test usage

Rings (DRAW2D-11)

Draw.ring(center, inner, outer, start, end, segments, color) / ring_lines

Category: Rings · raylib: DrawRing / DrawRingLines

Annulus sector with explicit inner/outer radii + angular range. Great for progress meters.

Draw.ring(center, Float32(30.0), Float32(50.0), Float32(0.0), Float32(270.0), Int32(64), GREEN)

raylib cheatsheet · Iron source · Test usage

Rectangles (DRAW2D-12)

Draw.rectangle(x, y, w, h: Int32, color: Color)

Category: Rectangles · raylib: DrawRectangle

Filled axis-aligned rectangle — the workhorse of 2D games.

Draw.rectangle(0, 250, 10, 100, fg)  -- pong paddle

raylib cheatsheet · Iron source · Test usage

Draw.rectangle_v / rectangle_rec / rectangle_pro

Category: Rectangles · raylib: DrawRectangleV / Rec / Pro

Vector2 position/size (_v); Rectangle input (_rec); origin + rotation (_pro).

Draw.rectangle_rec(paddle, fg)

raylib cheatsheet · Iron source · Test usage

Draw.rectangle_gradient_v / _h / _ex

Category: Rectangles · raylib: DrawRectangleGradient*

Two-color vertical gradient (_v); horizontal (_h); 4-corner (_ex). UI background primitive.

Draw.rectangle_gradient_v(0, 0, 800, 600, SKYBLUE, DARKBLUE)

raylib cheatsheet · Iron source · Test usage

Draw.rectangle_lines / lines_ex

Category: Rectangles · raylib: DrawRectangleLines / LinesEx

Outline-only rectangle. lines_ex takes a Rectangle + line thickness.

Draw.rectangle_lines_ex(paddle, Float32(2.0), WHITE)

raylib cheatsheet · Iron source · Test usage

Draw.rectangle_rounded / _rounded_lines / _rounded_lines_ex

Category: Rectangles · raylib: DrawRectangleRounded*

Rounded corners + configurable segments. UI button primitive.

Draw.rectangle_rounded(btn, Float32(0.3), Int32(8), ORANGE)

raylib cheatsheet · Iron source · Test usage

Triangles (DRAW2D-13)

Draw.triangle(v1, v2, v3: Vector2, color) / triangle_lines

Category: Triangles · raylib: DrawTriangle / DrawTriangleLines

Single filled / outlined triangle. Winding matters for fill (CCW).

Draw.triangle(p1, p2, p3, GREEN)

raylib cheatsheet · Iron source · Test usage

Draw.triangle_fan / triangle_strip(points: [Vector2], count, color)

Category: Triangles · raylib: DrawTriangleFan / Strip

Batched triangulation from a point list: fan (common-vertex) or strip (alternating).

Draw.triangle_fan(points, Int32(points.length), BLUE)

raylib cheatsheet · Iron source · Test usage

Polygons (DRAW2D-14)

Draw.poly(center: Vector2, sides: Int32, r, rotation: Float32, color)

Category: Polygons · raylib: DrawPoly

Regular n-gon. 3 sides = triangle, 6 = hexagon, etc.

Draw.poly(center, Int32(6), Float32(40.0), Float32(0.0), PURPLE)

raylib cheatsheet · Iron source · Test usage

Draw.poly_lines / poly_lines_ex

Category: Polygons · raylib: DrawPolyLines / LinesEx

Outline-only regular n-gon; _ex accepts line thickness.

Draw.poly_lines_ex(center, Int32(6), Float32(40.0), Float32(0.0), Float32(2.0), WHITE)

raylib cheatsheet · Iron source · Test usage

Splines (DRAW2D-15)

Draw.spline_segment_linear / _basis / _catmull_rom / _bezier_quadratic / _bezier_cubic

Category: Splines · raylib: DrawSplineSegment*

Single-segment spline draws. Basis + Catmull-Rom need 4 points; quadratic needs 3; cubic needs 4.

Draw.spline_segment_bezier_cubic(p1, c2, c3, p4, Float32(2.0), RED)

raylib cheatsheet · Iron source · Test usage

Draw.spline_linear / spline_basis / spline_catmull_rom / spline_bezier_quadratic / spline_bezier_cubic(points: [Vector2], ...)

Category: Splines · raylib: DrawSpline*

Full-curve splines from a point list — raylib handles the segment chaining.

Draw.spline_catmull_rom(waypoints, Int32(waypoints.length), Float32(2.0), GREEN)

raylib cheatsheet · Iron source · Test usage

Draw.get_spline_point_linear / _basis / _catmull_rom / _bezier_quadratic / _bezier_cubic(..., t: Float32) -> Vector2

Category: Splines · raylib: GetSplinePoint*

Evaluate a spline at parametric t in [0, 1]. Useful for driving objects along a path.

val p = Draw.get_spline_point_bezier_cubic(p1, c2, c3, p4, Float32(0.5))

raylib cheatsheet · Iron source · Test usage

Text (DRAW2D-16)

See also