-
Notifications
You must be signed in to change notification settings - Fork 2
Raylib_Types
Many raylib functions accept or return structured data such as colors, vectors, and rectangles. This page documents how each type is represented in MiniScript.
Some types (like Color and Vector2) are value types: simple maps you can construct by hand, or even supply as a list. Others (like Image and Texture) are handle types: opaque maps returned by raylib that wrap a native pointer. You read their properties but should not construct them yourself.
Handle type returned by raylib.LoadAudioStream and related functions.
| Property | Type | Description |
|---|---|---|
sampleRate |
number | Sample rate in Hz |
sampleSize |
number | Bits per sample (8, 16, 32) |
channels |
number | Number of channels (1 = mono, 2 = stereo) |
A 3D axis-aligned bounding box. Always represented as a map:
| Property | Type | Description |
|---|---|---|
min |
Vector3 | Minimum corner |
max |
Vector3 | Maximum corner |
Example:
box = {"min": {"x":-1,"y":-1,"z":-1}, "max": {"x":1,"y":1,"z":1}}
A 3D camera. Represented as a map. Raylib functions return a full map; you can pass one in the same form.
| Property | Type | Description |
|---|---|---|
position |
Vector3 | Camera position |
target |
Vector3 | Look-at point |
up |
Vector3 | Up direction (usually {x:0,y:1,z:0}) |
fovy |
number | Vertical field-of-view in degrees |
projection |
number |
CAMERA_PERSPECTIVE (0) or CAMERA_ORTHOGRAPHIC (1) |
For position, target, and up, you may supply either a nested Vector3 map/list or flat scalar fields: positionX, positionY, positionZ (and likewise for target and up). Raylib functions return both forms, so you can use whichever is more convenient.
Example:
cam = {}
cam.position = [0, 10, 10]
cam.target = [0, 0, 0]
cam.up = [0, 1, 0]
cam.fovy = 45
cam.projection = raylib.CAMERA_PERSPECTIVE
Colors are accepted in three formats, giving you flexibility when passing a color to any raylib function. Raylib functions that return a color always return a map.
"#RRGGBB" — six hex digits, alpha defaults to 255.
"#RRGGBBAA" — eight hex digits, explicit alpha.
raylib.ClearBackground "#3070A0"
raylib.ClearBackground "#3070A080" // 50% transparent
A 3- or 4-element list [r, g, b] or [r, g, b, a], with each component 0–255. Alpha defaults to 255 if omitted.
raylib.DrawPixel 100, 100, [255, 0, 0] // red
raylib.DrawPixel 100, 100, [255, 0, 0, 128] // semi-transparent red
A map with r, g, b, and optionally a keys (0–255). a defaults to 255 if omitted.
red = {"r": 255, "g": 0, "b": 0, "a": 255}
This is also the format returned by raylib functions such as raylib.GetColor.
Handle type returned by raylib.LoadFont and related functions.
| Property | Type | Description |
|---|---|---|
texture |
Texture | Atlas texture for the font glyphs |
baseSize |
number | Base size of glyphs (in pixels) |
glyphCount |
number | Number of glyph records |
glyphPadding |
number | Padding applied around each glyph |
Handle type returned by raylib.LoadImage, raylib.GenImageColor, etc. The pixel data is managed natively; use image functions to manipulate it.
| Property | Type | Description |
|---|---|---|
width |
number | Image width in pixels |
height |
number | Image height in pixels |
mipmaps |
number | Mipmap level count |
format |
number | Pixel format constant (e.g. PIXELFORMAT_UNCOMPRESSED_R8G8B8A8) |
Handle type returned by raylib.LoadMaterials and related functions.
| Property | Type | Description |
|---|---|---|
shaderId |
number | ID of the material's shader |
A 4×4 floating-point matrix. Accepted in multiple formats; raylib functions always return a nested-list map.
A flat 16-element list in column-major order (matching raylib's internal m0–m15 layout):
m = [m0, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12, m13, m14, m15]
A list of 4 rows, each a list of 4 values. This is also what raylib returns.
m = [[1,0,0,0], [0,1,0,0], [0,0,1,0], [0,0,0,1]] // identity
A map with fields m0 through m15:
m = {"m0":1, "m5":1, "m10":1, "m15":1, ...}
Raylib functions return a map with three fields:
| Property | Type | Description |
|---|---|---|
rows |
number | Always 4 |
columns |
number | Always 4 |
elem |
list | List of 4 rows, each a list of 4 numbers (row-major) |
Handle type returned by raylib.GenMesh* and raylib.LoadModel (indirectly).
| Property | Type | Description |
|---|---|---|
vertexCount |
number | Number of vertices |
triangleCount |
number | Number of triangles |
Handle type returned by raylib.LoadModel and related functions.
| Property | Type | Description |
|---|---|---|
meshCount |
number | Number of meshes in the model |
materialCount |
number | Number of materials in the model |
Handle type returned by raylib.LoadModelAnimations.
| Property | Type | Description |
|---|---|---|
name |
string | Animation name |
boneCount |
number | Number of bones |
keyframeCount |
number | Number of keyframes |
Handle type returned by raylib.LoadMusicStream and related functions.
| Property | Type | Description |
|---|---|---|
frameCount |
number | Total number of frames in the stream |
looping |
number | 1 if looping is enabled, 0 otherwise |
A quaternion is represented identically to Vector4 — either a list [x, y, z, w] or a map {x, y, z, w}. Raylib functions return a map.
A 3D ray with an origin and a direction. Represented as a map:
| Property | Type | Description |
|---|---|---|
position |
Vector3 | Ray origin (also accepted as origin) |
direction |
Vector3 | Ray direction (should be normalized) |
Raylib functions return a map using position (not origin), but origin is accepted as an alias when passing a ray in.
Returned by raylib.GetRayCollision* functions. Always a map:
| Property | Type | Description |
|---|---|---|
hit |
number | 1 if collision occurred, 0 otherwise |
distance |
number | Distance from ray origin to collision point |
point |
Vector3 | World-space collision point |
normal |
Vector3 | Surface normal at collision point |
A 2D rectangle. Accepted as a list or a map; raylib functions return a map.
[x, y, width, height]
rect = [10, 20, 200, 100]
rect = {"x": 10, "y": 20, "width": 200, "height": 100}
This is also the format returned by raylib functions.
Handle type returned by raylib.LoadRenderTexture.
| Property | Type | Description |
|---|---|---|
id |
number | OpenGL framebuffer object ID |
texture |
Texture | Color attachment texture |
Handle type returned by raylib.LoadShader and raylib.LoadShaderFromMemory.
| Property | Type | Description |
|---|---|---|
id |
number | OpenGL shader program ID |
Handle type returned by raylib.LoadSound and related functions.
| Property | Type | Description |
|---|---|---|
frameCount |
number | Total number of frames in the sound |
Handle type returned by raylib.LoadTexture, raylib.LoadTextureFromImage, etc.
| Property | Type | Description |
|---|---|---|
id |
number | OpenGL texture ID |
width |
number | Texture width in pixels |
height |
number | Texture height in pixels |
mipmaps |
number | Mipmap level count |
format |
number | Pixel format constant |
A 2D vector. Accepted as a list or a map; raylib functions return a map.
[x, y]
pos = [320, 240]
pos = {"x": 320, "y": 240}
This is also the format returned by functions such as raylib.GetMousePosition.
A 3D vector. Accepted as a list or a map; raylib functions return a map.
[x, y, z]
v = [1, 0, 0]
v = {"x": 1, "y": 0, "z": 0}
This is also the format returned by functions such as raylib.Vector3Add.
A 4D vector (also used for Quaternion). Accepted as a list or a map; raylib functions return a map.
[x, y, z, w]
v = {"x": 0, "y": 0, "z": 0, "w": 1}
Handle type returned by raylib.LoadWave and related functions.
| Property | Type | Description |
|---|---|---|
frameCount |
number | Total number of audio frames |
sampleRate |
number | Sample rate in Hz |
sampleSize |
number | Bits per sample |
channels |
number | Number of channels |