Skip to main content
Module

x/tui/mod.ts>Canvas

🦕 Deno module for creating Terminal User Interfaces
Go to Latest
class Canvas
Re-export
import { Canvas } from "https://deno.land/x/tui@1.0.2/mod.ts";

Canvas implementation that can be drawn onto and then rendered on terminal screen

Constructors

new
Canvas(unnamed 0: CanvasOptions)

Properties

fps: number
frameBuffer: string[][]
lastRender: number
previousFrameBuffer: this["frameBuffer"]
refreshRate: number
stdout: Stdout

Methods

draw(
column: number,
row: number,
value: string,
rectangle?: Rectangle,
): void

Render value starting on column and row on canvas

When rectangle is given: If particular part of the rendering doesn't fit within rectangle boundaries then it's not drawn

render(): AsyncGenerator<Timing, void, void>

Runs a loop in which it checks whether frameBuffer has changed (anything new has been drawn). If so, run renderFrame() with current frame buffer and in the way yield and emit proper events. On each iteration it sleeps for adjusted refreshRate time.

renderFrame(frame: string[][]): void

Checks for individual row and column changes in canvas, then renders just the changes. In the way yield and emit proper events.

Change size property, then clear frameBuffer and previousFrameBuffer to force re-render all of the canvas If size parameter matches canvas's size property then nothing happens