UNPKG

@promptbook/wizard

Version:

Promptbook: Create persistent AI agents that turn your company's scattered knowledge into action

81 lines (80 loc) 2.7 kB
/** * Color depth of the ANSI escape codes emitted by the ASCII-art conversion. * * - `TRUE_COLOR` emits 24-bit `38;2;r;g;b` / `48;2;r;g;b` sequences * - `ANSI_256` approximates colors on the 256-color ANSI cube for older terminals * * @private within the repository */ export type AsciiArtColorDepth = 'TRUE_COLOR' | 'ANSI_256'; /** * Minimal structural subset of the DOM `ImageData` accepted by the ASCII-art conversion. * * Works with browser canvas `ImageData`, `@napi-rs/canvas` image data, or any raw RGBA buffer. * * @private within the repository */ export type AsciiArtImageData = { /** * Source image width in pixels. */ readonly width: number; /** * Source image height in pixels. */ readonly height: number; /** * Flat RGBA pixel buffer with 4 bytes per pixel. */ readonly data: ArrayLike<number>; }; /** * Options for `convertImageDataToAsciiArt`. * * @private within the repository */ export type ConvertImageDataToAsciiArtOptions = { /** * Source pixels to convert. */ readonly imageData: AsciiArtImageData; /** * Output width in terminal character cells. */ readonly columns: number; /** * Output height in terminal character cells. * * Each character cell renders two vertically stacked pixels, so `rows = columns / 2` * keeps a square image visually square in a common terminal font. */ readonly rows: number; /** * Color depth of the emitted ANSI escape codes. * * @default 'TRUE_COLOR' */ readonly colorDepth?: AsciiArtColorDepth; /** * Alpha channel value (0-255) below which an averaged half-cell is treated as fully transparent. * * @default 32 */ readonly alphaThreshold?: number; }; /** * Converts raw RGBA image pixels into colored ASCII art for ANSI terminals. * * This is the universal image-to-terminal technique used across the repository: * every output character cell covers a rectangular region of source pixels which is * split into a top and bottom half; each half is area-averaged and rendered with * half-block characters (`▀` / `▄`) so one character shows two "pixels" vertically. * Transparent halves keep the terminal background so non-rectangular images * (for example rounded avatar cards) compose naturally into any terminal UI. * * @param options Source pixels, output grid size, and ANSI color depth. * @returns One ANSI-colored string per output row, each ending with a color reset. * * @private within the repository */ export declare function convertImageDataToAsciiArt(options: ConvertImageDataToAsciiArtOptions): ReadonlyArray<string>;