Header menu logo Mibo.Raylib

Camera2D Module

Helper functions for 2D Cameras (Orthographic projection).

Use these for top-down, side-scrolling, or any 2D game rendering.

Functions and values

Function or value Description

clampTarget camera minX minY maxX maxY

Full Usage: clampTarget camera minX minY maxX maxY

Parameters:
    camera : byref<Camera2D> - Passed by reference so mutations are visible to the caller.
    minX : float32
    minY : float32
    maxX : float32
    maxY : float32

Modifiers: inline

Clamp the camera target to a world bounds rectangle.

camera : byref<Camera2D>

Passed by reference so mutations are visible to the caller.

minX : float32
minY : float32
maxX : float32
maxY : float32

create position zoom viewportSize

Full Usage: create position zoom viewportSize

Parameters:
Returns: Camera2D

Creates a raylib Camera2D centered on the given position.

position : Vector2
zoom : float32
viewportSize : Vector2
Returns: Camera2D

overlay camera bounds

Full Usage: overlay camera bounds

Parameters:
Returns: Camera2DConfig

Picture-in-picture overlay. Clears with black by default.

camera : Camera2D
bounds : Rectangle
Returns: Camera2DConfig

render camera

Full Usage: render camera

Parameters:
Returns: Camera2DConfig

Create a rendering config from a 2D camera. Defaults: fullscreen, no clear.

camera : Camera2D
Returns: Camera2DConfig

screenToWorld camera screenPos

Full Usage: screenToWorld camera screenPos

Parameters:
Returns: Vector2

Converts a screen position (pixels) to world position.

camera : Camera2D
screenPos : Vector2
Returns: Vector2

smoothFollow camera target speed

Full Usage: smoothFollow camera target speed

Parameters:
    camera : byref<Camera2D> - Passed by reference so mutations are visible to the caller.
    target : Vector2
    speed : float32

Modifiers: inline

Smoothly interpolate the camera target toward a world position.

camera : byref<Camera2D>

Passed by reference so mutations are visible to the caller.

target : Vector2
speed : float32

splitScreenBottom camera clearColor

Full Usage: splitScreenBottom camera clearColor

Parameters:
Returns: Camera2DConfig

Split-screen bottom half. Clears with given color.

camera : Camera2D
clearColor : Color
Returns: Camera2DConfig

splitScreenLeft camera clearColor

Full Usage: splitScreenLeft camera clearColor

Parameters:
Returns: Camera2DConfig

Split-screen left half. Clears with given color.

camera : Camera2D
clearColor : Color
Returns: Camera2DConfig

splitScreenRight camera clearColor

Full Usage: splitScreenRight camera clearColor

Parameters:
Returns: Camera2DConfig

Split-screen right half. Clears with given color.

camera : Camera2D
clearColor : Color
Returns: Camera2DConfig

splitScreenTop camera clearColor

Full Usage: splitScreenTop camera clearColor

Parameters:
Returns: Camera2DConfig

Split-screen top half. Clears with given color.

camera : Camera2D
clearColor : Color
Returns: Camera2DConfig

viewportBounds camera width height

Full Usage: viewportBounds camera width height

Parameters:
    camera : Camera2D
    width : float32
    height : float32

Returns: Rectangle

Calculates the visible world bounds for a raylib Camera2D.

camera : Camera2D
width : float32
height : float32
Returns: Rectangle

withClear color config

Full Usage: withClear color config

Parameters:
Returns: Camera2DConfig

Clear with this color before rendering.

color : Color
config : Camera2DConfig
Returns: Camera2DConfig

withViewport viewport config

Full Usage: withViewport viewport config

Parameters:
Returns: Camera2DConfig

Set viewport in normalized screen coordinates (0-1).

viewport : Rectangle
config : Camera2DConfig
Returns: Camera2DConfig

worldToScreen camera worldPos

Full Usage: worldToScreen camera worldPos

Parameters:
Returns: Vector2

Converts a world position to screen position (pixels).

camera : Camera2D
worldPos : Vector2
Returns: Vector2

Type something to start searching.