Camera2D Module
Helper functions for 2D Cameras (Orthographic projection).
Use these for top-down, side-scrolling, or any 2D game rendering.
The raylib Camera2D is a native mutable struct. The read-only helpers
(viewportBounds/screenToWorld/worldToScreen) take it by inref
(no copy, use &camera at the call site), the movement helpers
(smoothFollow/clampTarget) take it by byref and mutate it in place,
and the config builders take it by value (the camera is stored in the config regardless).
Functions and values
| Function or value |
Description
|
Full Usage:
clampTarget camera minX minY maxX maxY
Parameters:
byref<Camera2D>
-
Passed by reference (&camera) 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.
|
|
|
|
Create a rendering config from a 2D camera. Defaults: fullscreen, no clear.
|
|
|
|
|
Full Usage:
splitScreenBottom camera clearColor
Parameters: Returns: Camera2DConfig
Modifiers: inline |
Split-screen bottom half. Clears with given color.
|
|
Split-screen left half. Clears with given color.
|
Full Usage:
splitScreenRight camera clearColor
Parameters: Returns: Camera2DConfig
Modifiers: inline |
Split-screen right half. Clears with given color.
|
|
Split-screen top half. Clears with given color.
|
|
|
Full Usage:
withClear color config
Parameters:
Color
config : Camera2DConfig
Returns: Camera2DConfig
Modifiers: inline |
Clear with this color before rendering.
|
Full Usage:
withViewport viewport config
Parameters:
Rectangle
config : Camera2DConfig
Returns: Camera2DConfig
Modifiers: inline |
Set viewport in normalized screen coordinates (0-1).
|
|
Mibo