Draw.begin() / Draw.end()
Bracket every frame's render commands. Draw.end presents the framebuffer.
Draw.begin()
Draw.clear(BLACK)
-- primitives here
Draw.end()
Pixels, lines, circles, ellipses, rings, rectangles, triangles, polygons, splines + modes.
Every 2D primitive raylib exposes — pixels, lines, circles, ellipses, rings, rectangles, triangles, polygons, splines — plus the frame / camera / texture / shader / blend / scissor mode brackets.
Draw.begin() / Draw.end()Bracket every frame's render commands. Draw.end presents the framebuffer.
Draw.begin()
Draw.clear(BLACK)
-- primitives here
Draw.end()
Draw.clear(color: Color)Wipe the framebuffer to a solid color. Call inside Draw.begin / end.
Draw.clear(RAYWHITE)
Draw.begin_mode_2d(camera: Camera) / end_mode_2d()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()
Draw.begin_texture_mode(target: RenderTexture) / end_texture_mode()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()
Draw.begin_shader_mode(shader: Shader) / end_shader_mode()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()
Draw.begin_blend_mode(mode: BlendMode) / end_blend_mode()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()
Draw.begin_scissor_mode(x, y, w, h: Int32) / end_scissor_mode()Clip subsequent draws to a rectangular scissor window.
Draw.begin_scissor_mode(Int32(50), Int32(50), Int32(200), Int32(200))
Draw.end_scissor_mode()
Draw.pixel(x, y, color) / pixel_v(position: Vector2, color)Single-pixel plot. Slow at scale — use textures for bulk plots.
Draw.pixel(Int32(10), Int32(10), RED)
Draw.line(x1, y1, x2, y2: Int32, color: Color)1px line between two integer points.
Draw.line(400, 0, 400, 600, divider) -- pong center divider
Draw.line_v / line_ex / line_bezier / line_stripVector2 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)
Draw.circle(cx, cy: Int32, r: Float32, color: Color)Filled circle.
Draw.circle(Int32(400), Int32(300), Float32(20.0), YELLOW)
Draw.circle_sector / circle_sector_lines / circle_gradient / circle_v / circle_lines / circle_lines_vSectors (pie slices); radial gradient; Vector2-center variants; outline-only variants.
Draw.circle_lines(Int32(400), Int32(300), Float32(20.0), WHITE)
Draw.ellipse(cx, cy: Int32, rh, rv: Float32, color) / ellipse_linesFilled + outlined ellipse.
Draw.ellipse(Int32(200), Int32(200), Float32(40.0), Float32(20.0), BLUE)
Draw.ring(center, inner, outer, start, end, segments, color) / ring_linesAnnulus 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)
Draw.rectangle(x, y, w, h: Int32, color: Color)Filled axis-aligned rectangle — the workhorse of 2D games.
Draw.rectangle(0, 250, 10, 100, fg) -- pong paddle
Draw.rectangle_v / rectangle_rec / rectangle_proVector2 position/size (_v); Rectangle input (_rec); origin + rotation (_pro).
Draw.rectangle_rec(paddle, fg)
Draw.rectangle_gradient_v / _h / _exTwo-color vertical gradient (_v); horizontal (_h); 4-corner (_ex). UI background primitive.
Draw.rectangle_gradient_v(0, 0, 800, 600, SKYBLUE, DARKBLUE)
Draw.rectangle_lines / lines_exOutline-only rectangle. lines_ex takes a Rectangle + line thickness.
Draw.rectangle_lines_ex(paddle, Float32(2.0), WHITE)
Draw.rectangle_rounded / _rounded_lines / _rounded_lines_exRounded corners + configurable segments. UI button primitive.
Draw.rectangle_rounded(btn, Float32(0.3), Int32(8), ORANGE)
Draw.triangle(v1, v2, v3: Vector2, color) / triangle_linesSingle filled / outlined triangle. Winding matters for fill (CCW).
Draw.triangle(p1, p2, p3, GREEN)
Draw.triangle_fan / triangle_strip(points: [Vector2], count, color)Batched triangulation from a point list: fan (common-vertex) or strip (alternating).
Draw.triangle_fan(points, Int32(points.length), BLUE)
Draw.poly(center: Vector2, sides: Int32, r, rotation: Float32, color)Regular n-gon. 3 sides = triangle, 6 = hexagon, etc.
Draw.poly(center, Int32(6), Float32(40.0), Float32(0.0), PURPLE)
Draw.poly_lines / poly_lines_exOutline-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)
Draw.spline_segment_linear / _basis / _catmull_rom / _bezier_quadratic / _bezier_cubicSingle-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)
Draw.spline_linear / spline_basis / spline_catmull_rom / spline_bezier_quadratic / spline_bezier_cubic(points: [Vector2], ...)Full-curve splines from a point list — raylib handles the segment chaining.
Draw.spline_catmull_rom(waypoints, Int32(waypoints.length), Float32(2.0), GREEN)
Draw.get_spline_point_linear / _basis / _catmull_rom / _bezier_quadratic / _bezier_cubic(..., t: Float32) -> Vector2Evaluate 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))
Draw.text(text: String, x, y, size: Int32, color: Color)Default font text draw. For loaded fonts + measurement, see Text reference.
Draw.text("Hello", Int32(200), Int32(280), Int32(24), WHITE)
Draw.fps(x: Int32, y: Int32)Shortcut for drawing the current FPS as text.
Draw.fps(Int32(10), Int32(10))
Texture.draw* family for sprite rendering.