Skip to content

Documentation / @ripl/terminal / BrailleRasterizer

Class: BrailleRasterizer ​

Defined in: terminal/src/rasterizer.ts:100

Braille-dot rasterizer. Each terminal cell encodes a 2×4 grid of sub-pixel dots via Unicode braille patterns (U+2800–U+28FF).

Pixels are held as an RGBA framebuffer at dot resolution and composited source-over, so two shapes overlapping inside one cell blend rather than the later one taking the whole cell. A cell emits a single color — that is what a character can express — resolved as the alpha-weighted mean of its lit dots.

Implements ​

Constructors ​

Constructor ​

new BrailleRasterizer(cols, rows, options?): BrailleRasterizer

Defined in: terminal/src/rasterizer.ts:135

Parameters ​

ParameterType
colsnumber
rowsnumber
options?BrailleRasterizerOptions

Returns ​

BrailleRasterizer

Accessors ​

cellHeight ​

Get Signature ​

get cellHeight(): number

Defined in: terminal/src/rasterizer.ts:131

Height of one braille cell, in pixels.

Returns ​

number

Height of one character cell, in pixels.

Implementation of ​

Rasterizer.cellHeight


cellWidth ​

Get Signature ​

get cellWidth(): number

Defined in: terminal/src/rasterizer.ts:126

Width of one braille cell, in pixels.

Returns ​

number

Width of one character cell, in pixels.

Implementation of ​

Rasterizer.cellWidth


pixelHeight ​

Get Signature ​

get pixelHeight(): number

Defined in: terminal/src/rasterizer.ts:121

Total pixel height of the grid (rows times cell height).

Returns ​

number

Total height of the pixel grid the rasterizer renders into.

Implementation of ​

Rasterizer.pixelHeight


pixelWidth ​

Get Signature ​

get pixelWidth(): number

Defined in: terminal/src/rasterizer.ts:116

Total pixel width of the grid (columns times cell width).

Returns ​

number

Total width of the pixel grid the rasterizer renders into.

Implementation of ​

Rasterizer.pixelWidth

Methods ​

clear() ​

clear(): void

Defined in: terminal/src/rasterizer.ts:288

Clears all pixels, characters, and colors from the grid.

Returns ​

void

Implementation of ​

Rasterizer.clear


resize() ​

resize(cols, rows): void

Defined in: terminal/src/rasterizer.ts:250

Resizes the grid to the given columns and rows, discarding all existing contents.

Parameters ​

ParameterType
colsnumber
rowsnumber

Returns ​

void

Implementation of ​

Rasterizer.resize


serialize() ​

serialize(options?): string

Defined in: terminal/src/rasterizer.ts:367

Serializes the grid to a string, including ANSI color and cursor codes unless ansi is disabled. The ANSI form erases past the end of every row and past the last row, so a grid that has shrunk since the previous frame does not leave the old output stranded on screen.

Parameters ​

ParameterType
options?SerializeOptions

Returns ​

string

Implementation of ​

Rasterizer.serialize


setChar() ​

setChar(col, row, char, color): void

Defined in: terminal/src/rasterizer.ts:276

Places a literal character in the given cell, overriding its braille dots; out-of-bounds cells are ignored.

Parameters ​

ParameterType
colnumber
rownumber
charstring
colorTerminalColor

Returns ​

void

Implementation of ​

Rasterizer.setChar


setPixel() ​

setPixel(x, y, color): void

Defined in: terminal/src/rasterizer.ts:259

Composites color onto the braille dot covering pixel (x, y); out-of-bounds and non-finite pixels are ignored.

Parameters ​

ParameterType
xnumber
ynumber
colorTerminalColor

Returns ​

void

Implementation of ​

Rasterizer.setPixel


toImageData() ​

toImageData(): ImageData

Defined in: terminal/src/rasterizer.ts:396

Rasterizes the grid to environment-agnostic RGBA pixel data. A glyph occupies a whole cell, which is 2×4 pixels here — far too small for a legible letterform — so each one rasterizes as a filled block. Text reads as a solid bar rather than disappearing from the image entirely.

Returns ​

ImageData

Implementation of ​

Rasterizer.toImageData