raylib

Raylib game development library bindings for Kit

Files

FileDescription
kit.tomlPackage manifest with metadata and dependencies
src/audio.kitSound and music loading and playback
src/camera.kit2D and 3D camera types and controls
src/collision.kitCollision detection for shapes
src/colors.kitColor constants and manipulation
src/core.kitWindow management and frame control
src/files.kitFile I/O for game assets
src/input.kitKeyboard, mouse, and gamepad input
src/keys.kitKeyboard and input constant definitions
src/models.kit3D model loading and rendering
src/raylib.kitMain module re-exporting all raylib APIs
src/rendering.kitBlend modes and render state management
src/shaders.kitShader loading and uniform management
src/shapes.kit2D shape drawing primitives
src/text.kitFont loading and text rendering
src/textures.kitTexture loading and drawing
src/types.kitCore types (Vector2, Rectangle, Color)
src/utils.kitVector math and rectangle utilities
tests/test-colors.kitTests for color packing and extraction
tests/test-keys.kitTests for input constant values
tests/test-utils.kitTests for vector and rectangle ops
LICENSEMIT license file

Architecture

FFI Structure

graph TD A[Kit Code] -->|import Raylib| B[src/raylib.kit] B --> C[core.kit] B --> D[rendering.kit] B --> E[audio.kit] B --> F[input.kit] B --> G[textures.kit] B --> H[models.kit] B --> I[shaders.kit] C -->|extern-zig| J[raylib C library] D --> J E --> J F --> J G --> J H --> J I --> J

Module Overview

graph LR subgraph Core A[Window] --> B[Timing] A --> C[Drawing] end subgraph Graphics D[Textures] --> E[Sprites] F[Shapes] --> G[2D Rendering] H[Models] --> I[3D Rendering] end subgraph Input J[Keyboard] K[Mouse] L[Gamepad] end subgraph Audio M[Sound] N[Music] end

Dependencies

No Kit package dependencies.

Installation

kit add gitlab.com/kit-lang/packages/kit-raylib.git

Usage

import Kit.Raylib

License

MIT License - see LICENSE for details.

Exported Functions & Types

pack-color

Int -> Int -> Int -> Int -> Int

color

Create custom color from RGBA values (0-255)

Int -> Int -> Int -> Int -> Int

rgb

Create color from RGB values with full opacity (alpha = 255)

Int -> Int -> Int -> Int

color-alpha

Extract alpha channel from a packed color (0-255)

Int -> Int

color-red

Extract red channel from a packed color (0-255)

Int -> Int

color-green

Extract green channel from a packed color (0-255)

Int -> Int

color-blue

Extract blue channel from a packed color (0-255)

Int -> Int

color-with-alpha

Create a new color with modified alpha (0-255)

Int -> Int -> Int

color-lerp

Interpolate between two colors based on t (0.0 to 1.0) t=0.0 returns start-color, t=1.0 returns end-color

Int -> Int -> Float -> Int

fade

Apply alpha to a color (0.0 = fully transparent, 1.0 = fully opaque)

Int -> Float -> Int

color-alpha-blend

Apply alpha to color (0.0 to 1.0)

Int -> Float -> Int

blend-alpha

Alpha blend two colors with tint

Int -> Int -> Int -> Int

color-brightness

Adjust brightness of a color (-1.0 to 1.0)

Int -> Float -> Int

color-contrast

Adjust contrast of a color (-1.0 to 1.0)

Int -> Float -> Int

color-tint

Apply tint to a color

Int -> Int -> Int

color-from-hsv

Create color from HSV values (hue: 0-360, saturation: 0-1, value: 0-1)

Float -> Float -> Float -> Int

color-to-int

Convert color to integer

Int -> Int

color-lerp-raylib

Interpolate between two colors using Raylib (factor: 0.0 to 1.0)

Int -> Int -> Float -> Int

get-color

Get color from hex value (e.g., 0xFF0000FF for red)

Int -> Int

draw-pixel

Int -> Int -> Int -> Void

draw-line

Int -> Int -> Int -> Int -> Int -> Void

draw-line-ex

Float -> Float -> Float -> Float -> Float -> Int -> Void

draw-line-bezier

Float -> Float -> Float -> Float -> Float -> Int -> Void

draw-circle

Int -> Int -> Float -> Int -> Void

draw-circle-v

Float -> Float -> Float -> Int -> Void

draw-circle-lines

Int -> Int -> Float -> Int -> Void

draw-circle-sector

Float -> Float -> Float -> Float -> Float -> Int -> Int -> Void

draw-circle-sector-lines

Float -> Float -> Float -> Float -> Float -> Int -> Int -> Void

draw-ellipse

Int -> Int -> Float -> Float -> Int -> Void

draw-ellipse-lines

Int -> Int -> Float -> Float -> Int -> Void

draw-ring

Float -> Float -> Float -> Float -> Float -> Float -> Int -> Int -> Void

draw-ring-lines

Float -> Float -> Float -> Float -> Float -> Float -> Int -> Int -> Void

draw-rectangle

Int -> Int -> Int -> Int -> Int -> Void

draw-rectangle-v

Float -> Float -> Float -> Float -> Int -> Void

draw-rectangle-lines

Int -> Int -> Int -> Int -> Int -> Void

draw-rectangle-lines-ex

Float -> Float -> Float -> Float -> Float -> Int -> Void

draw-rectangle-pro

Float -> Float -> Float -> Float -> Float -> Float -> Float -> Int -> Void

draw-rectangle-rounded

Float -> Float -> Float -> Float -> Float -> Int -> Int -> Void

draw-rectangle-rounded-lines

Float -> Float -> Float -> Float -> Float -> Int -> Int -> Void

draw-rectangle-rounded-lines-ex

Float -> Float -> Float -> Float -> Float -> Int -> Float -> Int -> Void

draw-triangle

Float -> Float -> Float -> Float -> Float -> Float -> Int -> Void

draw-triangle-lines

Float -> Float -> Float -> Float -> Float -> Float -> Int -> Void

draw-poly

Float -> Float -> Int -> Float -> Float -> Int -> Void

draw-poly-lines

Float -> Float -> Int -> Float -> Float -> Int -> Void

draw-poly-lines-ex

Float -> Float -> Int -> Float -> Float -> Float -> Int -> Void

draw-rectangle-gradient-h

Int -> Int -> Int -> Int -> Int -> Int -> Void

draw-rectangle-gradient-v

Int -> Int -> Int -> Int -> Int -> Int -> Void

draw-rectangle-gradient-ex

Int -> Int -> Int -> Int -> Int -> Int -> Int -> Int -> Void

draw-circle-gradient

Int -> Int -> Float -> Int -> Int -> Void

draw-fps

Int -> Int -> Void

draw-line-3d

Float -> Float -> Float -> Float -> Float -> Float -> Int -> Void

draw-point-3d

Float -> Float -> Float -> Int -> Void

draw-circle-3d

Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Int -> Void

draw-triangle-3d

Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Int -> Void

draw-cube

Float -> Float -> Float -> Float -> Float -> Float -> Int -> Void

draw-cube-wires

Float -> Float -> Float -> Float -> Float -> Float -> Int -> Void

draw-sphere

Float -> Float -> Float -> Float -> Int -> Void

draw-sphere-ex

Float -> Float -> Float -> Float -> Int -> Int -> Int -> Void

draw-sphere-wires

Float -> Float -> Float -> Float -> Int -> Int -> Int -> Void

draw-cylinder

Float -> Float -> Float -> Float -> Float -> Float -> Int -> Int -> Void

draw-cylinder-wires

Float -> Float -> Float -> Float -> Float -> Float -> Int -> Int -> Void

draw-capsule

Float -> Float -> Float -> Float -> Float -> Float -> Float -> Int -> Int -> Int -> Void

draw-capsule-wires

Float -> Float -> Float -> Float -> Float -> Float -> Float -> Int -> Int -> Int -> Void

draw-plane

Float -> Float -> Float -> Float -> Float -> Int -> Void

draw-grid

Int -> Float -> Void

draw-bounding-box

Float -> Float -> Float -> Float -> Float -> Float -> Int -> Void

load-model

String -> Ptr

unload-model

Ptr -> Void

is-model-valid?

Ptr -> Bool

draw-model

Ptr -> Float -> Float -> Float -> Float -> Int -> Void

draw-model-ex

Ptr -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Int -> Void

draw-model-wires

Ptr -> Float -> Float -> Float -> Float -> Int -> Void

draw-model-wires-ex

Ptr -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Int -> Void

draw-model-points

Ptr -> Float -> Float -> Float -> Float -> Int -> Void

draw-model-points-ex

Ptr -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Int -> Void

get-model-mesh-count

Ptr -> Int

get-model-material-count

Ptr -> Int

get-model-bone-count

Ptr -> Int

gen-mesh-poly

Int -> Float -> Ptr

gen-mesh-plane

Float -> Float -> Int -> Int -> Ptr

gen-mesh-cube

Float -> Float -> Float -> Ptr

gen-mesh-sphere

Float -> Int -> Int -> Ptr

gen-mesh-hemisphere

Float -> Int -> Int -> Ptr

gen-mesh-cylinder

Float -> Float -> Int -> Ptr

gen-mesh-cone

Float -> Float -> Int -> Ptr

gen-mesh-torus

Float -> Float -> Int -> Int -> Ptr

gen-mesh-knot

Float -> Float -> Int -> Int -> Ptr

gen-mesh-heightmap

Ptr -> Float -> Float -> Float -> Ptr

gen-mesh-cubicmap

Ptr -> Float -> Ptr

unload-mesh

Ptr -> Void

export-mesh?

Ptr -> String -> Bool

load-model-from-mesh

Ptr -> Ptr

upload-mesh

Ptr -> Bool -> Void

gen-mesh-tangents

Ptr -> Void

update-model-animation

Ptr -> Ptr -> Int -> Int -> Void

update-model-animation-bones

Ptr -> Ptr -> Int -> Int -> Void

unload-model-animation

Ptr -> Int -> Void

unload-model-animations

Ptr -> Void

is-model-animation-valid?

Ptr -> Ptr -> Int -> Bool

get-model-animation-frame-count

Ptr -> Int -> Int

get-model-animation-bone-count

Ptr -> Int -> Int

load-material-default

Ptr

is-material-valid?

Ptr -> Bool

unload-material

Ptr -> Void

set-material-texture

Ptr -> Int -> Ptr -> Void

set-model-mesh-material

Ptr -> Int -> Int -> Void

draw-billboard

Ptr -> Ptr -> Float -> Float -> Float -> Float -> Int -> Void

draw-billboard-rec

Ptr -> Ptr -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Int -> Void

draw-billboard-pro

Ptr -> Ptr -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Int -> Void

check-collision-spheres?

Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Bool

check-collision-box-sphere?

Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Bool

check-collision-boxes?

Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Bool

create-ray

Float -> Float -> Float -> Float -> Float -> Float -> Ptr

unload-ray

Ptr -> Void

get-screen-to-world-ray

Int -> Int -> Ptr -> Ptr

get-screen-to-world-ray-ex

Int -> Int -> Ptr -> Int -> Int -> Ptr

get-ray-collision-sphere

Ptr -> Float -> Float -> Float -> Float -> Ptr

get-ray-collision-box

Ptr -> Float -> Float -> Float -> Float -> Float -> Float -> Ptr

get-ray-collision-mesh

Ptr -> Ptr -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Ptr

get-ray-collision-triangle

Ptr -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Ptr

get-ray-collision-quad

Ptr -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Ptr

unload-ray-collision

Ptr -> Void

ray-collision-hit?

Ptr -> Bool

ray-collision-distance

Ptr -> Float

ray-collision-point-x

Ptr -> Float

ray-collision-point-y

Ptr -> Float

ray-collision-point-z

Ptr -> Float

ray-collision-normal-x

Ptr -> Float

ray-collision-normal-y

Ptr -> Float

ray-collision-normal-z

Ptr -> Float

begin-mode-2d

Float -> Float -> Float -> Float -> Float -> Float -> Void

end-mode-2d

Void

begin-mode-3d

Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Int -> Void

end-mode-3d

Void

camera-perspective

Perspective projection (realistic depth perception)

camera-orthographic

Orthographic projection (no depth perspective, good for 2D-style 3D)

begin-blend-mode

Int -> Void

end-blend-mode

Void

blend-alpha

Blend textures considering alpha (default mode)

blend-additive

Blend textures adding colors (brightening effect)

blend-multiplied

Blend textures multiplying colors (darkening effect)

blend-add-colors

Blend textures adding colors (alternative implementation)

blend-subtract-colors

Blend textures subtracting colors

blend-alpha-premultiply

Blend premultiplied textures considering alpha

blend-custom

Blend textures using custom src/dst factors

begin-scissor-mode

Int -> Int -> Int -> Int -> Void

end-scissor-mode

Void

begin-shader-mode

{ptr: Ptr} -> Void

end-shader-mode

Void

Ray definition (origin point and direction vector)

Ray collision result data

check-collision-recs?

Check collision between two rectangles Returns true if the rectangles overlap

Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Bool

check-collision-circles?

Check collision between two circles Returns true if the circles overlap

Float -> Float -> Float -> Float -> Float -> Float -> Bool

check-collision-circle-rec?

Check collision between circle and rectangle Returns true if the circle and rectangle overlap

Float -> Float -> Float -> Float -> Float -> Float -> Float -> Bool

check-collision-point-rec?

Check if point is inside rectangle Returns true if the point is within the rectangle bounds

Float -> Float -> Float -> Float -> Float -> Float -> Bool

check-collision-point-circle?

Check if point is inside circle Returns true if the point is within the circle

Float -> Float -> Float -> Float -> Float -> Bool

check-collision-point-triangle?

Check if point is inside a triangle Returns true if the point is within the triangle defined by three vertices

Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Bool

check-collision-point-line?

Check if point is near a line (within threshold) Returns true if the point is within the specified threshold distance from the line

Float -> Float -> Float -> Float -> Float -> Float -> Int -> Bool

check-collision-circle-line?

Check collision between circle and line Returns true if the circle intersects with the line segment

Float -> Float -> Float -> Float -> Float -> Float -> Float -> Bool

check-collision-lines?

Check collision between two lines Returns true if the two line segments intersect

Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Bool

check-collision-spheres?

Check collision between two spheres Returns true if the spheres overlap

Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Bool

check-collision-box-sphere?

Check collision between bounding box and sphere Returns true if the box and sphere overlap

Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Bool

check-collision-boxes?

Check collision between two bounding boxes Returns true if the boxes overlap

Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Bool

create-ray

Create a ray from origin point and direction vector

Float -> Float -> Float -> Float -> Float -> Float -> {ptr: Ptr}

unload-ray

Unload ray from memory

{ptr: Ptr} -> Void

get-screen-to-world-ray

Get a ray trace from mouse position to 3D world Requires a 3D camera (record with ptr field)

Int -> Int -> {ptr: Ptr} -> Option {ptr: Ptr}

get-screen-to-world-ray-ex

Get a ray trace from mouse position to 3D world with custom viewport size Requires a 3D camera (record with ptr field)

Int -> Int -> {ptr: Ptr} -> Int -> Int -> Option {ptr: Ptr}

get-ray-collision-sphere

Get collision info between ray and sphere Returns None if no collision, Some(RayCollision) otherwise

{ptr: Ptr} -> Float -> Float -> Float -> Float -> Option {ptr: Ptr}

get-ray-collision-box

Get collision info between ray and bounding box Returns None if no collision, Some(RayCollision) otherwise

{ptr: Ptr} -> Float -> Float -> Float -> Float -> Float -> Float -> Option {ptr: Ptr}

get-ray-collision-mesh

Get collision info between ray and mesh with transform matrix Matrix is provided as 16 individual float values (column-major order) Returns None if no collision, Some(RayCollision) otherwise

{ptr: Ptr} -> Ptr -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Option {ptr: Ptr}

get-ray-collision-triangle

Get collision info between ray and triangle Triangle is defined by three 3D vertices Returns None if no collision, Some(RayCollision) otherwise

{ptr: Ptr} -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Option {ptr: Ptr}

get-ray-collision-quad

Get collision info between ray and quad Quad is defined by four 3D vertices Returns None if no collision, Some(RayCollision) otherwise

{ptr: Ptr} -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Option {ptr: Ptr}

unload-ray-collision

Unload ray collision result from memory

{ptr: Ptr} -> Void

ray-collision-hit?

Check if ray collision hit occurred Returns true if the ray hit the target

{ptr: Ptr} -> Bool

ray-collision-distance

Get ray collision distance from ray origin to hit point

{ptr: Ptr} -> Float

ray-collision-point

Get ray collision point coordinates as a record Returns {x: Float, y: Float, z: Float}

{ptr: Ptr} -> {x: Float, y: Float, z: Float}

ray-collision-normal

Get ray collision normal vector as a record Returns {x: Float, y: Float, z: Float}

{ptr: Ptr} -> {x: Float, y: Float, z: Float}

draw-bounding-box

Draw a bounding box with wireframe lines Box is defined by minimum and maximum corner points

Float -> Float -> Float -> Float -> Float -> Float -> Int -> Void

file-exists?

Check if file exists at the given path.

String -> Bool

if Files.file-exists? "saves/game.dat" then
  print "Save file found"

directory-exists?

Check if a directory exists at the given path.

String -> Bool

if Files.directory-exists? "assets/images" then
  print "Assets directory found"

is-file-extension?

Check if a file has the specified extension. Extension should include the dot (e.g., ".png", ".wav").

String -> String -> Bool

if Files.is-file-extension? "image.png" ".png" then
  print "PNG image found"

get-file-length

Get file length in bytes.

String -> Int

size = Files.get-file-length "data.bin"
print "File size: ${size} bytes"

get-file-extension

Get the file extension for a filename (includes the dot, e.g., ".png").

String -> String

ext = Files.get-file-extension "image.png"
# ext == ".png"

get-file-name

Get the filename from a full path string.

String -> String

name = Files.get-file-name "/path/to/image.png"
# name == "image.png"

get-file-name-without-ext

Get the filename without its extension.

String -> String

name = Files.get-file-name-without-ext "/path/to/image.png"
# name == "image"

get-directory-path

Get the directory path from a full file path.

String -> String

dir = Files.get-directory-path "/path/to/image.png"
# dir == "/path/to"

get-prev-directory-path

Get the parent directory path for a given path.

String -> String

parent = Files.get-prev-directory-path "/path/to/dir"
# parent == "/path/to"

get-working-directory

Get the current working directory.

String

cwd = Files.get-working-directory()
print "Working dir: ${cwd}"

get-application-directory

Get the directory of the running application.

String

app-dir = Files.get-application-directory()
print "App dir: ${app-dir}"

make-directory?

Create a new directory at the given path. Returns true on success.

String -> Bool

if Files.make-directory? "saves" then
  print "Directory created"

change-directory?

Change the current working directory. Returns true on success.

String -> Bool

if Files.change-directory? "/new/path" then
  print "Changed directory"

is-path-file?

Check if the given path points to a file (not a directory).

String -> Bool

if Files.is-path-file? "data.txt" then
  print "It's a file"

is-file-name-valid?

Check if a filename is valid for the current platform/OS.

String -> Bool

if Files.is-file-name-valid? "my:file.txt" then
  print "Valid filename"
else
  print "Invalid filename"

get-file-mod-time

Get file modification time (Unix timestamp).

String -> Int

mod-time = Files.get-file-mod-time "config.toml"

load-file-text

Load text content from a file.

String -> String

content = Files.load-file-text "story.txt"
print content

save-file-text?

Save text content to a file. Returns true on success.

String -> String -> Bool

if Files.save-file-text? "output.txt" "Hello, World!" then
  print "File saved"

set-random-seed

Set the seed for the random number generator. Use this for reproducible random sequences.

Int -> Void

Files.set-random-seed 12345
# Random values will now be deterministic

get-random-value

Get a random integer value between min and max (both inclusive).

Int -> Int -> Int

dice = Files.get-random-value 1 6
enemy-count = Files.get-random-value 3 10

load-random-sequence

Load a random sequence of unique values in the given range. The sequence contains 'count' unique values between min and max. No values are repeated in the sequence.

Int -> Int -> Int -> Ptr

# Generate 5 unique numbers between 1 and 10
seq = Files.load-random-sequence 5 1 10
# Use values...
Files.unload-random-sequence seq

unload-random-sequence

Unload a random sequence and free its memory.

Ptr -> Void

seq = Files.load-random-sequence 5 1 10
# Use sequence...
Files.unload-random-sequence seq

get-random-sequence-value

Get a value from a random sequence at the specified index.

Ptr -> Int -> Int

seq = Files.load-random-sequence 5 1 10
first = Files.get-random-sequence-value seq 0
second = Files.get-random-sequence-value seq 1
Files.unload-random-sequence seq

push-matrix

Push the current matrix onto the stack. Used to save the current transformation state.

Void

Files.push-matrix()
Files.translate 100.0 0.0 0.0
# Draw transformed objects...
Files.pop-matrix()  # Restore previous state

pop-matrix

Pop the latest matrix from the stack. Restores the previous transformation state.

Void

Files.push-matrix()
Files.rotate 45.0 0.0 0.0 1.0
# Draw rotated objects...
Files.pop-matrix()  # Back to original state

load-identity

Reset the current matrix to the identity matrix. Clears all transformations.

Void

Files.load-identity()
# Matrix is now reset to no transformation

translate

Apply a translation transformation to the current matrix.

Float -> Float -> Float -> Void

Files.push-matrix()
Files.translate 100.0 200.0 0.0  # Move right 100, down 200
# Draw at new position...
Files.pop-matrix()

rotate

Apply a rotation transformation to the current matrix. Angle is in degrees. The axis is specified by (x, y, z).

Float -> Float -> Float -> Float -> Void

Files.push-matrix()
Files.rotate 45.0 0.0 0.0 1.0  # Rotate 45 degrees around Z-axis
# Draw rotated objects...
Files.pop-matrix()

scale

Apply a scaling transformation to the current matrix.

Float -> Float -> Float -> Void

Files.push-matrix()
Files.scale 2.0 2.0 1.0  # Scale 2x in X and Y
# Draw scaled objects...
Files.pop-matrix()

close-audio

Close the audio device and context

Void

is-audio-ready?

Check if audio device has been initialized successfully

Bool

set-master-volume

Set master volume (listener) volume: 0.0 (mute) to 1.0 (full volume)

Float -> Void

get-master-volume

Get master volume (0.0 to 1.0)

Float

load-sound

Load sound from file

String -> Ptr

unload-sound

Unload sound from memory

Ptr -> Void

play-sound

Play a sound

Ptr -> Void

stop-sound

Stop playing a sound

Ptr -> Void

pause-sound

Pause a sound

Ptr -> Void

resume-sound

Resume a paused sound

Ptr -> Void

is-sound-playing?

Check if a sound is currently playing

Ptr -> Bool

set-sound-volume

Set volume for a sound (0.0 to 1.0)

Ptr -> Float -> Void

set-sound-pitch

Set pitch for a sound (1.0 is base pitch)

Ptr -> Float -> Void

set-sound-pan

Set pan for a sound (-1.0 left, 0.0 center, 1.0 right)

Ptr -> Float -> Void

load-sound-from-wave

Load sound from wave data

Ptr -> Ptr

load-music

Load music stream from file

String -> Ptr

unload-music

Unload music stream

Ptr -> Void

play-music

Start music playing

Ptr -> Void

stop-music

Stop music playing

Ptr -> Void

update-music

Updates buffers for music streaming Call this in your game loop to keep music playing

Ptr -> Void

pause-music

Pause music playing

Ptr -> Void

resume-music

Resume playing paused music

Ptr -> Void

is-music-playing?

Check if music is playing

Ptr -> Bool

seek-music

Seek music to a position (in seconds)

Ptr -> Float -> Void

seek-music-stream

Seek music stream to a position (in seconds) Alternate name for seek-music

Ptr -> Float -> Void

set-music-volume

Set volume for music (0.0 to 1.0)

Ptr -> Float -> Void

set-music-pitch

Set pitch for a music stream (1.0 is base pitch)

Ptr -> Float -> Void

set-music-pan

Set pan for a music stream (-1.0 left, 0.0 center, 1.0 right)

Ptr -> Float -> Void

get-music-time-length

Get music time length (in seconds)

Ptr -> Float

get-music-time-played

Get current music time played (in seconds)

Ptr -> Float

load-wave

Load wave data from file

String -> Ptr

is-wave-valid?

Check if wave data is valid

Ptr -> Bool

unload-wave

Unload wave data

Ptr -> Void

export-wave?

Export wave data to file Returns true on success

Ptr -> String -> Bool

wave-copy

Copy a wave to a new wave

Ptr -> Ptr

wave-crop

Crop a wave to defined frames range

Ptr -> Int -> Int -> Void

wave-format

Convert wave data to desired format sample-rate: Samples per second (e.g., 44100) sample-size: Bits per sample (e.g., 16) channels: Number of channels (1 = mono, 2 = stereo)

Ptr -> Int -> Int -> Int -> Void

load-audio-stream

Load audio stream (to stream raw audio data) sample-rate: Samples per second (e.g., 44100) sample-size: Bits per sample (e.g., 16) channels: Number of channels (1 = mono, 2 = stereo)

Int -> Int -> Int -> Ptr

is-audio-stream-valid?

Check if audio stream is valid

Ptr -> Bool

unload-audio-stream

Unload audio stream

Ptr -> Void

play-audio-stream

Play audio stream

Ptr -> Void

pause-audio-stream

Pause audio stream

Ptr -> Void

resume-audio-stream

Resume audio stream

Ptr -> Void

stop-audio-stream

Stop audio stream

Ptr -> Void

is-audio-stream-playing?

Check if audio stream is playing

Ptr -> Bool

is-audio-stream-processed?

Check if audio stream buffer has been processed (consumed)

Ptr -> Bool

set-audio-stream-volume

Set volume for audio stream (0.0 to 1.0)

Ptr -> Float -> Void

set-audio-stream-pitch

Set pitch for audio stream (1.0 is base pitch)

Ptr -> Float -> Void

set-audio-stream-pan

Set pan for audio stream (-1.0 left, 0.0 center, 1.0 right)

Ptr -> Float -> Void

load-shader

Load shader from vertex and fragment shader files Pass empty string for either to use the default shader

String -> String -> {ptr: Ptr}

load-shader-from-memory

Load shader from vertex and fragment shader code strings Pass empty string for either to use the default shader

String -> String -> {ptr: Ptr}

unload

Unload shader from GPU memory (VRAM)

{ptr: Ptr} -> Void

is-valid?

Check if a shader is valid (program exists in GPU)

{ptr: Ptr} -> Bool

get-location

Get shader uniform location by name Returns -1 if uniform not found

{ptr: Ptr} -> String -> Int

get-location-attrib

Get shader attribute location by name Returns -1 if attribute not found

{ptr: Ptr} -> String -> Int

set-value-float

Set shader uniform value (float)

{ptr: Ptr} -> Int -> Float -> Void

set-value-int

Set shader uniform value (int)

{ptr: Ptr} -> Int -> Int -> Void

set-value-vec2

Set shader uniform value (vec2)

{ptr: Ptr} -> Int -> Float -> Float -> Void

set-value-vec3

Set shader uniform value (vec3)

{ptr: Ptr} -> Int -> Float -> Float -> Float -> Void

set-value-vec4

Set shader uniform value (vec4)

{ptr: Ptr} -> Int -> Float -> Float -> Float -> Float -> Void

set-value-matrix

Set shader uniform value (4x4 matrix) Matrix values are in column-major order (OpenGL convention)

{ptr: Ptr} -> Int -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Void

set-value-texture

Set shader uniform value for texture sampler

{ptr: Ptr} -> Int -> Ptr -> Void

begin-mode

Begin custom shader drawing mode All subsequent draw calls will use this shader until end-mode is called

{ptr: Ptr} -> Void

end-mode

End custom shader drawing mode (returns to default shader)

Void

create-vr-device-info

Create VR device info with display parameters h-res, v-res: display resolution in pixels h-screen, v-screen: physical screen size in meters eye-dist: eye to screen distance in meters lens-sep: lens separation distance in meters ipd: interpupillary distance in meters

Int -> Int -> Float -> Float -> Float -> Float -> Float -> {ptr: Ptr}

set-vr-device-lens-distortion

Set VR device lens distortion coefficients d0, d1, d2, d3: distortion coefficients (k0, k1, k2, k3)

{ptr: Ptr} -> Float -> Float -> Float -> Float -> Void

set-vr-device-chroma-correction

Set VR device chromatic aberration correction coefficients c0, c1, c2, c3: chromatic correction coefficients (r, g, b, unused)

{ptr: Ptr} -> Float -> Float -> Float -> Float -> Void

unload-vr-device-info

Unload VR device info from memory

{ptr: Ptr} -> Void

load-vr-stereo-config

Load VR stereo configuration for specified device

{ptr: Ptr} -> {ptr: Ptr}

unload-vr-stereo-config

Unload VR stereo configuration from memory

{ptr: Ptr} -> Void

begin-vr-stereo-mode

Begin VR stereo rendering mode All subsequent draw calls will be rendered for both eyes until end-vr-stereo-mode is called

{ptr: Ptr} -> Void

end-vr-stereo-mode

End VR stereo rendering mode

Void

is-key-pressed?

Check if a key was pressed once (not held)

Int -> Bool

is-key-down?

Check if a key is being held down

Int -> Bool

is-key-released?

Check if a key was released once

Int -> Bool

is-key-up?

Check if a key is NOT being pressed

Int -> Bool

is-key-pressed-repeat?

Check if a key has been pressed again (key repeat)

Int -> Bool

get-key-pressed

Get the last key pressed (queue-based)

Int

get-char-pressed

Get the last character pressed (unicode, queue-based)

Int

set-exit-key

Set a custom key to exit the application (default is ESC)

Int -> Void

is-mouse-button-pressed?

Check if a mouse button was pressed once

Int -> Bool

is-mouse-button-down?

Check if a mouse button is being held down

Int -> Bool

is-mouse-button-released?

Check if a mouse button was released once

Int -> Bool

is-mouse-button-up?

Check if a mouse button is NOT being pressed

Int -> Bool

get-mouse-x

Get mouse position X

Int

get-mouse-y

Get mouse position Y

Int

get-mouse-position

Get mouse position as a record {x, y}

{x: Float, y: Float}

set-mouse-position

Set mouse position

Int -> Int -> Void

get-mouse-wheel

Get mouse wheel movement (vertical)

Float

get-mouse-wheel-move

Get mouse wheel movement (vertical) - alias

Float

get-mouse-wheel-move-x

Get mouse wheel horizontal movement

Float

get-mouse-wheel-move-y

Get mouse wheel vertical movement

Float

show-cursor

Show cursor

Void

hide-cursor

Hide cursor

Void

enable-cursor

Enable cursor (unlock cursor)

Void

disable-cursor

Disable cursor (lock cursor)

Void

is-cursor-hidden?

Check if cursor is hidden

Bool

is-cursor-on-screen?

Check if cursor is currently on the screen

Bool

set-mouse-cursor

Set mouse cursor type

Int -> Void

set-mouse-scale

Set mouse scaling (for high-DPI displays)

Float -> Float -> Void

set-mouse-offset

Set mouse offset (for virtual resolution)

Int -> Int -> Void

is-gamepad-available?

Check if a gamepad is connected

Int -> Bool

get-gamepad-name

Get internal name of the gamepad

Int -> String

is-gamepad-button-pressed?

Check if a gamepad button was pressed once

Int -> Int -> Bool

is-gamepad-button-down?

Check if a gamepad button is being held down

Int -> Int -> Bool

is-gamepad-button-released?

Check if a gamepad button was released once

Int -> Int -> Bool

is-gamepad-button-up?

Check if a gamepad button is NOT being pressed

Int -> Int -> Bool

get-gamepad-button-pressed

Get the last gamepad button pressed

Int

get-gamepad-axis-count

Get gamepad axis count for a gamepad

Int -> Int

get-gamepad-axis-movement

Get axis movement value for a gamepad axis (-1.0 to 1.0)

Int -> Int -> Float

set-gamepad-mappings

Set internal gamepad mappings (SDL_GameControllerDB)

String -> Int

set-gamepad-vibration

Set gamepad vibration for both motors (duration in seconds)

Int -> Float -> Float -> Float -> Void

get-touch-x

Get touch position X for first touch point

Int

get-touch-y

Get touch position Y for first touch point

Int

get-touch-point-id

Get touch point identifier for a given index

Int -> Int

get-touch-point-count

Get number of touch points

Int

get-touch-position

Get touch position for a given touch point index as a record {x, y}

Int -> {x: Float, y: Float}

set-gestures-enabled

Enable a set of gestures using gesture flags

Int -> Void

is-gesture-detected?

Check if a gesture has been detected

Int -> Bool

get-gesture-detected

Get latest detected gesture

Int

get-gesture-hold-duration

Get gesture hold time in seconds

Float

get-gesture-drag-angle

Get gesture drag angle

Float

get-gesture-pinch-angle

Get gesture pinch angle

Float

get-gesture-drag-vector

Get gesture drag vector as a record {x, y}

{x: Float, y: Float}

get-gesture-pinch-vector

Get gesture pinch vector as a record {x, y}

{x: Float, y: Float}

Color type with RGBA components (0-255 for each channel)

2D Vector with x and y components

Rectangle defined by position (x, y) and dimensions (width, height)

Texture loaded in GPU memory (VRAM)

Sound source loaded in memory

Music stream that can be played continuously

Font with associated base size for text rendering

Render texture for offscreen rendering

Image loaded in CPU memory (RAM)

Shader program for GPU rendering effects

2D Camera with offset, target, rotation and zoom

3D Camera with position, target, up vector, field of view and projection type

3D Model with meshes, materials and transform

Mesh vertex data for 3D rendering

run-game

Simple game loop helper init: initialization function called once at startup update: update function called each frame for game logic draw: draw function called each frame for rendering

(() -> a) -> (() -> b) -> (() -> c) -> Void

vec2

Create a 2D vector from x and y components

Float -> Float -> {x: Float, y: Float}

vec2-add

Add two 2D vectors component-wise

{x: Float, y: Float} -> {x: Float, y: Float} -> {x: Float, y: Float}

vec2-sub

Subtract vector b from vector a component-wise

{x: Float, y: Float} -> {x: Float, y: Float} -> {x: Float, y: Float}

vec2-scale

Scale a vector by a scalar value

{x: Float, y: Float} -> Float -> {x: Float, y: Float}

vec2-length

Calculate the length (magnitude) of a vector

{x: Float, y: Float} -> Float

vec2-normalize

Normalize a vector to unit length Returns the original vector if length is zero to avoid division by zero

{x: Float, y: Float} -> {x: Float, y: Float}

rect

Create a rectangle from position and dimensions

Float -> Float -> Float -> Float -> {x: Float, y: Float, width: Float, height: Float}

rect-contains?

Check if a point (px, py) is contained within a rectangle

{x: Float, y: Float, width: Float, height: Float} -> Float -> Float -> Bool

rects-overlap?

Check if two rectangles overlap (collision detection)

{x: Float, y: Float, width: Float, height: Float} -> {x: Float, y: Float, width: Float, height: Float} -> Bool

load-texture

String -> Ptr

unload-texture

Ptr -> Void

draw-texture

Ptr -> Int -> Int -> Int -> Void

draw-texture-ex

Ptr -> Float -> Float -> Float -> Float -> Int -> Void

texture-width

Ptr -> Int

texture-height

Ptr -> Int

draw-texture-rec

Ptr -> Float -> Float -> Float -> Float -> Float -> Float -> Int -> Void

draw-texture-pro

Ptr -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Int -> Void

gen-texture-mipmaps

Ptr -> Void

set-texture-filter

Ptr -> Int -> Void

set-texture-wrap

Ptr -> Int -> Void

load-render-texture

Int -> Int -> Ptr

unload-render-texture

Ptr -> Void

begin-texture-mode

Ptr -> Void

end-texture-mode

Void

render-texture-width

Ptr -> Int

render-texture-height

Ptr -> Int

load-image

String -> Ptr

unload-image

Ptr -> Void

is-image-valid?

Ptr -> Bool

image-width

Ptr -> Int

image-height

Ptr -> Int

export-image?

Ptr -> String -> Bool

image-copy

Ptr -> Ptr

image-from-image

Ptr -> Float -> Float -> Float -> Float -> Ptr

load-image-from-texture

Ptr -> Ptr

load-image-from-screen

Ptr

load-texture-from-image

Ptr -> Ptr

image-crop

Ptr -> Float -> Float -> Float -> Float -> Void

image-alpha-crop

Ptr -> Float -> Void

image-alpha-clear

Ptr -> Int -> Float -> Void

image-alpha-premultiply

Ptr -> Void

image-alpha-mask

Ptr -> Ptr -> Void

image-mipmaps

Ptr -> Void

image-dither

Ptr -> Int -> Int -> Int -> Int -> Void

image-resize-canvas

Ptr -> Int -> Int -> Int -> Int -> Int -> Void

image-format

Ptr -> Int -> Void

image-to-pot

Ptr -> Int -> Void

image-from-channel

Ptr -> Int -> Ptr

image-flip-vertical

Ptr -> Void

image-flip-horizontal

Ptr -> Void

image-rotate

Ptr -> Int -> Void

image-rotate-cw

Ptr -> Void

image-rotate-ccw

Ptr -> Void

image-resize

Ptr -> Int -> Int -> Void

image-resize-nn

Ptr -> Int -> Int -> Void

image-color-tint

Ptr -> Int -> Void

image-color-invert

Ptr -> Void

image-color-grayscale

Ptr -> Void

image-color-contrast

Ptr -> Float -> Void

image-color-brightness

Ptr -> Int -> Void

image-color-replace

Ptr -> Int -> Int -> Void

image-blur-gaussian

Ptr -> Int -> Void

gen-image-color

Int -> Int -> Int -> Ptr

gen-image-gradient-linear

Int -> Int -> Int -> Int -> Int -> Ptr

gen-image-gradient-radial

Int -> Int -> Float -> Int -> Int -> Ptr

gen-image-gradient-square

Int -> Int -> Float -> Int -> Int -> Ptr

gen-image-checked

Int -> Int -> Int -> Int -> Int -> Int -> Ptr

gen-image-white-noise

Int -> Int -> Float -> Ptr

gen-image-perlin-noise

Int -> Int -> Int -> Int -> Float -> Ptr

gen-image-cellular

Int -> Int -> Int -> Ptr

gen-image-text

Int -> Int -> String -> Ptr

image-text

String -> Int -> Int -> Ptr

image-text-ex

Ptr -> String -> Float -> Float -> Int -> Ptr

image-clear-background

Ptr -> Int -> Void

image-draw-pixel

Ptr -> Int -> Int -> Int -> Void

image-draw-line

Ptr -> Int -> Int -> Int -> Int -> Int -> Void

image-draw-circle

Ptr -> Int -> Int -> Int -> Int -> Void

image-draw-circle-lines

Ptr -> Int -> Int -> Int -> Int -> Void

image-draw-rectangle

Ptr -> Int -> Int -> Int -> Int -> Int -> Void

image-draw-rectangle-lines

Ptr -> Int -> Int -> Int -> Int -> Int -> Int -> Void

image-draw

Ptr -> Ptr -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Int -> Void

image-draw-text

Ptr -> String -> Int -> Int -> Int -> Int -> Void

image-draw-text-ex

Ptr -> Ptr -> String -> Float -> Float -> Float -> Float -> Int -> Void

image-draw-triangle

Ptr -> Float -> Float -> Float -> Float -> Float -> Float -> Int -> Void

image-draw-triangle-ex

Ptr -> Float -> Float -> Float -> Float -> Float -> Float -> Int -> Int -> Int -> Void

image-draw-triangle-lines

Ptr -> Float -> Float -> Float -> Float -> Float -> Float -> Int -> Void

draw-texture-n-patch

Ptr -> Int -> Int -> Int -> Int -> Int -> Int -> Int -> Int -> Int -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Int -> Void

filter-point

Point filtering (nearest neighbor), no anti-aliasing

filter-bilinear

Bilinear filtering for smooth anti-aliased text

filter-trilinear

Trilinear filtering (linear with mipmaps)

filter-anisotropic-4x

Anisotropic filtering 4x

filter-anisotropic-8x

Anisotropic filtering 8x

filter-anisotropic-16x

Anisotropic filtering 16x

draw-text

Draw text using the default font.

Parameters:

  • text - The string to draw
  • x - X position on screen (pixels)
  • y - Y position on screen (pixels)
  • font-size - Size of the font in pixels
  • color - Text color as an integer (use Raylib color functions)

String -> Int -> Int -> Int -> Int -> Void

draw-text "Hello, World!" 10 10 20 Raylib.white

measure-text

Measure the width of text using the default font.

Parameters:

  • text - The string to measure
  • font-size - Size of the font in pixels

Returns: Int - Width of the text in pixels

String -> Int -> Int

width = measure-text "Hello" 20

load-font

Load a font from file.

Supports TTF and other common font formats.

Parameters:

  • path - Path to the font file

Returns: Option Font - Some Font if loading succeeded, None if failed

String -> Option {ptr: Ptr, base-size: Int}

font = load-font "assets/myfont.ttf"
match font
  | Some f -> draw-text-ex f "Hello" 10 10 24.0 2.0 color
  | None -> print "Failed to load font"

load-font-ex

Load a font with specific size and glyph count.

Parameters:

  • path - Path to the font file
  • font-size - Desired font size (affects quality)
  • glyph-count - Number of glyphs to load (0 for default)

Returns: Option Font - Some Font if loading succeeded, None if failed

String -> Int -> Int -> Option {ptr: Ptr, base-size: Int}

font = load-font-ex "assets/myfont.ttf" 32 0

unload-font

Unload a font from memory.

Parameters:

  • font - The font to unload

{ptr: Ptr, base-size: Int} -> Void

unload-font font

font-base-size

Get the base size a font was loaded at.

Parameters:

  • font - The loaded font

Returns: Int - Base font size in pixels

{ptr: Ptr, base-size: Int} -> Int

size = font-base-size font

set-font-filter

Set texture filter for a font (for anti-aliasing).

Use filter-bilinear for smooth anti-aliased text.

Parameters:

  • font - The font to configure
  • filter - Filter type (use filter-* constants)

{ptr: Ptr, base-size: Int} -> Int -> Void

set-font-filter font filter-bilinear

draw-text-ex

Draw text using a custom font.

Parameters:

  • font - The loaded font
  • text - String to draw
  • x - X position on screen
  • y - Y position on screen
  • font-size - Size to render at (Float for precision)
  • spacing - Character spacing
  • color - Text color

{ptr: Ptr, base-size: Int} -> String -> Int -> Int -> Float -> Float -> Int -> Void

draw-text-ex font "Hello" 10 50 24.0 2.0 Raylib.white

measure-text-ex

Measure text width using a custom font.

Parameters:

  • font - The loaded font
  • text - String to measure
  • font-size - Size to measure at
  • spacing - Character spacing

Returns: Int - Width of the text in pixels

{ptr: Ptr, base-size: Int} -> String -> Float -> Float -> Int

width = measure-text-ex font "Hello" 24.0 2.0

get-font-default

Get the default font.

Returns the built-in raylib default font. Useful when you need a font object but don't want to load a custom font.

Returns: Font - The default font

{ptr: Ptr, base-size: Int}

font = get-font-default

is-font-valid?

Check if a font is valid.

Parameters:

  • font - The font to check

Returns: Bool - true if the font is valid, false otherwise

{ptr: Ptr, base-size: Int} -> Bool

if is-font-valid? font then draw-text-ex font ...

export-font-as-code?

Export font as C code file.

Generates a C header file containing the font data that can be compiled into an application.

Parameters:

  • font - The font to export
  • file-name - Output file path

Returns: Bool - true if export succeeded, false otherwise

{ptr: Ptr, base-size: Int} -> String -> Bool

success = export-font-as-code? font "myfont.h"

draw-text-pro

Draw text with rotation.

Draws text with full control over positioning, rotation, and origin.

Parameters:

  • font - The loaded font
  • text - String to draw
  • pos-x - X position
  • pos-y - Y position
  • origin-x - Rotation origin X
  • origin-y - Rotation origin Y
  • rotation - Rotation angle in degrees
  • font-size - Font size
  • spacing - Character spacing
  • tint - Text color

{ptr: Ptr, base-size: Int} -> String -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Int -> Void

draw-text-pro font "Rotated!" 100.0 100.0 0.0 0.0 45.0 24.0 2.0 color

draw-text-codepoint

Draw a single codepoint.

Draws a single Unicode character at the specified position.

Parameters:

  • font - The loaded font
  • codepoint - Unicode codepoint to draw
  • pos-x - X position
  • pos-y - Y position
  • font-size - Font size
  • tint - Text color

{ptr: Ptr, base-size: Int} -> Int -> Float -> Float -> Float -> Int -> Void

draw-text-codepoint font 65 100.0 100.0 24.0 color  # Draws 'A'

set-text-line-spacing

Set vertical line spacing for text.

Parameters:

  • spacing - Line spacing in pixels

Int -> Void

set-text-line-spacing 24

get-glyph-index

Get glyph index in font.

Parameters:

  • font - The loaded font
  • codepoint - Unicode codepoint

Returns: Int - Index of the glyph in the font

{ptr: Ptr, base-size: Int} -> Int -> Int

index = get-glyph-index font 65  # Get index for 'A'

get-codepoint-count

Get codepoint count in UTF-8 text.

Parameters:

  • text - UTF-8 string

Returns: Int - Number of codepoints in the string

String -> Int

count = get-codepoint-count "Hello"  # Returns 5

text-to-integer

Parse text to integer.

Parameters:

  • text - String containing a number

Returns: Int - Parsed integer value

String -> Int

num = text-to-integer "42"  # Returns 42

text-to-float

Parse text to float.

Parameters:

  • text - String containing a number

Returns: Float - Parsed float value

String -> Float

num = text-to-float "3.14"  # Returns 3.14

text-find-index

Find text in string.

Parameters:

  • text - String to search in
  • search - String to search for

Returns: Int - Index of first occurrence, or -1 if not found

String -> String -> Int

index = text-find-index "Hello World" "World"  # Returns 6

text-is-equal?

Check if two strings are equal.

Parameters:

  • text1 - First string
  • text2 - Second string

Returns: Bool - true if strings are equal

String -> String -> Bool

if text-is-equal? "foo" "foo" then print "Match!"

text-length

Get text length.

Parameters:

  • text - String to measure

Returns: Int - Length of the string in bytes

String -> Int

len = text-length "Hello"  # Returns 5

load-file-text

Load text from file.

Parameters:

  • file-name - Path to the text file

Returns: String - Contents of the file

String -> String

content = load-file-text "data.txt"

save-file-text?

Save text to file.

Parameters:

  • file-name - Output file path
  • text - Text content to save

Returns: Bool - true if save succeeded

String -> String -> Bool

success = save-file-text? "output.txt" "Hello, World!"

load-font-from-image

Load font from image.

Creates a font from an image containing character glyphs.

Parameters:

  • image - Image containing font glyphs
  • key - Color key for transparency
  • first-char - First character code in the image

Returns: Option Font - Some Font if successful, None otherwise

{ptr: Ptr} -> Int -> Int -> Option {ptr: Ptr, base-size: Int}

font = load-font-from-image img 0xFF00FF 32

get-glyph-atlas-rec-x

Get glyph atlas rectangle X coordinate.

Parameters:

  • font - The loaded font
  • codepoint - Unicode codepoint

Returns: Int - X coordinate in the atlas texture

{ptr: Ptr, base-size: Int} -> Int -> Int

x = get-glyph-atlas-rec-x font 65

get-glyph-atlas-rec-y

Get glyph atlas rectangle Y coordinate.

Parameters:

  • font - The loaded font
  • codepoint - Unicode codepoint

Returns: Int - Y coordinate in the atlas texture

{ptr: Ptr, base-size: Int} -> Int -> Int

y = get-glyph-atlas-rec-y font 65

get-glyph-atlas-rec-width

Get glyph atlas rectangle width.

Parameters:

  • font - The loaded font
  • codepoint - Unicode codepoint

Returns: Int - Width of the glyph in the atlas

{ptr: Ptr, base-size: Int} -> Int -> Int

width = get-glyph-atlas-rec-width font 65

get-glyph-atlas-rec-height

Get glyph atlas rectangle height.

Parameters:

  • font - The loaded font
  • codepoint - Unicode codepoint

Returns: Int - Height of the glyph in the atlas

{ptr: Ptr, base-size: Int} -> Int -> Int

height = get-glyph-atlas-rec-height font 65

get-font-glyph-count

Get font glyph count.

Parameters:

  • font - The loaded font

Returns: Int - Number of glyphs in the font

{ptr: Ptr, base-size: Int} -> Int

count = get-font-glyph-count font

image-draw-text

Draw text on an image.

Parameters:

  • img - Target image to draw on
  • text - Text to draw
  • pos-x - X position in pixels
  • pos-y - Y position in pixels
  • font-size - Font size
  • color - Text color

{ptr: Ptr} -> String -> Int -> Int -> Int -> Int -> Void

image-draw-text img "Hello" 10 10 20 color

image-draw-text-ex

Draw text on an image using a custom font.

Parameters:

  • img - Target image to draw on
  • font - Font to use
  • text - Text to draw
  • pos-x - X position
  • pos-y - Y position
  • font-size - Font size
  • spacing - Character spacing
  • tint - Text color

{ptr: Ptr} -> {ptr: Ptr, base-size: Int} -> String -> Float -> Float -> Float -> Float -> Int -> Void

image-draw-text-ex img font "Hello" 10.0 10.0 24.0 2.0 color

gen-image-text

Generate an image with text.

Creates an image of specified size containing rendered text.

Parameters:

  • width - Image width
  • height - Image height
  • text - Text to render

Returns: Option Image - Some Image if successful, None otherwise

Int -> Int -> String -> Option {ptr: Ptr, width: Int, height: Int}

img = gen-image-text 200 50 "Hello"

image-text

Create an image from text using default font.

Parameters:

  • text - Text to render
  • font-size - Font size
  • color - Text color

Returns: Option Image - Some Image if successful, None otherwise

String -> Int -> Int -> Option {ptr: Ptr, width: Int, height: Int}

img = image-text "Hello" 20 color

image-text-ex

Create an image from text using a custom font.

Parameters:

  • font - Font to use
  • text - Text to render
  • font-size - Font size
  • spacing - Character spacing
  • tint - Text color

Returns: Option Image - Some Image if successful, None otherwise

{ptr: Ptr, base-size: Int} -> String -> Float -> Float -> Int -> Option {ptr: Ptr, width: Int, height: Int}

img = image-text-ex font "Hello" 24.0 2.0 color

set-trace-log-level

Set the minimum log level for raylib's internal logging.

Parameters:

  • log-warning, log-error, log-fatal, log-none)

Int -> Void

# Only show warnings and errors
Core.set-trace-log-level Core.log-warning

# Disable all raylib logging
Core.set-trace-log-level Core.log-none

set-trace-log-json

Set raylib logging to output JSON formatted logs.

This enables raylib logs to be output in JSON format, compatible with kit-logging's JsonFmt format. Each log entry includes timestamp, level, message, and source fields.

Call this before init-window to capture all raylib startup logs.

Void

Core.set-trace-log-json()
Core.init-window 800 600 "My Game"
# Raylib logs now appear as JSON:
# {"timestamp":"2024-01-15T10:30:45","level":"info","message":"Initializing raylib...","source":"raylib"}

set-trace-log-pretty

Set raylib logging to output pretty formatted logs.

This enables raylib logs to be output in a human-readable format with colors, compatible with kit-logging's PrettyFmt format. Each log entry includes timestamp, colored level, source tag, and message.

Call this before init-window to capture all raylib startup logs.

Void

Core.set-trace-log-pretty()
Core.init-window 800 600 "My Game"
# Raylib logs now appear as:
# 2024-01-15T10:30:45 INFO  [raylib] Initializing raylib...

set-trace-log-file

Set raylib logging to write JSON formatted logs to a file.

This enables raylib logs to be written to a file in JSON format, compatible with kit-logging's FileLogger format. Logs are appended to the file if it exists.

Call this before init-window to capture all raylib startup logs. Call reset-trace-log to close the file when done.

String -> Void

Core.set-trace-log-file "raylib.log"
Core.init-window 800 600 "My Game"
# Raylib logs are now written to raylib.log in JSON format

Core.close-window()
Core.reset-trace-log()  # Close the log file

set-trace-log-no-op

Set raylib logging to discard all logs (no-op).

This silently discards all raylib log messages without any output. Similar to kit-logging's NoOpLogger behavior.

Useful when you want to completely suppress raylib's internal logging without affecting the log level setting.

Void

Core.set-trace-log-no-op()
Core.init-window 800 600 "My Game"
# No raylib logs will be output

reset-trace-log

Reset raylib logging to its default behavior.

Restores raylib's internal trace log handler after using set-trace-log-json, set-trace-log-pretty, set-trace-log-file, or set-trace-log-no-op.

If a log file was opened with set-trace-log-file, it will be closed.

Void

Core.set-trace-log-json()
# ... do some operations with JSON logging ...
Core.reset-trace-log()
# Back to raylib's default logging

close-window

Close window and unload OpenGL context.

Void

Core.close-window()

window-should-close

Check if window should close (ESC key or close button pressed).

Returns 1 if window should close, 0 otherwise.

Int

while (Core.window-should-close() == 0)
  # game loop

is-window-ready

Check if window has been initialized successfully.

Returns 1 if window is ready, 0 otherwise.

Int

is-window-fullscreen

Check if window is currently fullscreen.

Returns 1 if fullscreen, 0 otherwise.

Int

is-window-hidden

Check if window is currently hidden.

Returns 1 if hidden, 0 otherwise.

Int

is-window-minimized

Check if window is currently minimized.

Returns 1 if minimized, 0 otherwise.

Int

is-window-maximized

Check if window is currently maximized.

Returns 1 if maximized, 0 otherwise.

Int

is-window-focused

Check if window is currently focused.

Returns 1 if focused, 0 otherwise.

Int

is-window-resized

Check if window has been resized since last frame.

Returns 1 if resized, 0 otherwise.

Int

is-window-state

Check if a specific window state flag is enabled.

Returns 1 if flag is set, 0 otherwise.

Int -> Int

toggle-fullscreen

Toggle fullscreen mode.

Void

toggle-borderless-windowed

Toggle borderless windowed mode.

Void

maximize-window

Maximize window (only for resizable windows).

Void

minimize-window

Minimize window.

Void

restore-window

Restore window to previous state (from minimized/maximized).

Void

set-window-title

Set window title.

String -> Void

set-window-position

Set window position on screen.

Int -> Int -> Void

set-window-min-size

Set window minimum dimensions (for resizable windows).

Int -> Int -> Void

set-window-max-size

Set window maximum dimensions (for resizable windows).

Int -> Int -> Void

set-window-size

Set window dimensions.

Int -> Int -> Void

set-window-opacity

Set window opacity (0.0 transparent to 1.0 opaque).

Float -> Void

set-window-focused

Set window as focused.

Void

set-window-monitor

Set monitor for the current window.

Int -> Void

set-config-flags

Set configuration flags before window creation. Call this BEFORE init-window to configure window properties.

Int -> Void

set-window-state

Set window state flags after window creation. Can be used to make window resizable, fullscreen, etc.

Int -> Void

clear-window-state

Clear window state flags.

Int -> Void

get-screen-width

Get screen width in pixels.

Int

get-screen-height

Get screen height in pixels.

Int

get-render-width

Get current render width (considers HiDPI).

Int

get-render-height

Get current render height (considers HiDPI).

Int

get-monitor-count

Get number of connected monitors.

Int

get-current-monitor

Get current monitor where window is placed.

Int

get-monitor-width

Get specified monitor width.

Int -> Int

get-monitor-height

Get specified monitor height.

Int -> Int

get-monitor-physical-width

Get specified monitor physical width in millimetres.

Int -> Int

get-monitor-physical-height

Get specified monitor physical height in millimetres.

Int -> Int

get-monitor-refresh-rate

Get specified monitor refresh rate.

Int -> Int

get-monitor-name

Get the human-readable name of the specified monitor.

Int -> String

get-window-handle

Get native window handle.

Ptr

set-clipboard-text

Set clipboard text content.

String -> Void

get-clipboard-text

Get clipboard text content.

String

enable-event-waiting

Enable waiting for events on EndDrawing (no automatic event polling).

Void

disable-event-waiting

Disable waiting for events (automatic event polling).

Void

begin-drawing

Setup canvas (framebuffer) to start drawing.

Void

end-drawing

End canvas drawing and swap buffers (double buffering).

Void

clear-background

Set background color (clears the framebuffer).

Parameters:

    Int -> Void

set-target-fps

Set target FPS (maximum).

Int -> Void

get-fps

Get current FPS.

Int

get-frame-time

Get time since last frame in seconds.

Float

get-time

Get elapsed time since init-window in seconds.

Float

wait-time

Wait for some time (halt program execution).

Parameters:

    Float -> Void

swap-screen-buffer

Swap back buffer with front buffer (screen drawing). Used for manual frame control.

Void

poll-input-events

Register all input events. Used for manual frame control.

Void

draw-fps

Draw current FPS at the given position.

Int -> Int -> Void

show-cursor

Show cursor.

Void

hide-cursor

Hide cursor.

Void

is-cursor-hidden

Check if cursor is hidden.

Returns 1 if hidden, 0 otherwise.

Int

enable-cursor

Enable cursor (unlock cursor).

Void

disable-cursor

Disable cursor (lock cursor).

Void

is-cursor-on-screen

Check if cursor is on screen.

Returns 1 if on screen, 0 otherwise.

Int

take-screenshot

Take a screenshot of current screen (saved to file).

Parameters:

    String -> Void

open-url

Open URL with default system browser.

Parameters:

    String -> Void

begin-mode-2d

Float -> Float -> Float -> Float -> Float -> Float -> Void

end-mode-2d

Void

get-screen-to-world-2d

Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Ptr -> Ptr -> Void

get-world-to-screen-2d

Float -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Ptr -> Ptr -> Void

begin-mode-3d

{pos-x: Float, pos-y: Float, pos-z: Float, target-x: Float, target-y: Float, target-z: Float, up-x: Float, up-y: Float, up-z: Float, fovy: Float, projection: Int} -> Void

end-mode-3d

Void

update-camera

Ptr -> Int -> Void

update-camera-pro

Ptr -> Float -> Float -> Float -> Float -> Float -> Float -> Float -> Void

get-camera-forward-x

Ptr -> Float

get-camera-forward-y

Ptr -> Float

get-camera-forward-z

Ptr -> Float

get-camera-up-x

Ptr -> Float

get-camera-up-y

Ptr -> Float

get-camera-up-z

Ptr -> Float

get-camera-right-x

Ptr -> Float

get-camera-right-y

Ptr -> Float

get-camera-right-z

Ptr -> Float

camera-move-forward

Ptr -> Float -> Int -> Void

camera-move-up

Ptr -> Float -> Void

camera-move-right

Ptr -> Float -> Int -> Void

camera-move-to-target

Ptr -> Float -> Void

camera-yaw

Ptr -> Float -> Int -> Void

camera-pitch

Ptr -> Float -> Int -> Int -> Int -> Void

camera-roll

Ptr -> Float -> Void

camera-custom

Custom camera mode (manual control).

camera-free

Free camera mode (free movement).

camera-orbital

Orbital camera mode (orbits around target).

camera-first-person

First person camera mode.

camera-third-person

Third person camera mode.

camera-perspective

Perspective projection (3D depth).

camera-orthographic

Orthographic projection (no depth).

camera-3d-perspective

Create a 3D camera with perspective projection.

Returns a record containing camera parameters that can be used with begin-mode-3d.

Parameters:

Float -> Float -> Float -> Float -> Float -> Float -> Float -> {pos-x: Float, pos-y: Float, pos-z: Float, target-x: Float, target-y: Float, target-z: Float, up-x: Float, up-y: Float, up-z: Float, fovy: Float, projection: Int}

camera = Camera.camera-3d-perspective 0.0 10.0 10.0 0.0 0.0 0.0 45.0
Camera.begin-mode-3d camera

camera-3d-orthographic

Create a 3D camera with orthographic projection.

Returns a record containing camera parameters.

Float -> Float -> Float -> Float -> Float -> Float -> Float -> {pos-x: Float, pos-y: Float, pos-z: Float, target-x: Float, target-y: Float, target-z: Float, up-x: Float, up-y: Float, up-z: Float, fovy: Float, projection: Int}

make-camera-2d

Create a 2D camera.

Returns a record containing 2D camera parameters.

Parameters:

    Float -> Float -> Float -> Float -> Float -> Float -> {offset-x: Float, offset-y: Float, target-x: Float, target-y: Float, rotation: Float, zoom: Float}