# LLM Docs ## Compact Docs Copy just this section if you want to keep your context small. If you want all docs, check the section `Full Docs per Module` below. RocRay.UUID : Network.UUID RocRay.rgba : Color -> InternalColor.RocColor RocRay.exit! : {} => {} RocRay.log! : Str, [ LogAll, LogTrace, LogDebug, LogInfo, LogWarning, LogError, LogFatal, LogNone ] => {} RocRay.init_window! : { title ? Str, width ? F32, height ? F32 } => {} RocRay.get_screen_size! : {} => { height : F32, width : F32 } RocRay.set_target_fps! : I32 => {} RocRay.display_fps! : { fps : [ Visible, Hidden ], pos : Vector2 } => {} RocRay.take_screenshot! : Str => {} RocRay.load_file_to_str! : Str => Result Str [LoadErr Str] RocRay.send_to_peer! : List U8, UUID => {} RocRay.random_i32! : { min : I32, max : I32 } => I32 Camera.create! : Settings => Result Camera [LoadErr Str] Camera.update! : Camera, Settings => {} Draw.draw! : Color, ({} => {}) => {} Draw.with_mode_2d! : Camera, ({} => {}) => {} Draw.with_texture! : RenderTexture, Color, ({} => {}) => {} Draw.text! : { font ? Font, pos : { x : F32, y : F32 }, text : Str, size ? F32, spacing ? F32, color ? Color } => {} Draw.line! : { start : Vector2, end : Vector2, color : Color } => {} Draw.rectangle! : { rect : Rectangle, color : Color } => {} Draw.rectangle_gradient_v! : { rect : Rectangle, top : Color, bottom : Color } => {} Draw.rectangle_gradient_h! : { rect : Rectangle, left : Color, right : Color } => {} Draw.circle! : { center : Vector2, radius : F32, color : Color } => {} Draw.circle_gradient! : { center : Vector2, radius : F32, inner : Color, outer : Color } => {} Draw.texture_rec! : { texture : Texture, source : Rectangle, pos : Vector2, tint : Color } => {} Draw.render_texture_rec! : { texture : RenderTexture, source : Rectangle, pos : Vector2, tint : Color } => {} Font.load! : Str => Result Font [LoadErr Str] Font.default : Font Font.measure! : { font ? Font, text : Str, size ? F32, spacing ? F32 } => { width : F32, height : F32 } Keys.down : Keys, KeyboardKey -> Bool Keys.up : Keys, KeyboardKey -> Bool Keys.pressed : Keys, KeyboardKey -> Bool Keys.released : Keys, KeyboardKey -> Bool Keys.pressed_repeat : Keys, KeyboardKey -> Bool Keys.any_down : Keys, List KeyboardKey -> Bool Keys.any_up : Keys, List KeyboardKey -> Bool Keys.any_pressed : Keys, List KeyboardKey -> Bool Keys.any_released : Keys, List KeyboardKey -> Bool Mouse.ButtonState : [ Up, Down, Pressed, Released ] Mouse.up : ButtonState -> Bool Mouse.down : ButtonState -> Bool Mouse.pressed : ButtonState -> Bool Mouse.released : ButtonState -> Bool Music.load! : Str => Result Music [LoadErr Str] Music.play! : Music => {} Music.stop! : Music => {} Music.pause! : Music => {} Music.resume! : Music => {} Music.get_time_played! : Music => F32 Music.length : Music -> F32 Network.configure! : { server_url : Str } => {} Network.from_u64_pair : { upper : U64, lower : U64 }a -> UUID Network.to_u64_pair : UUID -> Effect.RawUUID Network.to_str : UUID -> Str RenderTexture.create! : { width : F32, height : F32 } => Result RenderTexture [LoadErr Str] Sound.load! : Str => Result Sound [LoadErr Str] Sound.play! : Sound => {} Texture.load! : Str => Result Texture [LoadErr Str] Time.to_nanos : U64 -> U64 Time.sleep_millis! : U64 => {} ## Full Docs per Module ### RocRay Description: A state record provided by platform on each frame. ``` { frameCount : U64, keys : InternalKeyboard.Keys, mouse : { position : Vector2, buttons : Mouse.Buttons, wheel : F32, }, timestamp : Time.Time, network : { peers : { connected : List Network.UUID, disconnected : List Network.UUID, }, messages : List { id : Network.UUID, bytes : List U8, }, }, } ``` Description: Represents a keyboard key, like `KeyA` or `KeyEnter`. Description: Represents a rectangle. ``` { x : F32, y : F32, width : F32, height : F32 } ``` Description: Represents a 2D vector. ``` { x : F32, y : F32 } ``` Description: Represents a color using a tag union. ``` # a generic rgba color RGBA { r : U8, g : U8, b : U8, a : U8 } # predefined colors White Black Red Green Blue ... etc ``` Description: A static image loaded into GPU memory, typically from a file. Once loaded, it can be used multiple times for efficient rendering. Cannot be modified after creation - for dynamic textures that can be drawn to, see [RenderTexture] instead. Description: A special texture that can be used as a render target. Allows drawing operations to be performed to it (like a canvas), making it useful for effects, buffering, or off-screen rendering. The result can then be used like a regular texture. Description: A loaded sound resource, used to play audio. Description: A camera used to render a 2D perspective of the world. UUID : Network.UUID rgba : Color -> InternalColor.RocColor exit! : {} => {} Description: Exit the program. ``` RocRay.exit! ``` log! : Str, [ LogAll, LogTrace, LogDebug, LogInfo, LogWarning, LogError, LogFatal, LogNone ] => {} Description: Show a RocRay log trace message. ``` RocRay.log! "Not yet implemented" LogError ``` init_window! : { title ? Str, width ? F32, height ? F32 } => {} get_screen_size! : {} => { height : F32, width : F32 } Description: Get the window size. set_target_fps! : I32 => {} Description: Set the target frames per second. The default value is 60. display_fps! : { fps : [ Visible, Hidden ], pos : Vector2 } => {} Description: Display the frames per second, and set the location. The default values are Hidden, 10, 10. ``` RocRay.displayFPS! { fps: Visible, pos: { x: 10, y: 10 }} ``` take_screenshot! : Str => {} Description: Takes a screenshot of current screen (filename extension defines format) ``` RocRay.takeScreenshot! "screenshot.png" ``` load_file_to_str! : Str => Result Str [LoadErr Str] Description: Loads a file from disk ``` RocRay.loadFileToStr! "resources/example.txt" ``` send_to_peer! : List U8, UUID => {} Description: Send a message to a connected peer. random_i32! : { min : I32, max : I32 } => I32 ### Camera create! : Settings => Result Camera [LoadErr Str] Description: Create a new camera. The camera can be used to render a 2D and 3D perspective of the world. ``` cameraSettings = { target: player, offset: { x: screenWidth / 2, y: screenHeight / 2 }, rotation: 0, zoom: 1, } cameraID = Camera.create! cameraSettings ``` update! : Camera, Settings => {} Description: Update a camera's target, offset, rotation, and zoom. ``` cameraSettings = model.cameraSettings |> &target model.player |> &rotation rotation |> &zoom zoom Camera.update! model.cameraID cameraSettings ``` ### Draw draw! : Color, ({} => {}) => {} Description: Draw to the framebuffer. Takes a color to clear the screen with. ``` Draw.draw! White \{} -> Draw.text! { pos: { x: 300, y: 50 }, text: "Hello World", size: 40, color: Navy } Draw.rectangle! { rect: { x: 100, y: 150, width: 250, height: 100 }, color: Aqua } ``` with_mode_2d! : Camera, ({} => {}) => {} Description: Draw a 2D scene using a camera perspective. ``` # RENDER FRAMEBUFFER Draw.draw! White \{} -> # RENDER WORLD Draw.withMode2D! model.camera \{} -> drawWorld! model # RENDER SCREEN UI drawScreenUI! ``` with_texture! : RenderTexture, Color, ({} => {}) => {} Description: Draw to a render texture. Takes a color to clear the texture with. text! : { font ? Font, pos : { x : F32, y : F32 }, text : Str, size ? F32, spacing ? F32, color ? Color } => {} Description: Draw text on the screen using the default font. line! : { start : Vector2, end : Vector2, color : Color } => {} Description: Draw a line on the screen. ``` Draw.line! { start: { x: 100, y: 500 }, end: { x: 500, y: 500 }, color: Red } ``` rectangle! : { rect : Rectangle, color : Color } => {} Description: Draw a rectangle on the screen. ``` Draw.rectangle! { rect: { x: 100, y: 150, width: 250, height: 100 }, color: Aqua } ``` rectangle_gradient_v! : { rect : Rectangle, top : Color, bottom : Color } => {} Description: Draw a rectangle with a vertical-gradient fill on the screen. ``` Draw.rectangleGradientV! { rect: { x: 300, y: 250, width: 250, height: 100 }, top: Maroon, bottom: Green } ``` rectangle_gradient_h! : { rect : Rectangle, left : Color, right : Color } => {} Description: Draw a rectangle with a horizontal-gradient fill on the screen. ``` Draw.rectangleGradientH! { rect: { x: 400, y: 150, width: 250, height: 100 }, top: Lime, bottom: Navy } ``` circle! : { center : Vector2, radius : F32, color : Color } => {} Description: Draw a circle on the screen. ``` Draw.circle! { center: { x: 200, y: 400 }, radius: 75, color: Fuchsia } ``` circle_gradient! : { center : Vector2, radius : F32, inner : Color, outer : Color } => {} Description: Draw a circle with a gradient on the screen. ``` Draw.circleGradient! { center: { x: 600, y: 400 }, radius: 75, inner: Yellow, outer: Maroon } ``` texture_rec! : { texture : Texture, source : Rectangle, pos : Vector2, tint : Color } => {} Description: Draw part of a texture. ``` # Draw the sprite at the player's position. Draw.textureRec! { texture: model.dude, source: dudeSprite model.direction dudeAnimation.frame, pos: model.player, tint: White, } ``` render_texture_rec! : { texture : RenderTexture, source : Rectangle, pos : Vector2, tint : Color } => {} Description: Draw part of a texture. ``` # Draw the sprite at the player's position. Draw.renderTextureRec! { texture: model.dude, source: dudeSprite model.direction dudeAnimation.frame, pos: model.player, tint: White, } ``` ### Font Description: A font that has been loaded into memory and is ready to be used. load! : Str => Result Font [LoadErr Str] default : Font measure! : { font ? Font, text : Str, size ? F32, spacing ? F32 } => { width : F32, height : F32 } Description: Measure the width of a text string using the default font. ### Keys down : Keys, KeyboardKey -> Bool up : Keys, KeyboardKey -> Bool pressed : Keys, KeyboardKey -> Bool released : Keys, KeyboardKey -> Bool pressed_repeat : Keys, KeyboardKey -> Bool any_down : Keys, List KeyboardKey -> Bool any_up : Keys, List KeyboardKey -> Bool any_pressed : Keys, List KeyboardKey -> Bool any_released : Keys, List KeyboardKey -> Bool ### Mouse ButtonState : [ Up, Down, Pressed, Released ] up : ButtonState -> Bool down : ButtonState -> Bool pressed : ButtonState -> Bool released : ButtonState -> Bool ### Music Description: A loaded music stream, used to play audio. load! : Str => Result Music [LoadErr Str] Description: Load a music stream from a file. ``` track = Music.load! "resources/green-hill-zone.wav" ``` maps to Raylib's LoadMusicStream play! : Music => {} Description: Play a loaded music stream. ``` Music.play! track ``` maps to Raylib's PlayMusicStream stop! : Music => {} Description: Stop a playing music stream. ``` Music.stop! track ``` maps to Raylib's StopMusicStream pause! : Music => {} Description: Pause a playing music stream. ``` Music.pause! track ``` maps to Raylib's PauseMusicStream resume! : Music => {} Description: Resume a paused music stream. ``` Music.resume! track ``` maps to Raylib's ResumeMusicStream get_time_played! : Music => F32 Description: Get the time played so far in seconds. ``` duration = Music.getTimePlayed! track ``` maps to Raylib's GetMusicTimePlayed length : Music -> F32 Description: The length of the track in seconds. ``` length = Music.length track ``` maps to Raylib's GetMusicTimeLength ### Network configure! : { server_url : Str } => {} Description: Configure the WebRTC connection to the given server URL. from_u64_pair : { upper : U64, lower : U64 }a -> UUID to_u64_pair : UUID -> Effect.RawUUID to_str : UUID -> Str ### RenderTexture create! : { width : F32, height : F32 } => Result RenderTexture [LoadErr Str] Description: Create a render texture. ``` RenderTexture.create! { width: 100, height: 100 } ``` ### Sound load! : Str => Result Sound [LoadErr Str] Description: Load a sound from a file. ``` wav = Sound.load! "resources/sound.wav" ``` play! : Sound => {} Description: Play a loaded sound. ``` Sound.play! wav ``` ### Texture load! : Str => Result Texture [LoadErr Str] Description: Load a texture from a file. ``` texture = Texture.load! "sprites.png" ``` ### Time Description: Timing information for key platform events measured in milliseconds from [UNIX EPOCH](https://en.wikipedia.org/wiki/Epoch_(computing)). ``` { initStart: U64, initEnd: U64, renderStart: U64, lastRenderStart: U64, lastRenderEnd: U64, } ``` to_nanos : U64 -> U64 sleep_millis! : U64 => {} Description: Sleep the main thread for a given number of milliseconds.