Source: assets/modules/xs.wren
Handle for shapes and sprites in the rendering system.
Used to correctly manage resources via the GC. Not to be created directly.
Core rendering API for sprites, shapes, text, and debug drawing
Provides functionality for rendering images, texts and shapes
static loadImage(path) ↗Loads an image from a file and returns an image ID
Supports PNG and JPG formats. Use relative paths like "[game]/textures/flower.png"
static loadShape(path) ↗Loads a shape from a file and returns a shape ID
Supports SVG format
static loadFont(font, size) ↗Loads a font into a font atlas and returns a font ID
Font will be rasterized at the specified size
static getImageWidth(imageId) ↗Gets the width in pixels of a loaded image
static getImageHeight(imageId) ↗Gets the height in pixels of a loaded image
static createSprite(imageId, x0, y0, x1, y1) ↗Creates a sprite from a section of an image using texture coordinates
Coordinates are normalized (0.0 to 1.0): x0, y0 (top-left), x1, y1 (bottom-right)
static createShape(imageId, positions, textureCoords, indices) ↗Creates a custom mesh shape from vertices, texture coordinates, and indices
static destroyShape(shapeId) ↗Destroys a shape and frees its resources
static setOffset(x, y) ↗Sets the offset for subsequent sprite draw calls
All sprites will be offset by (x, y) until new values are set
static sprite(spriteId, x, y, z, scale, rotation, mul, add, flags) ↗Draws a sprite with full control over appearance
- spriteId: Valid sprite ID created with createSprite (not an image ID)
- x, y: Position on screen (affected by setOffset)
- z: Sorting depth value
- scale: Scaling factor
- rotation: Rotation angle in radians
- mul: Multiply color (0xRRGGBBAA format)
- add: Additive color (0xRRGGBBAA format)
- flags: Combination of sprite flags (spriteBottom, spriteCenter, etc.)
static shape(shapeId, x, y, z, scale, rotation, mul, add) ↗Draws a shape at a position with transformation
static text(fontId, txt, x, y, z, mul, add, flags) ↗Draws text at a position with styling
Note: Text always renders above sprites currently
static spriteNone ↗Don't apply any flags
static spriteBottom ↗Draw the sprite at the bottom
static spriteTop ↗Draw the sprite at the top
static spriteCenterX ↗Center the sprite on the x-axis
static spriteCenterY ↗Center the sprite on the y-axis
static spriteFlipX ↗Flip the sprite on the x-axis
static spriteFlipY ↗Flip the sprite on the y-axis
static spriteFixed ↗Overlay the sprite as overlay (no offset applied)
static spriteCenter ↗Center the sprite on the x and y-axis
static spriteShape ↗This is not a sprite but a shape, so handle it differently
static lines ↗Primitive type for line rendering
static triangles ↗Primitive type for triangle rendering
static dbgBegin(primitive) ↗Begins a debug primitive batch
Call dbgVertex() to add vertices, then dbgEnd() to finish
Primitive can be lines or triangles
static dbgEnd() ↗Ends a debug primitive batch and renders it
Number of vertices must match primitive type (divisible by 2 for lines, 3 for triangles)
static dbgVertex(x, y) ↗Adds a vertex to the current debug primitive
Must be called between dbgBegin() and dbgEnd()
static dbgColor(color) ↗Sets the color for the next debug vertices
Color format: 0xRRGGBBAA (e.g., 0xF0C0D0FF)
static dbgLine(x0, y0, x1, y1) ↗Draws a debug line from (x0, y0) to (x1, y1)
static dbgText(text, x, y, size) ↗Draws debug text on screen with specified size
Uses built-in debug font
static dbgLine(a, b) ↗Draws a debug line between two vector points
static dbgRect(fromX, fromY, toX, toY) ↗Draws a filled debug rectangle
static dbgSquare(centerX, centerY, size) ↗Draws a filled debug square centered at position
static dbgDisk(x, y, r, divs) ↗Draws a filled debug circle (disk)
divs controls the number of triangular segments
static dbgCircle(x, y, r, divs) ↗Draws a debug circle outline
divs controls the number of line segments
static dbgArc(x, y, r, angle, divs) ↗Draws a debug arc (partial circle outline)
angle is in radians, divs controls line segment count
static dbgPie(x, y, r, angle, divs) ↗Draws a filled debug pie/wedge shape
angle is in radians, divs controls triangle count
static dbgVertex(v) ↗Adds a vector point as a debug vertex
static sprite(spriteId, x, y) ↗Draws a sprite at position with default settings
Equivalent to: sprite(spriteId, x, y, 0.0, 1.0, 0.0, 0xFFFFFFFF, 0x00000000, spriteBottom)
static sprite(spriteId, x, y, z) ↗Draws a sprite at position with z-sorting
static sprite(spriteId, x, y, z, flags) ↗Draws a sprite at position with z-sorting and custom flags
static createGridSprite(imageId, columns, rows, c, r) ↗Creates a sprite from a grid/sprite sheet by column and row
static createGridSprite(imageId, columns, rows, idx) ↗Creates a sprite from a grid/sprite sheet by index
Index starts at 0 from top-left, going row by row
File I/O operations
static read(src) ↗Reads the contents of a file as a string
static write(text, dst) ↗Writes text content to a file
static exists(src) ↗Checks if a file exists at the given path
Data class for touch input information
Input handling for keyboard, mouse, gamepad, and touch
static getAxis(axis) ↗Gets the current value of a gamepad axis (-1.0 to 1.0)
static getAxisOnce(axis, threshold) ↗Gets axis value once when it crosses threshold (prevents repeating)
static getButton(button) ↗Checks if a gamepad button is currently pressed
static getButtonOnce(button) ↗Checks if a gamepad button was just pressed (doesn't repeat while held)
static getKey(key) ↗Checks if a keyboard key is currently pressed
static getKeyOnce(key) ↗Checks if a keyboard key was just pressed (doesn't repeat while held)
static getMouse() ↗Gets mouse state information
static getMouseButton(button) ↗Checks if a mouse button is currently pressed
static getMouseButtonOnce(button) ↗Checks if a mouse button was just pressed (doesn't repeat while held)
static getMouseX() ↗Gets the current mouse X position in screen coordinates
static getMouseY() ↗Gets the current mouse Y position in screen coordinates
static getMouseWheel() ↗Gets the mouse wheel delta for this frame
static getNrTouches() ↗Gets the number of active touch points
static getTouchId(index) ↗Gets the unique ID for a touch at the given index
static getTouchX(index) ↗Gets the X position for a touch at the given index
static getTouchY(index) ↗Gets the Y position for a touch at the given index
static setPadVibration(lowRumble, highRumble, time) ↗Sets gamepad vibration motors (DualSense, Xbox controllers)
time is in milliseconds
static setPadLightbarColor(red, green, blue) ↗Sets the gamepad lightbar color (DualSense controller)
Colors are 0-255
static resetPadLightbarColor() ↗Resets gamepad lightbar to default color
static getTouchData() ↗Gets all touch data as a list of TouchData objects
static getTouchData(index) ↗Gets touch data for a specific touch index
static getMousePosition() ↗Gets the mouse position as a two-element list [x, y]
Audio playback using FMOD
static load(name, groupId) ↗Loads a sound file into a group and returns a sound ID
static play(soundId) ↗Plays a loaded sound and returns a channel ID
static getGroupVolume(groupId) ↗Gets the volume level of a sound group (0.0 to 1.0)
static setGroupVolume(groupId, volume) ↗Sets the volume level of a sound group (0.0 to 1.0)
static getChannelVolume(channelId) ↗Gets the volume level of a specific channel (0.0 to 1.0)
static setChannelVolume(channelId, volume) ↗Sets the volume level of a specific channel (0.0 to 1.0)
static getBusVolume(busName) ↗Gets the volume level of an FMOD bus by name (0.0 to 1.0)
static setBusVolume(busName, volume) ↗Sets the volume level of an FMOD bus by name (0.0 to 1.0)
static loadBank(bankId) ↗Loads an FMOD sound bank
static unloadBank(bankId) ↗Unloads an FMOD sound bank
static startEvent(eventName) ↗Starts an FMOD event and returns an event instance ID
static setParameterNumber(eventId, paramName, newValue) ↗Sets a numeric parameter on an FMOD event instance
static setParameterLabel(eventId, paramName, newValue) ↗Sets a labeled parameter on an FMOD event instance
static load(path) ↗Load an audio file and return an audio id
static play(audioId, volume) ↗Play a loaded audio file with specified volume (0.0 to 1.0)
static play(audioId) ↗Play a loaded audio file with default volume (1.0)
static setVolume(channelId, volume) ↗Set the volume of a playing channel (0.0 to 1.0)
static getVolume(channelId) ↗Get the volume of a playing channel
static stop(channelId) ↗Stop a playing channel
static stopAll() ↗Stop all playing channels
static isPlaying(channelId) ↗Check if a channel is currently playing
static getNumber(name) ↗Gets a number value from the game scope
static getColor(name) ↗Gets a color value from the game scope
static getBool(name) ↗Gets a boolean value from the game scope
static getNumber(name, type) ↗Gets a number value from a specific data scope
static getColor(name, type) ↗Gets a color value from a specific data scope
static getBool(name, type) ↗Gets a boolean value from a specific data scope
static getString(name, type) ↗Gets a string value from a specific data scope
static setNumber(name, value, type) ↗Sets a number value in a specific data scope
static setColor(name, value, type) ↗Sets a color value in a specific data scope
static setBool(name, value, type) ↗Sets a boolean value in a specific data scope
static setString(name, value, type) ↗Sets a string value in a specific data scope
Platform and device information
static getPlatform() ↗Gets the current platform identifier
static canClose() ↗Checks if the application can be closed (always false on consoles)
static requestClose() ↗Requests the application to close
CPU profiling utilities
static begin(name) ↗Begins a named profiler section
static end(name) ↗Ends a named profiler section