Skip to content

@shaisrc/tty v0.1.0-beta.5


@shaisrc/tty v0.1.0-beta.5 โ€‹

Classes โ€‹

AnimationManager โ€‹

Defined in: core/AnimationManager.ts:76

AnimationManager Provides simple animation capabilities for ASCII rendering

Constructors โ€‹

Constructor โ€‹

new AnimationManager(): AnimationManager

Returns โ€‹

AnimationManager

Methods โ€‹

animate() โ€‹

animate(options): number

Defined in: core/AnimationManager.ts:108

Create a custom animation

Parameters โ€‹
options โ€‹

AnimateOptions = {}

Animation options

Returns โ€‹

number

Animation ID that can be used to stop the animation

Example โ€‹
ts
const animId = animations.animate({
  duration: 1000,
  easing: 'easeInOut',
  onUpdate: (progress) => {
    const x = Math.floor(10 + progress * 50);
    renderer.setChar(x, 10, '@', 'cyan');
  },
  onComplete: () => console.log('Animation done!')
});
flash() โ€‹

flash(x, y, options): number

Defined in: core/AnimationManager.ts:156

Flash a character at a position

Parameters โ€‹
x โ€‹

number

X coordinate

y โ€‹

number

Y coordinate

options โ€‹

FlashOptions = {}

Flash options

Returns โ€‹

number

Animation ID that can be used to stop the animation

Example โ€‹
ts
// Flash '@' at position (10, 5) in red, 3 times
animations.flash(10, 5, {
  char: '@',
  fg: 'red',
  count: 3,
  duration: 500
});
getActiveCount() โ€‹

getActiveCount(): number

Defined in: core/AnimationManager.ts:338

Get the number of active animations

Returns โ€‹

number

isActive() โ€‹

isActive(id): boolean

Defined in: core/AnimationManager.ts:346

Check if an animation is active

Parameters โ€‹
id โ€‹

number

Animation ID

Returns โ€‹

boolean

pulse() โ€‹

pulse(x, y, options): number

Defined in: core/AnimationManager.ts:221

Create a pulsing animation at a position

Parameters โ€‹
x โ€‹

number

X coordinate

y โ€‹

number

Y coordinate

options โ€‹

PulseOptions = {}

Pulse options

Returns โ€‹

number

Animation ID that can be used to stop the animation

Example โ€‹
ts
// Pulse a character between dim and bright
animations.pulse(20, 10, {
  duration: 1000,
  minIntensity: 0.3,
  maxIntensity: 1.0,
  fg: 'yellow',
  loop: true
});
setRenderer() โ€‹

setRenderer(renderer): void

Defined in: core/AnimationManager.ts:85

Set the renderer instance for animations that need to modify cells

Parameters โ€‹
renderer โ€‹

Renderer

The renderer instance

Returns โ€‹

void

stop() โ€‹

stop(id): void

Defined in: core/AnimationManager.ts:270

Stop an animation

Parameters โ€‹
id โ€‹

number

Animation ID returned from animate/flash/pulse

Returns โ€‹

void

stopAll() โ€‹

stopAll(): void

Defined in: core/AnimationManager.ts:281

Stop all animations

Returns โ€‹

void

update() โ€‹

update(currentTime): void

Defined in: core/AnimationManager.ts:298

Update all active animations Should be called each frame, typically from the game loop

Parameters โ€‹
currentTime โ€‹

number = ...

Current time in milliseconds (defaults to Date.now())

Returns โ€‹

void

Example โ€‹
ts
gameLoop.update((dt) => {
  animations.update();
});

CanvasTarget โ€‹

Defined in: targets/CanvasTarget.ts:29

Renders to an HTML Canvas element

Implements โ€‹

Constructors โ€‹

Constructor โ€‹

new CanvasTarget(canvas, options): CanvasTarget

Defined in: targets/CanvasTarget.ts:44

Create a new CanvasTarget

Parameters โ€‹
canvas โ€‹

HTMLCanvasElement

Canvas element to render to

options โ€‹

CanvasTargetOptions

Canvas configuration including width, height, and rendering options

Returns โ€‹

CanvasTarget

Methods โ€‹

clear() โ€‹

clear(): void

Defined in: targets/CanvasTarget.ts:93

Clear the entire canvas

Returns โ€‹

void

Implementation of โ€‹

RenderTarget.clear

flush() โ€‹

flush(): void

Defined in: targets/CanvasTarget.ts:100

Flush changes (no-op for canvas as drawing is immediate)

Returns โ€‹

void

Implementation of โ€‹

RenderTarget.flush

getCanvas() โ€‹

getCanvas(): HTMLCanvasElement

Defined in: targets/CanvasTarget.ts:114

Get the canvas element

Returns โ€‹

HTMLCanvasElement

getSize() โ€‹

getSize(): object

Defined in: targets/CanvasTarget.ts:107

Get the size of the render target

Returns โ€‹

object

height โ€‹

height: number

width โ€‹

width: number

Implementation of โ€‹

RenderTarget.getSize

setCell() โ€‹

setCell(x, y, char, fg, bg): void

Defined in: targets/CanvasTarget.ts:73

Set a character at the specified position

Parameters โ€‹
x โ€‹

number

y โ€‹

number

char โ€‹

string

fg โ€‹

Color

bg โ€‹

Color

Returns โ€‹

void

Implementation of โ€‹

RenderTarget.setCell

setOptions() โ€‹

setOptions(options): void

Defined in: targets/CanvasTarget.ts:121

Update canvas options

Parameters โ€‹
options โ€‹

Partial<CanvasTargetOptions>

Returns โ€‹

void


GameLoop โ€‹

Defined in: core/GameLoop.ts:15

Constructors โ€‹

Constructor โ€‹

new GameLoop(update, render?, options?): GameLoop

Defined in: core/GameLoop.ts:41

Create a new game loop

Parameters โ€‹
update โ€‹

UpdateCallback

Update callback (called with delta time in ms)

render? โ€‹

RenderCallback

Optional render callback

options? โ€‹

GameLoopOptions = {}

Game loop options

Returns โ€‹

GameLoop

Methods โ€‹

getActualFPS() โ€‹

getActualFPS(): number

Defined in: core/GameLoop.ts:171

Get actual FPS (calculated over last second)

Returns โ€‹

number

getElapsedTime() โ€‹

getElapsedTime(): number

Defined in: core/GameLoop.ts:193

Get total elapsed time in milliseconds (excluding paused time)

Returns โ€‹

number

getFPS() โ€‹

getFPS(): number

Defined in: core/GameLoop.ts:164

Get target FPS

Returns โ€‹

number

getTimestep() โ€‹

getTimestep(): number

Defined in: core/GameLoop.ts:186

Get fixed timestep in milliseconds

Returns โ€‹

number

isPaused() โ€‹

isPaused(): boolean

Defined in: core/GameLoop.ts:157

Check if game loop is paused

Returns โ€‹

boolean

isRunning() โ€‹

isRunning(): boolean

Defined in: core/GameLoop.ts:150

Check if game loop is running

Returns โ€‹

boolean

pause() โ€‹

pause(): void

Defined in: core/GameLoop.ts:131

Pause the game loop (stops update/render but keeps running)

Returns โ€‹

void

resume() โ€‹

resume(): void

Defined in: core/GameLoop.ts:139

Resume the game loop

Returns โ€‹

void

setFPS() โ€‹

setFPS(fps): void

Defined in: core/GameLoop.ts:178

Set target FPS

Parameters โ€‹
fps โ€‹

number

Returns โ€‹

void

start() โ€‹

start(): void

Defined in: core/GameLoop.ts:101

Start the game loop

Returns โ€‹

void

stop() โ€‹

stop(): void

Defined in: core/GameLoop.ts:114

Stop the game loop

Returns โ€‹

void


GamepadManager โ€‹

Defined in: input/GamepadManager.ts:19

Constructors โ€‹

Constructor โ€‹

new GamepadManager(options): GamepadManager

Defined in: input/GamepadManager.ts:34

Create a new gamepad manager

Parameters โ€‹
options โ€‹

Configuration options

deadzone? โ€‹

number

Returns โ€‹

GamepadManager

Methods โ€‹

destroy() โ€‹

destroy(): void

Defined in: input/GamepadManager.ts:337

Remove event listeners and cleanup

Returns โ€‹

void

getAxis() โ€‹

getAxis(axisIndex, gamepadIndex): number

Defined in: input/GamepadManager.ts:209

Get axis value with deadzone applied

Parameters โ€‹
axisIndex โ€‹

number

gamepadIndex โ€‹

number = 0

Returns โ€‹

number

getButton() โ€‹

getButton(buttonIndex, gamepadIndex): GamepadButtonState

Defined in: input/GamepadManager.ts:186

Get button state with all flags

Parameters โ€‹
buttonIndex โ€‹

number

gamepadIndex โ€‹

number = 0

Returns โ€‹

GamepadButtonState

getConnectedCount() โ€‹

getConnectedCount(): number

Defined in: input/GamepadManager.ts:154

Get the number of connected gamepads

Returns โ€‹

number

getDeadzone() โ€‹

getDeadzone(): number

Defined in: input/GamepadManager.ts:267

Get current deadzone value

Returns โ€‹

number

getDPad() โ€‹

getDPad(gamepadIndex): GamepadAxisState

Defined in: input/GamepadManager.ts:245

Get D-pad direction as {x, y} (-1, 0, 1) Uses buttons 12-15 (standard mapping)

Parameters โ€‹
gamepadIndex โ€‹

number = 0

Returns โ€‹

GamepadAxisState

getGamepad() โ€‹

getGamepad(index): Gamepad | null

Defined in: input/GamepadManager.ts:133

Get a gamepad by index (0-3)

Parameters โ€‹
index โ€‹

number = 0

Returns โ€‹

Gamepad | null

getGamepads() โ€‹

getGamepads(): Gamepad[]

Defined in: input/GamepadManager.ts:140

Get all connected gamepads

Returns โ€‹

Gamepad[]

getLeftStick() โ€‹

getLeftStick(gamepadIndex): GamepadAxisState

Defined in: input/GamepadManager.ts:224

Get left stick as

Parameters โ€‹
gamepadIndex โ€‹

number = 0

Returns โ€‹

GamepadAxisState

getRightStick() โ€‹

getRightStick(gamepadIndex): GamepadAxisState

Defined in: input/GamepadManager.ts:234

Get right stick as

Parameters โ€‹
gamepadIndex โ€‹

number = 0

Returns โ€‹

GamepadAxisState

isConnected() โ€‹

isConnected(index): boolean

Defined in: input/GamepadManager.ts:147

Check if a gamepad is connected

Parameters โ€‹
index โ€‹

number = 0

Returns โ€‹

boolean

isPressed() โ€‹

isPressed(buttonIndex, gamepadIndex): boolean

Defined in: input/GamepadManager.ts:161

Check if a button is currently pressed

Parameters โ€‹
buttonIndex โ€‹

number

gamepadIndex โ€‹

number = 0

Returns โ€‹

boolean

justPressed() โ€‹

justPressed(buttonIndex, gamepadIndex): boolean

Defined in: input/GamepadManager.ts:170

Check if a button was just pressed this frame

Parameters โ€‹
buttonIndex โ€‹

number

gamepadIndex โ€‹

number = 0

Returns โ€‹

boolean

justReleased() โ€‹

justReleased(buttonIndex, gamepadIndex): boolean

Defined in: input/GamepadManager.ts:178

Check if a button was just released this frame

Parameters โ€‹
buttonIndex โ€‹

number

gamepadIndex โ€‹

number = 0

Returns โ€‹

boolean

onConnected() โ€‹

onConnected(callback): void

Defined in: input/GamepadManager.ts:305

Register a callback for gamepad connection

Parameters โ€‹
callback โ€‹

GamepadCallback

Returns โ€‹

void

onDisconnected() โ€‹

onDisconnected(callback): void

Defined in: input/GamepadManager.ts:312

Register a callback for gamepad disconnection

Parameters โ€‹
callback โ€‹

GamepadCallback

Returns โ€‹

void

removeCallback() โ€‹

removeCallback(callback, type): void

Defined in: input/GamepadManager.ts:319

Remove a callback

Parameters โ€‹
callback โ€‹

GamepadCallback

type โ€‹

"connected" | "disconnected"

Returns โ€‹

void

setDeadzone() โ€‹

setDeadzone(deadzone): void

Defined in: input/GamepadManager.ts:260

Set the deadzone for analog sticks (0-1)

Parameters โ€‹
deadzone โ€‹

number

Returns โ€‹

void

update() โ€‹

update(): void

Defined in: input/GamepadManager.ts:84

Poll gamepads and update state (call once per frame before checking inputs)

Returns โ€‹

void

vibrate() โ€‹

vibrate(duration, weakMagnitude, strongMagnitude, gamepadIndex): Promise<boolean>

Defined in: input/GamepadManager.ts:278

Vibrate/rumble the gamepad

Parameters โ€‹
duration โ€‹

number = 200

Duration in milliseconds

weakMagnitude โ€‹

number = 0.5

Weak motor magnitude (0-1)

strongMagnitude โ€‹

number = 0.5

Strong motor magnitude (0-1)

gamepadIndex โ€‹

number = 0

Gamepad index

Returns โ€‹

Promise<boolean>


KeyboardManager โ€‹

Defined in: input/KeyboardManager.ts:21

Constructors โ€‹

Constructor โ€‹

new KeyboardManager(element): KeyboardManager

Defined in: input/KeyboardManager.ts:40

Create a new keyboard manager

Parameters โ€‹
element โ€‹

Element to attach listeners to (default: window)

HTMLElement | Window

Returns โ€‹

KeyboardManager

Methods โ€‹

clear() โ€‹

clear(): void

Defined in: input/KeyboardManager.ts:220

Clear all key states

Returns โ€‹

void

destroy() โ€‹

destroy(): void

Defined in: input/KeyboardManager.ts:383

Remove event listeners and cleanup

Returns โ€‹

void

getDirection() โ€‹

getDirection(options): DirectionVector

Defined in: input/KeyboardManager.ts:239

Get direction vector from WASD/Arrow keys

Parameters โ€‹
options โ€‹

DirectionOptions = {}

Options for direction calculation

Returns โ€‹

DirectionVector

Direction vector {x, y} with values -1, 0, or 1 (or normalized)

Example โ€‹
ts
const dir = keyboard.getDirection()
if (dir.x !== 0 || dir.y !== 0) {
  player.move(dir.x, dir.y)
}
getPressed() โ€‹

getPressed(): string[]

Defined in: input/KeyboardManager.ts:205

Get array of all currently pressed keys

Returns โ€‹

string[]

isDown() โ€‹

isDown(key): boolean

Defined in: input/KeyboardManager.ts:112

Alias for isPressed - check if a key is currently down

Parameters โ€‹
key โ€‹

string

Key to check

Returns โ€‹

boolean

true if the key is currently pressed

Example โ€‹
ts
if (keyboard.isDown('Space')) {
  player.jump()
}
isPressed() โ€‹

isPressed(key): boolean

Defined in: input/KeyboardManager.ts:96

Check if a key is currently pressed

Parameters โ€‹
key โ€‹

string

Returns โ€‹

boolean

justPressed() โ€‹

justPressed(key): boolean

Defined in: input/KeyboardManager.ts:119

Check if a key was just pressed this frame

Parameters โ€‹
key โ€‹

string

Returns โ€‹

boolean

justReleased() โ€‹

justReleased(key): boolean

Defined in: input/KeyboardManager.ts:126

Check if a key was just released this frame

Parameters โ€‹
key โ€‹

string

Returns โ€‹

boolean

onKeyDown() โ€‹

onKeyDown(key, callback): void

Defined in: input/KeyboardManager.ts:144

Register a callback for key down events

Parameters โ€‹
key โ€‹

Single key or array of keys to bind

string | string[]

callback โ€‹

KeyCallback

Callback function to execute

Returns โ€‹

void

Example โ€‹
ts
// Single key
keyboard.onKeyDown('Enter', () => console.log('Enter pressed'))

// Multiple keys (alternative bindings)
keyboard.onKeyDown(['ArrowUp', 'w', 'W'], () => player.moveUp())
onKeyUp() โ€‹

onKeyUp(key, callback): void

Defined in: input/KeyboardManager.ts:169

Register a callback for key up events

Parameters โ€‹
key โ€‹

Single key or array of keys to bind

string | string[]

callback โ€‹

KeyCallback

Callback function to execute

Returns โ€‹

void

Example โ€‹
ts
// Single key
keyboard.onKeyUp('Space', () => player.stopJumping())

// Multiple keys (alternative bindings)
keyboard.onKeyUp(['ArrowLeft', 'a', 'A'], () => player.stopMovingLeft())
removeCallback() โ€‹

removeCallback(key, callback, type): void

Defined in: input/KeyboardManager.ts:183

Remove a callback

Parameters โ€‹
key โ€‹

string

callback โ€‹

KeyCallback

type โ€‹

"keydown" | "keyup"

Returns โ€‹

void

update() โ€‹

update(): void

Defined in: input/KeyboardManager.ts:212

Clear just pressed/released states (call once per frame)

Returns โ€‹

void

waitForKey() โ€‹

waitForKey(key?, options?): Promise<string>

Defined in: input/KeyboardManager.ts:301

Wait for a specific key press (promise-based)

Parameters โ€‹
key? โ€‹

Key or array of keys to wait for (omit for any key)

string | string[]

options? โ€‹

WaitForKeyOptions = {}

Timeout and abort signal options

Returns โ€‹

Promise<string>

Promise that resolves with the pressed key

Example โ€‹
ts
// Wait for Enter
const key = await keyboard.waitForKey('Enter')

// Wait for Y or N with timeout
try {
  const key = await keyboard.waitForKey(['y', 'n'], { timeout: 5000 })
  if (key === 'y') console.log('Yes!')
} catch {
  console.log('Timeout!')
}

MouseManager โ€‹

Defined in: input/MouseManager.ts:21

Deprecated โ€‹

Use PointerManager instead. MouseManager is deprecated and will be removed in a future version.

Constructors โ€‹

Constructor โ€‹

new MouseManager(element, gridWidth, gridHeight, cellWidth, cellHeight): MouseManager

Defined in: input/MouseManager.ts:57

Create a new mouse manager

Parameters โ€‹
element โ€‹

HTMLElement

Element to attach listeners to

gridWidth โ€‹

number

Grid width in cells

gridHeight โ€‹

number

Grid height in cells

cellWidth โ€‹

number

Cell width in pixels

cellHeight โ€‹

number

Cell height in pixels

Returns โ€‹

MouseManager

Methods โ€‹

clear() โ€‹

clear(): void

Defined in: input/MouseManager.ts:326

Clear all button states

Returns โ€‹

void

destroy() โ€‹

destroy(): void

Defined in: input/MouseManager.ts:336

Remove event listeners and cleanup

Returns โ€‹

void

getDragDelta() โ€‹

getDragDelta(): MousePosition

Defined in: input/MouseManager.ts:280

Get drag delta from start position

Returns โ€‹

MousePosition

getGridPosition() โ€‹

getGridPosition(): MousePosition

Defined in: input/MouseManager.ts:240

Get current mouse position in grid coordinates

Returns โ€‹

MousePosition

getPosition() โ€‹

getPosition(): MousePosition

Defined in: input/MouseManager.ts:233

Get current mouse position in pixels

Returns โ€‹

MousePosition

getWorldPosition() โ€‹

getWorldPosition(cameraX, cameraY): MousePosition

Defined in: input/MouseManager.ts:247

Get mouse position in world coordinates

Parameters โ€‹
cameraX โ€‹

number

cameraY โ€‹

number

Returns โ€‹

MousePosition

isDragging() โ€‹

isDragging(): boolean

Defined in: input/MouseManager.ts:273

Check if currently dragging

Returns โ€‹

boolean

isHovering() โ€‹

isHovering(): boolean

Defined in: input/MouseManager.ts:258

Check if mouse is hovering over element

Returns โ€‹

boolean

isHoveringCell() โ€‹

isHoveringCell(x, y): boolean

Defined in: input/MouseManager.ts:265

Check if hovering over specific grid cell

Parameters โ€‹
x โ€‹

number

y โ€‹

number

Returns โ€‹

boolean

isLeftPressed() โ€‹

isLeftPressed(): boolean

Defined in: input/MouseManager.ts:198

Check if left mouse button is pressed

Returns โ€‹

boolean

isMiddlePressed() โ€‹

isMiddlePressed(): boolean

Defined in: input/MouseManager.ts:212

Check if middle mouse button is pressed

Returns โ€‹

boolean

isPressed() โ€‹

isPressed(button): boolean

Defined in: input/MouseManager.ts:191

Check if mouse button is currently pressed

Parameters โ€‹
button โ€‹

number

Returns โ€‹

boolean

isRightPressed() โ€‹

isRightPressed(): boolean

Defined in: input/MouseManager.ts:205

Check if right mouse button is pressed

Returns โ€‹

boolean

justPressed() โ€‹

justPressed(button): boolean

Defined in: input/MouseManager.ts:219

Check if button was just pressed this frame

Parameters โ€‹
button โ€‹

number

Returns โ€‹

boolean

justReleased() โ€‹

justReleased(button): boolean

Defined in: input/MouseManager.ts:226

Check if button was just released this frame

Parameters โ€‹
button โ€‹

number

Returns โ€‹

boolean

onClick() โ€‹

onClick(callback): void

Defined in: input/MouseManager.ts:290

Register click callback

Parameters โ€‹
callback โ€‹

MouseCallback

Returns โ€‹

void

onDragEnd() โ€‹

onDragEnd(callback): void

Defined in: input/MouseManager.ts:311

Register drag end callback

Parameters โ€‹
callback โ€‹

MouseCallback

Returns โ€‹

void

onDragStart() โ€‹

onDragStart(callback): void

Defined in: input/MouseManager.ts:304

Register drag start callback

Parameters โ€‹
callback โ€‹

MouseCallback

Returns โ€‹

void

onHover() โ€‹

onHover(callback): void

Defined in: input/MouseManager.ts:297

Register hover callback

Parameters โ€‹
callback โ€‹

MouseCallback

Returns โ€‹

void

update() โ€‹

update(): void

Defined in: input/MouseManager.ts:318

Clear just pressed/released states (call once per frame)

Returns โ€‹

void


PointerManager โ€‹

Defined in: input/PointerManager.ts:19

Constructors โ€‹

Constructor โ€‹

new PointerManager(element, gridWidth, gridHeight, cellWidth, cellHeight): PointerManager

Defined in: input/PointerManager.ts:57

Create a new pointer manager

Parameters โ€‹
element โ€‹

HTMLElement

Element to attach listeners to

gridWidth โ€‹

number

Grid width in cells

gridHeight โ€‹

number

Grid height in cells

cellWidth โ€‹

number

Cell width in pixels

cellHeight โ€‹

number

Cell height in pixels

Returns โ€‹

PointerManager

Methods โ€‹

clear() โ€‹

clear(): void

Defined in: input/PointerManager.ts:347

Clear all button states

Returns โ€‹

void

destroy() โ€‹

destroy(): void

Defined in: input/PointerManager.ts:357

Remove event listeners and cleanup

Returns โ€‹

void

getDragDelta() โ€‹

getDragDelta(): PointerPosition

Defined in: input/PointerManager.ts:301

Get drag delta from start position

Returns โ€‹

PointerPosition

getGridPosition() โ€‹

getGridPosition(): PointerPosition

Defined in: input/PointerManager.ts:246

Get current pointer position in grid coordinates

Returns โ€‹

PointerPosition

getPointerType() โ€‹

getPointerType(): string

Defined in: input/PointerManager.ts:264

Get the type of pointer device (mouse, touch, pen, or empty string)

Returns โ€‹

string

getPosition() โ€‹

getPosition(): PointerPosition

Defined in: input/PointerManager.ts:239

Get current pointer position in pixels

Returns โ€‹

PointerPosition

getPressure() โ€‹

getPressure(): number

Defined in: input/PointerManager.ts:272

Get the pressure of the pointer (0.0 to 1.0) Useful for pen input with pressure sensitivity

Returns โ€‹

number

getWorldPosition() โ€‹

getWorldPosition(cameraX, cameraY): PointerPosition

Defined in: input/PointerManager.ts:253

Get pointer position in world coordinates

Parameters โ€‹
cameraX โ€‹

number

cameraY โ€‹

number

Returns โ€‹

PointerPosition

isDragging() โ€‹

isDragging(): boolean

Defined in: input/PointerManager.ts:294

Check if currently dragging

Returns โ€‹

boolean

isHovering() โ€‹

isHovering(): boolean

Defined in: input/PointerManager.ts:279

Check if pointer is hovering over element

Returns โ€‹

boolean

isHoveringCell() โ€‹

isHoveringCell(x, y): boolean

Defined in: input/PointerManager.ts:286

Check if hovering over specific grid cell

Parameters โ€‹
x โ€‹

number

y โ€‹

number

Returns โ€‹

boolean

isLeftPressed() โ€‹

isLeftPressed(): boolean

Defined in: input/PointerManager.ts:204

Check if left pointer button is pressed

Returns โ€‹

boolean

isMiddlePressed() โ€‹

isMiddlePressed(): boolean

Defined in: input/PointerManager.ts:218

Check if middle pointer button is pressed

Returns โ€‹

boolean

isPressed() โ€‹

isPressed(button): boolean

Defined in: input/PointerManager.ts:197

Check if pointer button is currently pressed

Parameters โ€‹
button โ€‹

number

Returns โ€‹

boolean

isRightPressed() โ€‹

isRightPressed(): boolean

Defined in: input/PointerManager.ts:211

Check if right pointer button is pressed

Returns โ€‹

boolean

justPressed() โ€‹

justPressed(button): boolean

Defined in: input/PointerManager.ts:225

Check if button was just pressed this frame

Parameters โ€‹
button โ€‹

number

Returns โ€‹

boolean

justReleased() โ€‹

justReleased(button): boolean

Defined in: input/PointerManager.ts:232

Check if button was just released this frame

Parameters โ€‹
button โ€‹

number

Returns โ€‹

boolean

onClick() โ€‹

onClick(callback): void

Defined in: input/PointerManager.ts:311

Register click callback

Parameters โ€‹
callback โ€‹

PointerCallback

Returns โ€‹

void

onDragEnd() โ€‹

onDragEnd(callback): void

Defined in: input/PointerManager.ts:332

Register drag end callback

Parameters โ€‹
callback โ€‹

PointerCallback

Returns โ€‹

void

onDragStart() โ€‹

onDragStart(callback): void

Defined in: input/PointerManager.ts:325

Register drag start callback

Parameters โ€‹
callback โ€‹

PointerCallback

Returns โ€‹

void

onHover() โ€‹

onHover(callback): void

Defined in: input/PointerManager.ts:318

Register hover callback

Parameters โ€‹
callback โ€‹

PointerCallback

Returns โ€‹

void

update() โ€‹

update(): void

Defined in: input/PointerManager.ts:339

Clear just pressed/released states (call once per frame)

Returns โ€‹

void


Renderer โ€‹

Defined in: core/Renderer.ts:80

Main renderer class providing drawing primitives and higher-level helpers

Constructors โ€‹

Constructor โ€‹

new Renderer(target, options): Renderer

Defined in: core/Renderer.ts:103

Create a new Renderer

Parameters โ€‹
target โ€‹

RenderTarget

Render target to output to

options โ€‹

RendererCreateOptions = {}

Renderer options

Returns โ€‹

Renderer

Properties โ€‹

debug โ€‹

readonly debug: object

Defined in: core/Renderer.ts:1285

Debug namespace providing visualization and inspection tools

logCell() โ€‹

logCell: (x, y) => CellInfo | null

Get detailed information about a cell

Parameters โ€‹
x โ€‹

number

X coordinate of the cell

y โ€‹

number

Y coordinate of the cell

Returns โ€‹

CellInfo | null

Cell information object, or null if out of bounds

showBounds() โ€‹

showBounds: (x, y, width, height, options?) => this

Visualize the bounds of a rectangular area

Parameters โ€‹
x โ€‹

number

X coordinate of top-left corner

y โ€‹

number

Y coordinate of top-left corner

width โ€‹

number

Width of the bounds

height โ€‹

number

Height of the bounds

options? โ€‹

ShowBoundsOptions

Bounds display options

Returns โ€‹

this

The renderer instance for chaining

showFPS() โ€‹

showFPS: (fps, options?) => this

Display FPS (frames per second) counter

Parameters โ€‹
fps โ€‹

number

Current FPS value

options? โ€‹

ShowFPSOptions

FPS display options

Returns โ€‹

this

The renderer instance for chaining

showGrid() โ€‹

showGrid: (options?) => this

Draw a grid overlay for alignment and positioning

Parameters โ€‹
options? โ€‹

ShowGridOptions

Grid display options

Returns โ€‹

this

The renderer instance for chaining

showPointerCoords() โ€‹

showPointerCoords: (pointerX, pointerY, options?) => this

Display pointer/mouse coordinates

Parameters โ€‹
pointerX โ€‹

number

Pointer X grid coordinate

pointerY โ€‹

number

Pointer Y grid coordinate

options? โ€‹

ShowPointerCoordsOptions

Display options

Returns โ€‹

this

The renderer instance for chaining

height โ€‹

readonly height: number

Defined in: core/Renderer.ts:96

Height in characters

width โ€‹

readonly width: number

Defined in: core/Renderer.ts:93

Width in characters

Accessors โ€‹

validate โ€‹
Get Signature โ€‹

get validate(): object

Defined in: core/Renderer.ts:1545

Validation helpers for bounds checking

Provides methods to check if drawing operations would be within bounds before attempting to draw. Useful for conditional rendering logic.

Returns โ€‹
box() โ€‹

box: (x, y, width, height) => boolean

Check if a box would fit within bounds

Parameters โ€‹
x โ€‹

number

Starting X coordinate

y โ€‹

number

Starting Y coordinate

width โ€‹

number

Box width

height โ€‹

number

Box height

Returns โ€‹

boolean

True if box fits entirely within bounds, false otherwise

Example โ€‹
ts
if (renderer.validate.box(x, y, 20, 10)) {
  renderer.box(x, y, 20, 10)
} else {
  console.warn('Box out of bounds')
}
cell() โ€‹

cell: (x, y) => boolean

Check if a cell position is within bounds

Parameters โ€‹
x โ€‹

number

X coordinate

y โ€‹

number

Y coordinate

Returns โ€‹

boolean

True if position is valid, false otherwise

Example โ€‹
ts
if (renderer.validate.cell(x, y)) {
  renderer.setChar(x, y, '@')
}
line() โ€‹

line: (x1, y1, x2, y2) => boolean

Check if a line would fit within bounds

Parameters โ€‹
x1 โ€‹

number

Starting X coordinate

y1 โ€‹

number

Starting Y coordinate

x2 โ€‹

number

Ending X coordinate

y2 โ€‹

number

Ending Y coordinate

Returns โ€‹

boolean

True if both endpoints are within bounds, false otherwise

Example โ€‹
ts
if (renderer.validate.line(x1, y1, x2, y2)) {
  renderer.drawLine(x1, y1, x2, y2, '-')
}
text() โ€‹

text: (x, y, text) => boolean

Check if text would fit within bounds

Parameters โ€‹
x โ€‹

number

Starting X coordinate

y โ€‹

number

Y coordinate

text โ€‹

string

Text string to check

Returns โ€‹

boolean

True if text fits entirely within bounds, false otherwise

Example โ€‹
ts
if (renderer.validate.text(x, y, message)) {
  renderer.drawText(x, y, message)
} else {
  // Truncate or wrap text
  renderer.drawText(x, y, message.substring(0, 10))
}

Methods โ€‹

alignBox() โ€‹

alignBox(anchor, width, height, offsetX, offsetY): object

Defined in: core/Renderer.ts:626

Calculate aligned box position

Returns the (x, y) position for a box aligned to a specific anchor point within the viewport. Useful for positioning dialogs, menus, and UI elements.

Parameters โ€‹
anchor โ€‹

BoxAnchor

Alignment anchor (center, top, bottom, left, right, or combinations)

width โ€‹

number

Box width

height โ€‹

number

Box height

offsetX โ€‹

number = 0

X offset from anchor position (default: 0)

offsetY โ€‹

number = 0

Y offset from anchor position (default: 0)

Returns โ€‹

object

Object with x and y coordinates

x โ€‹

x: number

y โ€‹

y: number

Example โ€‹
ts
// Center a 30x10 dialog
const pos = renderer.alignBox('center', 30, 10)
renderer.box(pos.x, pos.y, 30, 10, { style: 'double' })

// Top-right notification with offset
const notifPos = renderer.alignBox('top-right', 20, 5, -2, 1)
renderer.box(notifPos.x, notifPos.y, 20, 5)
alignText() โ€‹

alignText(y, text, options, startX, width?): this

Defined in: core/Renderer.ts:804

Draw aligned text using options.align property

Generic text alignment that uses the align property from TextOptions. Delegates to centerText, rightAlign, or leftAlign based on the setting.

Parameters โ€‹
y โ€‹

number

Y coordinate for the text

text โ€‹

string

Text to draw

options โ€‹

TextOptions = {}

Text styling options (including align property)

startX โ€‹

number = 0

Starting X coordinate of alignment area (default: 0)

width? โ€‹

number

Width of alignment area (default: screen width)

Returns โ€‹

this

The renderer instance for chaining

Example โ€‹
ts
renderer
  .alignText(5, 'Title', { align: 'center', fg: 'yellow' })
  .alignText(10, 'Score', { align: 'right', fg: 'green' })
  .render()
animate() โ€‹

animate(options?): number

Defined in: core/Renderer.ts:1245

Parameters โ€‹
options? โ€‹

AnimateOptions

Returns โ€‹

number

applyBoxPreset() โ€‹

applyBoxPreset(x, y, width, height, presetName, overrides?): this

Defined in: core/Renderer.ts:1457

Apply a box preset

Parameters โ€‹
x โ€‹

number

X coordinate

y โ€‹

number

Y coordinate

width โ€‹

number

Box width

height โ€‹

number

Box height

presetName โ€‹

string

Name of the box preset

overrides? โ€‹

BoxOptions

Optional overrides for preset options

Returns โ€‹

this

The renderer instance for chaining

Example โ€‹
ts
definePreset('panel', { type: 'box', style: 'double', fill: true })
renderer.applyBoxPreset(0, 0, 80, 24, 'panel')
applyMenuPreset() โ€‹

applyMenuPreset(x, y, items, presetName, overrides?): this

Defined in: core/Renderer.ts:1493

Apply a menu preset

Parameters โ€‹
x โ€‹

number

X coordinate

y โ€‹

number

Y coordinate

items โ€‹

string[]

Menu items

presetName โ€‹

string

Name of the menu preset

overrides? โ€‹

MenuOptions

Optional overrides for preset options

Returns โ€‹

this

The renderer instance for chaining

Example โ€‹
ts
definePreset('mainMenu', {
  type: 'menu',
  selectedFg: 'black',
  selectedBg: 'cyan',
  border: true
})
renderer.applyMenuPreset(10, 5, ['Start', 'Quit'], 'mainMenu', {
  selected: 0
})
applyProgressBarPreset() โ€‹

applyProgressBarPreset(x, y, width, progress, presetName, overrides?): this

Defined in: core/Renderer.ts:1526

Apply a progress bar preset

Parameters โ€‹
x โ€‹

number

X coordinate

y โ€‹

number

Y coordinate

width โ€‹

number

Bar width

progress โ€‹

number

Progress value (0.0 to 1.0)

presetName โ€‹

string

Name of the progress bar preset

overrides? โ€‹

ProgressBarOptions

Optional overrides for preset options

Returns โ€‹

this

The renderer instance for chaining

Example โ€‹
ts
definePreset('health', {
  type: 'progressBar',
  fillFg: 'red',
  emptyFg: 'gray'
})
renderer.applyProgressBarPreset(5, 5, 20, 0.75, 'health')
applyTextPreset() โ€‹

applyTextPreset(x, y, text, presetName, overrides?): this

Defined in: core/Renderer.ts:1428

Apply a text preset

Parameters โ€‹
x โ€‹

number

X coordinate

y โ€‹

number

Y coordinate

text โ€‹

string

Text to draw

presetName โ€‹

string

Name of the text preset

overrides? โ€‹

TextOptions

Optional overrides for preset options

Returns โ€‹

this

The renderer instance for chaining

Example โ€‹
ts
// Define preset first
definePreset('warning', { type: 'text', fg: 'yellow', bg: 'red' })

// Use preset
renderer.applyTextPreset(10, 5, 'Warning!', 'warning')
border() โ€‹

border(x, y, w, h, options): this

Defined in: core/Renderer.ts:520

Draw a border without filling the interior

Similar to box() but only draws the border, leaving the interior transparent. Useful for creating frames around existing content.

Parameters โ€‹
x โ€‹

number

Top-left X coordinate

y โ€‹

number

Top-left Y coordinate

w โ€‹

number

Width in characters (including borders)

h โ€‹

number

Height in characters (including borders)

options โ€‹

BoxOptions = {}

Border styling options

Returns โ€‹

this

The renderer instance for chaining

Example โ€‹
ts
renderer
  .drawText(12, 7, 'Important!')
  .border(10, 5, 20, 5, { style: 'double', fg: 'red' })
  .render()
box() โ€‹

box(x, y, w, h, options): this

Defined in: core/Renderer.ts:488

Draw a box with borders and optional fill

Creates a bordered box using various drawing styles. Can optionally fill the interior with a character.

Parameters โ€‹
x โ€‹

number

Top-left X coordinate

y โ€‹

number

Top-left Y coordinate

w โ€‹

number

Width in characters (including borders)

h โ€‹

number

Height in characters (including borders)

options โ€‹

BoxOptions = {}

Box styling options (style, fg, bg, fill, shadow, padding)

Returns โ€‹

this

The renderer instance for chaining

Example โ€‹
ts
renderer
  .box(10, 5, 30, 10, { style: 'double', fg: 'cyan' })
  .box(15, 8, 20, 5, { style: 'rounded', fill: true, bg: 'blue' })
  .render()
centerBox() โ€‹

centerBox(width, height, options, offsetX, offsetY): this

Defined in: core/Renderer.ts:665

Draw a centered box

Convenience method that combines alignBox('center') and box(). Centers a box in the viewport and draws it in one call.

Parameters โ€‹
width โ€‹

number

Box width

height โ€‹

number

Box height

options โ€‹

BoxOptions = {}

Box styling options

offsetX โ€‹

number = 0

X offset from center (default: 0)

offsetY โ€‹

number = 0

Y offset from center (default: 0)

Returns โ€‹

this

The renderer instance for chaining

Example โ€‹
ts
renderer
  .centerBox(40, 15, { style: 'double', fill: true, fg: 'cyan' })
  .centerText(10, 'GAME OVER', { fg: 'red' })
  .render()
centerText() โ€‹

centerText(y, text, options, startX, width?): this

Defined in: core/Renderer.ts:697

Draw centered text

Centers text horizontally within a specified width or the entire screen. Useful for titles, menus, and dialog boxes.

Parameters โ€‹
y โ€‹

number

Y coordinate for the text

text โ€‹

string

Text to draw

options โ€‹

TextOptions = {}

Text styling options

startX โ€‹

number = 0

Starting X coordinate of centering area (default: 0)

width? โ€‹

number

Width of centering area (default: screen width)

Returns โ€‹

this

The renderer instance for chaining

Example โ€‹
ts
renderer
  .centerText(5, 'GAME TITLE', { fg: 'yellow' })
  .centerText(10, 'Centered in box', {}, 10, 30) // Center within x=10 to x=40
  .render()
clear() โ€‹

clear(): this

Defined in: core/Renderer.ts:401

Clear the current layer's buffer

Removes all drawn content from the current layer. Does not affect other layers or the render target. Call render() to flush changes to the screen.

Returns โ€‹

this

The renderer instance for chaining

Example โ€‹
ts
renderer
  .clear() // Clear everything
  .drawText(0, 0, 'Fresh start')
  .render()
clearCameraBounds() โ€‹

clearCameraBounds(): this

Defined in: core/Renderer.ts:1149

Clear camera bounds

Removes any camera movement restrictions, allowing unlimited scrolling.

Returns โ€‹

this

The renderer instance for chaining

Example โ€‹
ts
renderer
  .clearCameraBounds()
  .setCamera(1000, 1000) // No longer restricted
  .render()
clearLayer() โ€‹

clearLayer(name): this

Defined in: core/Renderer.ts:926

Clear a specific layer

Removes all content from the specified layer. The layer itself remains and stays visible.

Parameters โ€‹
name โ€‹

string

Name of the layer to clear

Returns โ€‹

this

The renderer instance for chaining

Example โ€‹
ts
renderer
  .clearLayer('effects')
  .render()
drawLine() โ€‹

drawLine(x1, y1, x2, y2, char, options): this

Defined in: core/Renderer.ts:590

Draw a line between two points

Draws a line from (x1, y1) to (x2, y2) using Bresenham's line algorithm. Useful for creating borders, connections, diagrams, and ASCII art.

Parameters โ€‹
x1 โ€‹

number

Starting X coordinate

y1 โ€‹

number

Starting Y coordinate

x2 โ€‹

number

Ending X coordinate

y2 โ€‹

number

Ending Y coordinate

char โ€‹

string

Character to draw the line with

options โ€‹

TextOptions = {}

Line styling options (fg, bg)

Returns โ€‹

this

The renderer instance for chaining

Example โ€‹
ts
renderer
  .drawLine(0, 0, 10, 10, '/', { fg: 'cyan' })
  .drawLine(10, 0, 0, 10, '\\', { fg: 'cyan' })
  .drawLine(5, 0, 5, 10, '|', { fg: 'yellow' })
  .render()
drawText() โ€‹

drawText(x, y, text, options): this

Defined in: core/Renderer.ts:330

Draw a text string

Draws text horizontally starting at the specified position. Each character is drawn sequentially to the right.

Parameters โ€‹
x โ€‹

number

Starting X coordinate

y โ€‹

number

Y coordinate

text โ€‹

string

Text string to draw

options โ€‹

TextOptions = {}

Text styling options (fg, bg, wrap, align)

Returns โ€‹

this

The renderer instance for chaining

Example โ€‹
ts
renderer
  .drawText(5, 10, 'Hello, World!', { fg: 'cyan' })
  .drawText(5, 11, 'Press any key', { fg: 'gray' })
  .render()
exportAsANSI() โ€‹

exportAsANSI(): string

Defined in: core/Renderer.ts:1382

Export buffer as ANSI-colored text

Returns โ€‹

string

ANSI-colored text string

Example โ€‹
ts
const ansi = renderer.exportAsANSI()
console.log(ansi) // Displays with colors in terminal
exportAsDataURL() โ€‹

exportAsDataURL(format?, options?): Promise<string>

Defined in: core/Renderer.ts:1400

Export buffer as image data URL

Parameters โ€‹
format? โ€‹

ImageFormat

Image format ('png' or 'jpeg')

options? โ€‹

ExportImageOptions

Image export options

Returns โ€‹

Promise<string>

Promise resolving to data URL string

Example โ€‹
ts
const dataURL = await renderer.exportAsDataURL('png')
const img = document.createElement('img')
img.src = dataURL
exportAsString() โ€‹

exportAsString(): string

Defined in: core/Renderer.ts:1367

Export buffer as plain text string

Returns โ€‹

string

Plain text representation of the buffer

Example โ€‹
ts
const text = renderer.exportAsString()
console.log(text)
fill() โ€‹

fill(x, y, w, h, char, fg?, bg?): this

Defined in: core/Renderer.ts:367

Fill a rectangular area

Fills a rectangular region with the specified character and colors. Useful for creating solid backgrounds or clearable areas.

Parameters โ€‹
x โ€‹

number

Starting X coordinate

y โ€‹

number

Starting Y coordinate

w โ€‹

number

Width in characters

h โ€‹

number

Height in characters

char โ€‹

string

Character to fill with

fg? โ€‹

Color

Foreground color (optional)

bg? โ€‹

Color

Background color (optional)

Returns โ€‹

this

The renderer instance for chaining

Example โ€‹
ts
renderer
  .fill(10, 5, 20, 10, ' ', null, 'blue') // Blue background box
  .fill(15, 7, 5, 3, 'โ–‘', 'gray') // Textured area
  .render()
flash() โ€‹

flash(x, y, options?): number

Defined in: core/Renderer.ts:1249

Parameters โ€‹
x โ€‹

number

y โ€‹

number

options? โ€‹

FlashOptions

Returns โ€‹

number

follow() โ€‹

follow(targetX, targetY): this

Defined in: core/Renderer.ts:1196

Center camera on target position

Moves the camera to center on a specific world position. Useful for following a player character or focusing on important events.

Parameters โ€‹
targetX โ€‹

number

World X coordinate to center on

targetY โ€‹

number

World Y coordinate to center on

Returns โ€‹

this

The renderer instance for chaining

Example โ€‹
ts
const player = { x: 150, y: 75 }
renderer
  .follow(player.x, player.y) // Camera centers on player
  .setChar(player.x, player.y, '@', 'yellow')
  .render()
getActiveAnimationCount() โ€‹

getActiveAnimationCount(): number

Defined in: core/Renderer.ts:1272

Returns โ€‹

number

getCamera() โ€‹

getCamera(): object

Defined in: core/Renderer.ts:1098

Get current camera position

Returns the camera's current position in world coordinates.

Returns โ€‹

object

Object with x and y camera coordinates

x โ€‹

x: number

y โ€‹

y: number

Example โ€‹
ts
const { x, y } = renderer.getCamera()
console.log(`Camera at (${x}, ${y})`)
getCell() โ€‹

getCell(x, y): Cell | undefined

Defined in: core/Renderer.ts:463

Get cell at position from current layer

Retrieves the cell data at the specified screen coordinates. Returns undefined if nothing is drawn at that position.

Parameters โ€‹
x โ€‹

number

X coordinate

y โ€‹

number

Y coordinate

Returns โ€‹

Cell | undefined

The cell data or undefined

Example โ€‹
ts
const cell = renderer.getCell(10, 5)
if (cell) {
  console.log(cell.char, cell.fg, cell.bg)
}
hideLayer() โ€‹

hideLayer(name): this

Defined in: core/Renderer.ts:885

Hide a layer

Makes a layer invisible without deleting its contents. Hidden layers are not included in rendering.

Parameters โ€‹
name โ€‹

string

Name of the layer to hide

Returns โ€‹

this

The renderer instance for chaining

Example โ€‹
ts
renderer
  .hideLayer('debug')
  .render() // Debug layer won't be visible
isAnimationActive() โ€‹

isAnimationActive(animationId): boolean

Defined in: core/Renderer.ts:1276

Parameters โ€‹
animationId โ€‹

number

Returns โ€‹

boolean

layer() โ€‹

layer(name): this

Defined in: core/Renderer.ts:843

Select or create a layer

Switches the current drawing context to the specified layer. Layers are created automatically if they don't exist. All subsequent drawing operations affect the current layer.

Parameters โ€‹
name โ€‹

string

Name of the layer to select/create

Returns โ€‹

this

The renderer instance for chaining

Example โ€‹
ts
renderer
  .layer('background').fill(0, 0, 80, 24, ' ', null, 'blue')
  .layer('ui').box(10, 5, 20, 10, { style: 'double' })
  .layerOrder(['background', 'ui'])
  .render()
layerOrder() โ€‹

layerOrder(order): this

Defined in: core/Renderer.ts:864

Set layer rendering order

Defines the order in which layers are composited. Layers listed first are rendered at the bottom, last ones on top.

Parameters โ€‹
order โ€‹

string[]

Array of layer names in rendering order (bottom to top)

Returns โ€‹

this

The renderer instance for chaining

Example โ€‹
ts
renderer
  .layerOrder(['background', 'entities', 'ui', 'effects'])
  .render()
leftAlign() โ€‹

leftAlign(y, text, options, offsetX): this

Defined in: core/Renderer.ts:773

Draw left-aligned text

Draws text starting at a specified X offset. Primarily for consistency with centerText and rightAlign.

Parameters โ€‹
y โ€‹

number

Y coordinate for the text

text โ€‹

string

Text to draw

options โ€‹

TextOptions = {}

Text styling options

offsetX โ€‹

number = 0

X offset from left edge (default: 0)

Returns โ€‹

this

The renderer instance for chaining

Example โ€‹
ts
renderer
  .leftAlign(5, 'Menu Item 1', { fg: 'white' })
  .leftAlign(6, 'Menu Item 2', { fg: 'white' }, 2) // Indent by 2
  .render()

menu(x, y, items, options): this

Defined in: core/Renderer.ts:1038

Draw a menu with selectable items

Renders a list of menu items with visual indication of the selected item. Supports borders, titles, and customizable selection indicators.

Parameters โ€‹
x โ€‹

number

Top-left X coordinate

y โ€‹

number

Top-left Y coordinate

items โ€‹

string[]

Array of menu item strings

options โ€‹

MenuOptions = {}

Menu styling options (selected, colors, indicator, border, title, etc.)

Returns โ€‹

this

The renderer instance for chaining

Example โ€‹
ts
renderer
  .menu(20, 10, ['New Game', 'Load Game', 'Options', 'Quit'], {
    selected: 0,
    indicator: '>',
    border: true,
    title: 'Main Menu',
    selectedFg: 'black',
    selectedBg: 'yellow'
  })
  .render()
moveCamera() โ€‹

moveCamera(dx, dy): this

Defined in: core/Renderer.ts:1172

Move camera by delta

Moves the camera relative to its current position. Positive values move the camera right/down in world space.

Parameters โ€‹
dx โ€‹

number

Change in X position

dy โ€‹

number

Change in Y position

Returns โ€‹

this

The renderer instance for chaining

Example โ€‹
ts
renderer
  .moveCamera(5, 0) // Pan camera 5 units right
  .moveCamera(0, -3) // Pan camera 3 units up
  .render()
panel() โ€‹

panel(x, y, width, height, options): this

Defined in: core/Renderer.ts:1001

Draw a panel with border, title, and content

Creates a bordered box with optional title, footer, and auto-formatted content. Content can be scrolled using the scrollOffset option.

Parameters โ€‹
x โ€‹

number

Top-left X coordinate

y โ€‹

number

Top-left Y coordinate

width โ€‹

number

Width in characters (including border)

height โ€‹

number

Height in characters (including border)

options โ€‹

PanelOptions = {}

Panel styling options (title, footer, content, style, colors, padding, etc.)

Returns โ€‹

this

The renderer instance for chaining

Example โ€‹
ts
renderer
  .panel(10, 5, 40, 15, {
    title: 'Inventory',
    content: ['Sword', 'Shield', 'Potion x3'],
    style: 'double',
    fg: 'cyan',
    padding: 1
  })
  .render()
progressBar() โ€‹

progressBar(x, y, length, progress, options): this

Defined in: core/Renderer.ts:957

Draw a progress bar

Renders a horizontal or vertical progress bar with customizable appearance. Progress value should be between 0.0 and 1.0.

Parameters โ€‹
x โ€‹

number

Top-left X coordinate

y โ€‹

number

Top-left Y coordinate

length โ€‹

number

Length in characters (width if horizontal, height if vertical)

progress โ€‹

number

Progress value from 0.0 to 1.0

options โ€‹

ProgressBarOptions = {}

Progress bar styling options (fillChar, emptyChar, colors, border, label, etc.)

Returns โ€‹

this

The renderer instance for chaining

Example โ€‹
ts
renderer
  .progressBar(10, 5, 30, 0.75, {
    style: 'blocks',
    fillFg: 'green',
    emptyFg: 'gray',
    showPercent: true
  })
  .progressBar(50, 10, 10, 0.5, { vertical: true })
  .render()
pulse() โ€‹

pulse(x, y, options?): number

Defined in: core/Renderer.ts:1253

Parameters โ€‹
x โ€‹

number

y โ€‹

number

options? โ€‹

PulseOptions

Returns โ€‹

number

rect() โ€‹

rect(x, y, w, h, fillChar, fg?, bg?): this

Defined in: core/Renderer.ts:554

Draw a filled rectangle without borders

Creates a solid rectangular area filled with the specified character. No borders are drawn.

Parameters โ€‹
x โ€‹

number

Top-left X coordinate

y โ€‹

number

Top-left Y coordinate

w โ€‹

number

Width in characters

h โ€‹

number

Height in characters

fillChar โ€‹

string = " "

Character to fill with (default: space)

fg? โ€‹

Color

Foreground color (optional)

bg? โ€‹

Color

Background color (optional)

Returns โ€‹

this

The renderer instance for chaining

Example โ€‹
ts
renderer
  .rect(10, 5, 20, 10, ' ', null, 'blue') // Solid blue rectangle
  .rect(15, 8, 10, 5, 'โ–ˆ', 'red') // Solid block pattern
  .render()
render() โ€‹

render(): this

Defined in: core/Renderer.ts:423

Render all layers to the target

Composites all visible layers in order and flushes the result to the render target. This is when drawing actually becomes visible.

Returns โ€‹

this

The renderer instance for chaining

Example โ€‹
ts
renderer
  .clear()
  .box(10, 5, 20, 10)
  .drawText(12, 7, 'Game Over')
  .render() // Now visible on screen
resetCamera() โ€‹

resetCamera(): this

Defined in: core/Renderer.ts:1080

Reset camera to origin (0, 0)

Moves the camera back to the world origin.

Returns โ€‹

this

The renderer instance for chaining

Example โ€‹
ts
renderer
  .resetCamera()
  .render()
rightAlign() โ€‹

rightAlign(y, text, options, startX, width?): this

Defined in: core/Renderer.ts:735

Draw right-aligned text

Aligns text to the right edge of a specified area.

Parameters โ€‹
y โ€‹

number

Y coordinate for the text

text โ€‹

string

Text to draw

options โ€‹

TextOptions = {}

Text styling options

startX โ€‹

number = 0

Starting X coordinate of alignment area (default: 0)

width? โ€‹

number

Width of alignment area (default: screen width)

Returns โ€‹

this

The renderer instance for chaining

Example โ€‹
ts
renderer
  .rightAlign(5, 'Score: 1000', { fg: 'green' })
  .rightAlign(10, 'HP: 75/100', {}, 50, 30) // Right-align within x=50 to x=80
  .render()
screenToWorld() โ€‹

screenToWorld(screenX, screenY): object

Defined in: core/Renderer.ts:1239

Convert screen coordinates to world coordinates

Transforms a screen position to its corresponding world position based on the current camera position. Useful for mouse input handling.

Parameters โ€‹
screenX โ€‹

number

X coordinate in screen space

screenY โ€‹

number

Y coordinate in screen space

Returns โ€‹

object

Object with world x and y coordinates

x โ€‹

x: number

y โ€‹

y: number

Example โ€‹
ts
mouseManager.onClick((pos) => {
  const world = renderer.screenToWorld(pos.x, pos.y)
  console.log(`Clicked world position (${world.x}, ${world.y})`)
})
setCamera() โ€‹

setCamera(x, y): this

Defined in: core/Renderer.ts:1061

Set camera position (top-left of viewport in world coordinates)

Positions the camera at specific world coordinates. All subsequent drawing uses world coordinates, which are transformed by the camera.

Parameters โ€‹
x โ€‹

number

Camera X position in world space

y โ€‹

number

Camera Y position in world space

Returns โ€‹

this

The renderer instance for chaining

Example โ€‹
ts
renderer
  .setCamera(100, 50) // View world at (100, 50)
  .setChar(105, 55, '@') // Draw at world position (105, 55)
  .render() // Character appears at screen position (5, 5)
setCameraBounds() โ€‹

setCameraBounds(minX, minY, maxX, maxY): this

Defined in: core/Renderer.ts:1124

Set camera bounds to limit scrolling area

Prevents the camera from scrolling outside the specified boundaries. All camera movements (setCamera, moveCamera, follow) will be clamped to stay within these bounds.

Parameters โ€‹
minX โ€‹

number

Minimum X coordinate

minY โ€‹

number

Minimum Y coordinate

maxX โ€‹

number

Maximum X coordinate

maxY โ€‹

number

Maximum Y coordinate

Returns โ€‹

this

The renderer instance for chaining

Example โ€‹
ts
// Limit camera to a 100x50 world map
renderer
  .setCameraBounds(0, 0, 100, 50)
  .follow(player.x, player.y) // Auto-clamped to bounds
  .render()
setChar() โ€‹

setChar(x, y, char, fg?, bg?): this

Defined in: core/Renderer.ts:296

Set a character at position (world coordinates)

The fundamental drawing primitive. Positions are in world coordinates, which are transformed by the camera before rendering.

Parameters โ€‹
x โ€‹

number

X coordinate in world space

y โ€‹

number

Y coordinate in world space

char โ€‹

string

Character to display

fg? โ€‹

Color

Foreground color (defaults to renderer's defaultFg)

bg? โ€‹

Color

Background color (defaults to renderer's defaultBg)

Returns โ€‹

this

The renderer instance for chaining

Example โ€‹
ts
renderer
  .setChar(10, 5, '@', 'yellow', 'black')
  .setChar(11, 5, '#', 'green')
  .render()
setClipMode() โ€‹

setClipMode(enabled): this

Defined in: core/Renderer.ts:252

Enable or disable clip mode

When enabled, clips drawing operations to stay within bounds. Useful for preventing visual artifacts when drawing near edges.

Parameters โ€‹
enabled โ€‹

boolean

True to enable clip mode, false to disable

Returns โ€‹

this

The renderer instance for chaining

Example โ€‹
ts
renderer
  .setClipMode(true)
  .drawText(75, 10, 'This text will be clipped at screen edge')
setSafeMode() โ€‹

setSafeMode(enabled): this

Defined in: core/Renderer.ts:231

Enable or disable safe mode

When enabled, throws errors for out-of-bounds operations. When disabled, silently ignores out-of-bounds operations.

Parameters โ€‹
enabled โ€‹

boolean

True to enable safe mode, false to disable

Returns โ€‹

this

The renderer instance for chaining

Example โ€‹
ts
renderer
  .setSafeMode(true)
  .setChar(100, 100, 'X') // Will throw if out of bounds
showLayer() โ€‹

showLayer(name): this

Defined in: core/Renderer.ts:905

Show a layer

Makes a previously hidden layer visible again.

Parameters โ€‹
name โ€‹

string

Name of the layer to show

Returns โ€‹

this

The renderer instance for chaining

Example โ€‹
ts
renderer
  .showLayer('debug')
  .render() // Debug layer is now visible
stopAllAnimations() โ€‹

stopAllAnimations(): this

Defined in: core/Renderer.ts:1262

Returns โ€‹

this

stopAnimation() โ€‹

stopAnimation(animationId): this

Defined in: core/Renderer.ts:1257

Parameters โ€‹
animationId โ€‹

number

Returns โ€‹

this

updateAnimations() โ€‹

updateAnimations(currentTime?): this

Defined in: core/Renderer.ts:1267

Parameters โ€‹
currentTime? โ€‹

number

Returns โ€‹

this

worldToScreen() โ€‹

worldToScreen(worldX, worldY): object

Defined in: core/Renderer.ts:1217

Convert world coordinates to screen coordinates

Transforms a world position to its corresponding screen position based on the current camera position.

Parameters โ€‹
worldX โ€‹

number

X coordinate in world space

worldY โ€‹

number

Y coordinate in world space

Returns โ€‹

object

Object with screen x and y coordinates

x โ€‹

x: number

y โ€‹

y: number

Example โ€‹
ts
const screen = renderer.worldToScreen(100, 50)
console.log(`World (100, 50) is at screen (${screen.x}, ${screen.y})`)
forCanvas() โ€‹

static forCanvas(canvas, options): Renderer

Defined in: core/Renderer.ts:167

Create a Renderer for Canvas with improved, semantic API

Modern factory method with better parameter grouping for improved DX. Recommended over fromCanvas() for new code.

Parameters โ€‹
canvas โ€‹

HTMLCanvasElement

HTML Canvas element to render to

options โ€‹

CanvasRendererOptions

Grouped configuration options

Returns โ€‹

Renderer

A new Renderer instance configured for the canvas

Example โ€‹
ts
const renderer = Renderer.forCanvas(canvas, {
  grid: { width: 80, height: 24 },
  cell: { width: 12, height: 20 },
  font: { family: 'monospace', size: 16 },
  colors: { fg: 'white', bg: 'black' }
})
fromCanvas() โ€‹

static fromCanvas(canvas, canvasOptions, rendererOptions?): Renderer

Defined in: core/Renderer.ts:138

Create a Renderer from an HTML Canvas element

Convenience factory method that creates a CanvasTarget and Renderer in one step. Simplifies the common pattern of creating a canvas-based renderer.

Parameters โ€‹
canvas โ€‹

HTMLCanvasElement

HTML Canvas element to render to

canvasOptions โ€‹

CanvasTargetOptions

Canvas target configuration (width, height, charWidth, etc.)

rendererOptions? โ€‹

RendererCreateOptions

Optional renderer configuration (colors, autoClear)

Returns โ€‹

Renderer

A new Renderer instance configured for the canvas

Example โ€‹
ts
// Instead of:
const target = new CanvasTarget(canvas, { width: 80, height: 24 })
const renderer = new Renderer(target)

// Use:
const renderer = Renderer.fromCanvas(canvas, { width: 80, height: 24 })

Interfaces โ€‹

AnimateOptions โ€‹

Defined in: types/types.ts:286

Options for animate()

Properties โ€‹

delay? โ€‹

optional delay: number

Defined in: types/types.ts:298

Delay before starting in milliseconds

duration? โ€‹

optional duration: number

Defined in: types/types.ts:288

Animation duration in milliseconds

easing? โ€‹

optional easing: EasingFunction

Defined in: types/types.ts:290

Easing function

loop? โ€‹

optional loop: boolean

Defined in: types/types.ts:296

Whether to loop the animation

onComplete? โ€‹

optional onComplete: AnimationCompleteCallback

Defined in: types/types.ts:294

Callback called when animation completes

onUpdate? โ€‹

optional onUpdate: AnimationCallback

Defined in: types/types.ts:292

Callback called on each frame with progress (0.0 to 1.0)


BorderChars โ€‹

Defined in: types/types.ts:66

Custom border characters

Properties โ€‹

bottomLeft โ€‹

bottomLeft: string

Defined in: types/types.ts:69

bottomRight โ€‹

bottomRight: string

Defined in: types/types.ts:70

horizontal โ€‹

horizontal: string

Defined in: types/types.ts:71

topLeft โ€‹

topLeft: string

Defined in: types/types.ts:67

topRight โ€‹

topRight: string

Defined in: types/types.ts:68

vertical โ€‹

vertical: string

Defined in: types/types.ts:72


BoxOptions โ€‹

Defined in: types/types.ts:78

Options for drawing a box

Properties โ€‹

bg? โ€‹

optional bg: Color

Defined in: types/types.ts:84

Background color

fg? โ€‹

optional fg: Color

Defined in: types/types.ts:82

Foreground color

fill? โ€‹

optional fill: boolean

Defined in: types/types.ts:86

Fill the box interior

fillChar? โ€‹

optional fillChar: string

Defined in: types/types.ts:88

Character to fill with when fill is true

padding? โ€‹

optional padding: number

Defined in: types/types.ts:92

Inner padding

shadow? โ€‹

optional shadow: boolean

Defined in: types/types.ts:90

Add shadow effect

style? โ€‹

optional style: BoxStyle | BorderChars

Defined in: types/types.ts:80

Border style to use

title? โ€‹

optional title: string

Defined in: types/types.ts:94

Optional title to display in the top border

titleAlign? โ€‹

optional titleAlign: TextAlign

Defined in: types/types.ts:98

Alignment of the title in the top border

titleFg? โ€‹

optional titleFg: Color

Defined in: types/types.ts:96

Foreground color for the title


BoxPreset โ€‹

Defined in: helpers/presetHelpers.ts:37

Box preset definition

Extends โ€‹

  • BasePreset

Properties โ€‹

options โ€‹

options: BoxOptions

Defined in: helpers/presetHelpers.ts:39

Overrides โ€‹

BasePreset.options

type โ€‹

type: "box"

Defined in: helpers/presetHelpers.ts:38

Overrides โ€‹

BasePreset.type


CanvasRendererOptions โ€‹

Defined in: core/Renderer.ts:50

Options for forCanvas factory method with semantic grouping

Properties โ€‹

autoClear? โ€‹

optional autoClear: boolean

Defined in: core/Renderer.ts:72

Auto-clear behavior

cell? โ€‹

optional cell: object

Defined in: core/Renderer.ts:57

Cell/character sizing

height? โ€‹

optional height: number

width? โ€‹

optional width: number

clearColor? โ€‹

optional clearColor: Color

Defined in: core/Renderer.ts:74

Clear color when autoClear is enabled

colors? โ€‹

optional colors: object

Defined in: core/Renderer.ts:67

Color defaults

bg? โ€‹

optional bg: Color

fg? โ€‹

optional fg: Color

font? โ€‹

optional font: object

Defined in: core/Renderer.ts:62

Font configuration

family? โ€‹

optional family: string

size? โ€‹

optional size: number

grid โ€‹

grid: object

Defined in: core/Renderer.ts:52

Grid dimensions

height โ€‹

height: number

width โ€‹

width: number


CanvasTargetOptions โ€‹

Defined in: targets/CanvasTarget.ts:11

Options for CanvasTarget initialization

Properties โ€‹

charHeight? โ€‹

optional charHeight: number

Defined in: targets/CanvasTarget.ts:19

Character height in pixels

charWidth? โ€‹

optional charWidth: number

Defined in: targets/CanvasTarget.ts:17

Character width in pixels

fontFamily? โ€‹

optional fontFamily: string

Defined in: targets/CanvasTarget.ts:21

Font family

fontSize? โ€‹

optional fontSize: number

Defined in: targets/CanvasTarget.ts:23

Font size in pixels

height โ€‹

height: number

Defined in: targets/CanvasTarget.ts:15

Height in characters

width โ€‹

width: number

Defined in: targets/CanvasTarget.ts:13

Width in characters


Cell โ€‹

Defined in: types/types.ts:49

A single cell in the render buffer

Properties โ€‹

bg โ€‹

bg: Color

Defined in: types/types.ts:55

Background color

char โ€‹

char: string

Defined in: types/types.ts:51

The character to display

fg โ€‹

fg: Color

Defined in: types/types.ts:53

Foreground color


CellInfo โ€‹

Defined in: helpers/debugHelpers.ts:65

Cell information returned by logCell

Properties โ€‹

bg โ€‹

bg: Color

Defined in: helpers/debugHelpers.ts:70

char โ€‹

char: string

Defined in: helpers/debugHelpers.ts:68

fg โ€‹

fg: Color

Defined in: helpers/debugHelpers.ts:69

x โ€‹

x: number

Defined in: helpers/debugHelpers.ts:66

y โ€‹

y: number

Defined in: helpers/debugHelpers.ts:67


DirectionOptions โ€‹

Defined in: input/KeyboardManager.ts:12

Properties โ€‹

normalize? โ€‹

optional normalize: boolean

Defined in: input/KeyboardManager.ts:13


DirectionVector โ€‹

Defined in: input/KeyboardManager.ts:7

Properties โ€‹

x โ€‹

x: number

Defined in: input/KeyboardManager.ts:8

y โ€‹

y: number

Defined in: input/KeyboardManager.ts:9


ExportImageOptions โ€‹

Defined in: helpers/exportHelpers.ts:13

Export options for data URL/image export

Properties โ€‹

backgroundColor? โ€‹

optional backgroundColor: Color

Defined in: helpers/exportHelpers.ts:23

Background color for transparent areas

charHeight? โ€‹

optional charHeight: number

Defined in: helpers/exportHelpers.ts:17

Character height in pixels (default: 16)

charWidth? โ€‹

optional charWidth: number

Defined in: helpers/exportHelpers.ts:15

Character width in pixels (default: 10)

fontFamily? โ€‹

optional fontFamily: string

Defined in: helpers/exportHelpers.ts:19

Font family (default: 'monospace')

fontSize? โ€‹

optional fontSize: number

Defined in: helpers/exportHelpers.ts:21

Font size in pixels (default: 14)


FlashOptions โ€‹

Defined in: types/types.ts:304

Options for flash()

Properties โ€‹

bg? โ€‹

optional bg: Color

Defined in: types/types.ts:314

Background color

char? โ€‹

optional char: string

Defined in: types/types.ts:310

Character to flash

count? โ€‹

optional count: number

Defined in: types/types.ts:308

Number of times to flash

duration? โ€‹

optional duration: number

Defined in: types/types.ts:306

Flash duration in milliseconds

fg? โ€‹

optional fg: Color

Defined in: types/types.ts:312

Foreground color

onComplete? โ€‹

optional onComplete: AnimationCompleteCallback

Defined in: types/types.ts:316

Callback when flash completes


GameLoopOptions โ€‹

Defined in: core/GameLoop.ts:5

Game loop utility with fixed timestep and delta time support

Properties โ€‹

fps? โ€‹

optional fps: number

Defined in: core/GameLoop.ts:7

Target frames per second (default: 60)

maxFrameSkip? โ€‹

optional maxFrameSkip: number

Defined in: core/GameLoop.ts:9

Maximum number of update calls per frame (prevents spiral of death)


GamepadAxisState โ€‹

Defined in: input/GamepadManager.ts:14

Properties โ€‹

x โ€‹

x: number

Defined in: input/GamepadManager.ts:15

y โ€‹

y: number

Defined in: input/GamepadManager.ts:16


GamepadButtonState โ€‹

Defined in: input/GamepadManager.ts:7

Properties โ€‹

justPressed โ€‹

justPressed: boolean

Defined in: input/GamepadManager.ts:9

justReleased โ€‹

justReleased: boolean

Defined in: input/GamepadManager.ts:10

pressed โ€‹

pressed: boolean

Defined in: input/GamepadManager.ts:8

value โ€‹

value: number

Defined in: input/GamepadManager.ts:11


Defined in: types/types.ts:169

Options for menu rendering

Properties โ€‹

bg? โ€‹

optional bg: Color

Defined in: types/types.ts:175

Background color for unselected items

border? โ€‹

optional border: boolean

Defined in: types/types.ts:183

Draw a border around the menu

fg? โ€‹

optional fg: Color

Defined in: types/types.ts:173

Foreground color for unselected items

indicator? โ€‹

optional indicator: string

Defined in: types/types.ts:181

Selection indicator character (e.g., '>' or 'โ€ข')

padding? โ€‹

optional padding: number

Defined in: types/types.ts:191

Padding inside the menu

selected? โ€‹

optional selected: number

Defined in: types/types.ts:171

Index of selected item (0-based)

selectedBg? โ€‹

optional selectedBg: Color

Defined in: types/types.ts:179

Background color for selected item

selectedFg? โ€‹

optional selectedFg: Color

Defined in: types/types.ts:177

Foreground color for selected item

style? โ€‹

optional style: BoxStyle

Defined in: types/types.ts:185

Box style for border

title? โ€‹

optional title: string

Defined in: types/types.ts:187

Menu title (displayed in top border if border is true)

width? โ€‹

optional width: number

Defined in: types/types.ts:189

Fixed width (auto-calculated if not specified)


Defined in: helpers/presetHelpers.ts:45

Menu preset definition

Extends โ€‹

  • BasePreset

Properties โ€‹

options โ€‹

options: MenuOptions

Defined in: helpers/presetHelpers.ts:47

Overrides โ€‹

BasePreset.options

type โ€‹

type: "menu"

Defined in: helpers/presetHelpers.ts:46

Overrides โ€‹

BasePreset.type


MouseEvent โ€‹

Defined in: input/MouseManager.ts:13

Properties โ€‹

event โ€‹

event: MouseEvent

Defined in: input/MouseManager.ts:16

grid โ€‹

grid: MousePosition

Defined in: input/MouseManager.ts:15

pixel โ€‹

pixel: MousePosition

Defined in: input/MouseManager.ts:14


MousePosition โ€‹

Defined in: input/MouseManager.ts:8

Mouse input manager for handling mouse events and state

Deprecated โ€‹

Use PointerManager instead for unified mouse/touch/pen support

See โ€‹

PointerManager

Properties โ€‹

x โ€‹

x: number

Defined in: input/MouseManager.ts:9

y โ€‹

y: number

Defined in: input/MouseManager.ts:10


PanelOptions โ€‹

Defined in: types/types.ts:234

Options for panel rendering

Properties โ€‹

bg? โ€‹

optional bg: Color

Defined in: types/types.ts:246

Background color

content? โ€‹

optional content: string[]

Defined in: types/types.ts:248

Content lines to display

contentAlign? โ€‹

optional contentAlign: TextAlign

Defined in: types/types.ts:250

Content alignment

fg? โ€‹

optional fg: Color

Defined in: types/types.ts:244

Foreground color

fill? โ€‹

optional fill: boolean

Defined in: types/types.ts:254

Fill panel background

fillChar? โ€‹

optional fillChar: string

Defined in: types/types.ts:256

Fill character when fill is true

optional footer: string

Defined in: types/types.ts:240

Panel footer (displayed in bottom border)

padding? โ€‹

optional padding: number

Defined in: types/types.ts:258

Inner padding

scrollOffset? โ€‹

optional scrollOffset: number

Defined in: types/types.ts:252

Scroll offset for content (0-based line index)

style? โ€‹

optional style: BoxStyle

Defined in: types/types.ts:242

Box style for border

title? โ€‹

optional title: string

Defined in: types/types.ts:236

Panel title (displayed in top border)

titleAlign? โ€‹

optional titleAlign: TextAlign

Defined in: types/types.ts:238

Title alignment


Point โ€‹

Defined in: types/types.ts:354

A 2D point or position

Example โ€‹

ts
const playerPos: Point = { x: 10, y: 5 };
renderer.setChar(playerPos.x, playerPos.y, '@');

Properties โ€‹

x โ€‹

x: number

Defined in: types/types.ts:356

X coordinate

y โ€‹

y: number

Defined in: types/types.ts:358

Y coordinate


PointerEvent โ€‹

Defined in: input/PointerManager.ts:11

Properties โ€‹

event โ€‹

event: PointerEvent

Defined in: input/PointerManager.ts:14

grid โ€‹

grid: PointerPosition

Defined in: input/PointerManager.ts:13

pixel โ€‹

pixel: PointerPosition

Defined in: input/PointerManager.ts:12


PointerPosition โ€‹

Defined in: input/PointerManager.ts:6

Pointer input manager for handling mouse, touch, and pen events Uses the Pointer Events API for unified input handling across devices

Properties โ€‹

x โ€‹

x: number

Defined in: input/PointerManager.ts:7

y โ€‹

y: number

Defined in: input/PointerManager.ts:8


ProgressBarOptions โ€‹

Defined in: types/types.ts:202

Options for progress bar rendering

Properties โ€‹

border? โ€‹

optional border: boolean

Defined in: types/types.ts:216

Draw border around progress bar

borderChars? โ€‹

optional borderChars: [string, string]

Defined in: types/types.ts:218

Border characters (defaults to [ and ])

emptyBg? โ€‹

optional emptyBg: Color

Defined in: types/types.ts:214

Background color for empty portion

emptyChar? โ€‹

optional emptyChar: string

Defined in: types/types.ts:206

Character for empty portion

emptyFg? โ€‹

optional emptyFg: Color

Defined in: types/types.ts:212

Foreground color for empty portion

fillBg? โ€‹

optional fillBg: Color

Defined in: types/types.ts:210

Background color for filled portion

fillChar? โ€‹

optional fillChar: string

Defined in: types/types.ts:204

Character for filled portion

fillFg? โ€‹

optional fillFg: Color

Defined in: types/types.ts:208

Foreground color for filled portion

label? โ€‹

optional label: string

Defined in: types/types.ts:222

Custom label to display

labelPosition? โ€‹

optional labelPosition: "left" | "center" | "right"

Defined in: types/types.ts:224

Label position

showPercent? โ€‹

optional showPercent: boolean

Defined in: types/types.ts:220

Show percentage label

style? โ€‹

optional style: ProgressBarStyle

Defined in: types/types.ts:228

Style preset

vertical? โ€‹

optional vertical: boolean

Defined in: types/types.ts:226

Render vertically instead of horizontally


ProgressBarPreset โ€‹

Defined in: helpers/presetHelpers.ts:53

Progress bar preset definition

Extends โ€‹

  • BasePreset

Properties โ€‹

options โ€‹

options: ProgressBarOptions

Defined in: helpers/presetHelpers.ts:55

Overrides โ€‹

BasePreset.options

type โ€‹

type: "progressBar"

Defined in: helpers/presetHelpers.ts:54

Overrides โ€‹

BasePreset.type


PulseOptions โ€‹

Defined in: types/types.ts:322

Options for pulse()

Properties โ€‹

bg? โ€‹

optional bg: Color

Defined in: types/types.ts:336

Background color

duration? โ€‹

optional duration: number

Defined in: types/types.ts:324

Pulse duration in milliseconds

easing? โ€‹

optional easing: EasingFunction

Defined in: types/types.ts:330

Easing function

fg? โ€‹

optional fg: Color

Defined in: types/types.ts:334

Foreground color

loop? โ€‹

optional loop: boolean

Defined in: types/types.ts:332

Whether to loop the pulse

maxIntensity? โ€‹

optional maxIntensity: number

Defined in: types/types.ts:328

Maximum opacity/intensity (0.0 to 1.0)

minIntensity? โ€‹

optional minIntensity: number

Defined in: types/types.ts:326

Minimum opacity/intensity (0.0 to 1.0)

onComplete? โ€‹

optional onComplete: AnimationCompleteCallback

Defined in: types/types.ts:338

Callback when pulse completes (only called if not looping)


Rect โ€‹

Defined in: types/types.ts:370

A rectangle defined by position and dimensions

Example โ€‹

ts
const bounds: Rect = { x: 5, y: 5, width: 20, height: 10 };
renderer.box(bounds.x, bounds.y, bounds.width, bounds.height);

Properties โ€‹

height โ€‹

height: number

Defined in: types/types.ts:378

Height in characters

width โ€‹

width: number

Defined in: types/types.ts:376

Width in characters

x โ€‹

x: number

Defined in: types/types.ts:372

X coordinate of top-left corner

y โ€‹

y: number

Defined in: types/types.ts:374

Y coordinate of top-left corner


RendererCreateOptions โ€‹

Defined in: core/Renderer.ts:36

Renderer initialization options

Properties โ€‹

autoClear? โ€‹

optional autoClear: boolean

Defined in: core/Renderer.ts:42

Auto-clear the render target each frame

clearColor? โ€‹

optional clearColor: Color

Defined in: core/Renderer.ts:44

Optional clear color when autoClear is enabled

defaultBg? โ€‹

optional defaultBg: Color

Defined in: core/Renderer.ts:40

Default background color

defaultFg? โ€‹

optional defaultFg: Color

Defined in: core/Renderer.ts:38

Default foreground color


RendererOptions โ€‹

Defined in: types/types.ts:123

Renderer configuration options

Properties โ€‹

defaultBg? โ€‹

optional defaultBg: Color

Defined in: types/types.ts:131

Default background color

defaultFg? โ€‹

optional defaultFg: Color

Defined in: types/types.ts:129

Default foreground color

height โ€‹

height: number

Defined in: types/types.ts:127

Height in characters

width โ€‹

width: number

Defined in: types/types.ts:125

Width in characters


RenderTarget โ€‹

Defined in: types/types.ts:138

Abstract interface for render targets Allows rendering to different outputs (Canvas, DOM, Terminal, etc.)

Methods โ€‹

clear() โ€‹

clear(): void

Defined in: types/types.ts:152

Clear the entire render target

Returns โ€‹

void

flush() โ€‹

flush(): void

Defined in: types/types.ts:157

Flush all pending changes to the actual output

Returns โ€‹

void

getSize() โ€‹

getSize(): object

Defined in: types/types.ts:163

Get the size of the render target

Returns โ€‹

object

Width and height in characters

height โ€‹

height: number

width โ€‹

width: number

setCell() โ€‹

setCell(x, y, char, fg, bg): void

Defined in: types/types.ts:147

Set a character at the specified position

Parameters โ€‹
x โ€‹

number

X coordinate (0-indexed)

y โ€‹

number

Y coordinate (0-indexed)

char โ€‹

string

Character to display

fg โ€‹

Color

Foreground color

bg โ€‹

Color

Background color

Returns โ€‹

void


RGBColor โ€‹

Defined in: types/types.ts:35

RGB color object

Properties โ€‹

b โ€‹

b: number

Defined in: types/types.ts:38

g โ€‹

g: number

Defined in: types/types.ts:37

r โ€‹

r: number

Defined in: types/types.ts:36


ShowBoundsOptions โ€‹

Defined in: helpers/debugHelpers.ts:25

Options for showing bounds

Properties โ€‹

fg? โ€‹

optional fg: Color

Defined in: helpers/debugHelpers.ts:27

Foreground color

fill? โ€‹

optional fill: boolean

Defined in: helpers/debugHelpers.ts:31

Fill the bounds with a transparent pattern

label? โ€‹

optional label: string

Defined in: helpers/debugHelpers.ts:29

Label to display (positioned at top-left corner)


ShowFPSOptions โ€‹

Defined in: helpers/debugHelpers.ts:37

Options for showing FPS counter

Properties โ€‹

bg? โ€‹

optional bg: Color

Defined in: helpers/debugHelpers.ts:45

Background color

fg? โ€‹

optional fg: Color

Defined in: helpers/debugHelpers.ts:43

Foreground color

x? โ€‹

optional x: number

Defined in: helpers/debugHelpers.ts:39

X position (default: 0)

y? โ€‹

optional y: number

Defined in: helpers/debugHelpers.ts:41

Y position (default: 0)


ShowGridOptions โ€‹

Defined in: helpers/debugHelpers.ts:13

Options for showing a grid overlay

Properties โ€‹

char? โ€‹

optional char: string

Defined in: helpers/debugHelpers.ts:19

Character to use for grid lines (default: 'ยท' for dots, 'โ”ผ' for intersections)

fg? โ€‹

optional fg: Color

Defined in: helpers/debugHelpers.ts:17

Grid line color

spacing? โ€‹

optional spacing: number

Defined in: helpers/debugHelpers.ts:15

Grid line spacing (default: 10)


ShowPointerCoordsOptions โ€‹

Defined in: helpers/debugHelpers.ts:51

Options for showing pointer coordinates

Properties โ€‹

bg? โ€‹

optional bg: Color

Defined in: helpers/debugHelpers.ts:59

Background color

fg? โ€‹

optional fg: Color

Defined in: helpers/debugHelpers.ts:57

Foreground color

x? โ€‹

optional x: number

Defined in: helpers/debugHelpers.ts:53

X position for the display (default: 0)

y? โ€‹

optional y: number

Defined in: helpers/debugHelpers.ts:55

Y position for the display (default: 0)


Size โ€‹

Defined in: types/types.ts:389

Dimensions (width and height)

Example โ€‹

ts
const gridSize: Size = { width: 80, height: 24 };

Properties โ€‹

height โ€‹

height: number

Defined in: types/types.ts:393

Height in characters

width โ€‹

width: number

Defined in: types/types.ts:391

Width in characters


TextOptions โ€‹

Defined in: types/types.ts:109

Options for drawing text

Properties โ€‹

align? โ€‹

optional align: TextAlign

Defined in: types/types.ts:117

Text alignment

bg? โ€‹

optional bg: Color

Defined in: types/types.ts:113

Background color

fg? โ€‹

optional fg: Color

Defined in: types/types.ts:111

Foreground color

wrap? โ€‹

optional wrap: boolean

Defined in: types/types.ts:115

Enable word wrapping


TextPreset โ€‹

Defined in: helpers/presetHelpers.ts:29

Text preset definition

Extends โ€‹

  • BasePreset

Properties โ€‹

options โ€‹

options: TextOptions

Defined in: helpers/presetHelpers.ts:31

Overrides โ€‹

BasePreset.options

type โ€‹

type: "text"

Defined in: helpers/presetHelpers.ts:30

Overrides โ€‹

BasePreset.type


WaitForKeyOptions โ€‹

Defined in: input/KeyboardManager.ts:16

Properties โ€‹

signal? โ€‹

optional signal: AbortSignal

Defined in: input/KeyboardManager.ts:18

timeout? โ€‹

optional timeout: number

Defined in: input/KeyboardManager.ts:17

Type Aliases โ€‹

AnimationCallback() โ€‹

AnimationCallback = (progress) => void

Defined in: types/types.ts:276

Animation callback function

Parameters โ€‹

progress โ€‹

number

Animation progress (0.0 to 1.0)

Returns โ€‹

void


AnimationCompleteCallback() โ€‹

AnimationCompleteCallback = () => void

Defined in: types/types.ts:281

Animation completion callback

Returns โ€‹

void


BoxStyle โ€‹

BoxStyle = "single" | "double" | "rounded" | "heavy" | "ascii"

Defined in: types/types.ts:61

Box border styles


Color โ€‹

Color = NamedColor | HexColor | RGBColor | null

Defined in: types/types.ts:44

All supported color formats


EasingFunction โ€‹

EasingFunction = "linear" | "easeIn" | "easeOut" | "easeInOut" | "bounce" | "elastic"

Defined in: types/types.ts:264

Easing functions for animations


GamepadCallback() โ€‹

GamepadCallback = (gamepad) => void

Defined in: input/GamepadManager.ts:5

Gamepad/Controller input manager using the native Gamepad API

Parameters โ€‹

gamepad โ€‹

Gamepad

Returns โ€‹

void


HexColor โ€‹

HexColor = `#${string}`

Defined in: types/types.ts:30

Hex color string (e.g., "#ff0000")


ImageFormat โ€‹

ImageFormat = "png" | "jpeg"

Defined in: helpers/exportHelpers.ts:29

Image format for export


KeyCallback() โ€‹

KeyCallback = (event) => void

Defined in: input/KeyboardManager.ts:5

Keyboard input manager for handling key events and state

Parameters โ€‹

event โ€‹

KeyboardEvent

Returns โ€‹

void


MouseCallback() โ€‹

MouseCallback = (event) => void

Defined in: input/MouseManager.ts:19

Parameters โ€‹

event โ€‹

MouseEvent

Returns โ€‹

void


NamedColor โ€‹

NamedColor = "black" | "red" | "green" | "yellow" | "blue" | "magenta" | "cyan" | "white" | "gray" | "grey" | "brightRed" | "brightGreen" | "brightYellow" | "brightBlue" | "brightMagenta" | "brightCyan" | "brightWhite"

Defined in: types/types.ts:8

Named ANSI colors


PointerCallback() โ€‹

PointerCallback = (event) => void

Defined in: input/PointerManager.ts:17

Parameters โ€‹

event โ€‹

PointerEvent

Returns โ€‹

void


Preset โ€‹

Preset = TextPreset | BoxPreset | MenuPreset | ProgressBarPreset

Defined in: helpers/presetHelpers.ts:61

Union type of all preset types


PresetDefinition โ€‹

PresetDefinition = object & TextOptions | object & BoxOptions | object & MenuOptions | object & ProgressBarOptions

Defined in: helpers/presetHelpers.ts:66

Preset definition for definePreset function


PresetType โ€‹

PresetType = "text" | "box" | "menu" | "progressBar"

Defined in: helpers/presetHelpers.ts:16

Preset type discriminators


ProgressBarStyle โ€‹

ProgressBarStyle = "blocks" | "dots" | "arrows" | "custom"

Defined in: types/types.ts:197

Progress bar style presets


RenderCallback() โ€‹

RenderCallback = () => void

Defined in: core/GameLoop.ts:13

Returns โ€‹

void


TextAlign โ€‹

TextAlign = "left" | "center" | "right"

Defined in: types/types.ts:104

Text alignment options


UpdateCallback() โ€‹

UpdateCallback = (delta) => void

Defined in: core/GameLoop.ts:12

Parameters โ€‹

delta โ€‹

number

Returns โ€‹

void

Functions โ€‹

brighten() โ€‹

brighten(color, amount): RGBColor

Defined in: drawing/colors.ts:138

Brighten a color by a given amount

Parameters โ€‹

color โ€‹

Color

Color to brighten

amount โ€‹

number

Amount to brighten (0-1)

Returns โ€‹

RGBColor

Brightened RGB color


clearAllPresets() โ€‹

clearAllPresets(): void

Defined in: helpers/presetHelpers.ts:174

Clear all defined presets

Removes all presets from the registry. Useful for testing or resetting the preset system.

Returns โ€‹

void

Example โ€‹

ts
clearAllPresets()
console.log(listPresets()) // []

darken() โ€‹

darken(color, amount): RGBColor

Defined in: drawing/colors.ts:155

Darken a color by a given amount

Parameters โ€‹

color โ€‹

Color

Color to darken

amount โ€‹

number

Amount to darken (0-1)

Returns โ€‹

RGBColor

Darkened RGB color


definePreset() โ€‹

definePreset(name, definition): void

Defined in: helpers/presetHelpers.ts:118

Define a reusable style preset

Presets allow you to define commonly used styles once and reuse them throughout your application. Supports text, box, menu, and progress bar styles.

Parameters โ€‹

name โ€‹

string

Unique name for the preset

definition โ€‹

PresetDefinition

Preset definition with type and options

Returns โ€‹

void

Example โ€‹

ts
// Define text presets
definePreset('title', {
  type: 'text',
  fg: 'yellow',
  bg: 'blue',
  align: 'center'
})

// Define box preset
definePreset('panel', {
  type: 'box',
  style: 'double',
  fg: 'cyan',
  fill: true
})

// Define menu preset
definePreset('mainMenu', {
  type: 'menu',
  selectedFg: 'black',
  selectedBg: 'white',
  border: true,
  style: 'rounded'
})

// Use presets
renderer.applyTextPreset(10, 5, 'Game Title', 'title')
renderer.applyBoxPreset(0, 0, 80, 24, 'panel')

getPreset() โ€‹

getPreset(name): Preset | undefined

Defined in: helpers/presetHelpers.ts:143

Get a preset by name

Parameters โ€‹

name โ€‹

string

Preset name

Returns โ€‹

Preset | undefined

Preset definition, or undefined if not found

Example โ€‹

ts
const preset = getPreset('title')
if (preset && preset.type === 'text') {
  console.log(preset.options.fg) // 'yellow'
}

lerp() โ€‹

lerp(color1, color2, t): RGBColor

Defined in: drawing/colors.ts:120

Interpolate between two colors

Parameters โ€‹

color1 โ€‹

Color

First color

color2 โ€‹

Color

Second color

t โ€‹

number

Interpolation factor (0-1)

Returns โ€‹

RGBColor

Interpolated RGB color


listPresets() โ€‹

listPresets(): string[]

Defined in: helpers/presetHelpers.ts:158

List all defined preset names

Returns โ€‹

string[]

Array of preset names

Example โ€‹

ts
const presets = listPresets()
console.log(presets) // ['title', 'panel', 'mainMenu']

parseColor() โ€‹

parseColor(color): RGBColor | null

Defined in: drawing/colors.ts:62

Parse any color format to RGB

Parameters โ€‹

color โ€‹

Color

Color in any supported format

Returns โ€‹

RGBColor | null

RGB color object or null


rgbToHex() โ€‹

rgbToHex(color): `#${string}`

Defined in: drawing/colors.ts:91

Convert RGB color to hex string

Parameters โ€‹

color โ€‹

RGBColor

RGB color

Returns โ€‹

`#${string}`

Hex color string


toCSSColor() โ€‹

toCSSColor(color): string

Defined in: drawing/colors.ts:105

Convert color to CSS-compatible string

Parameters โ€‹

color โ€‹

Color

Color in any format

Returns โ€‹

string

CSS color string

Released under the MIT License.