@thi.ng/text-canvas
Version:
Text based canvas, drawing, plotting, tables with arbitrary formatting (incl. ANSI/HTML)
103 lines • 2.77 kB
TypeScript
import type { FnN, NumOrString } from "@thi.ng/api";
export declare enum Align {
LEFT = 0,
RIGHT = 1,
CENTER = 2
}
export declare enum Border {
NONE = 0,
H = 1,
V = 2,
ALL = 3,
FRAME = 4,
FRAME_H = 5,
FRAME_V = 6
}
export type BlendFn = (src: number, dest: number, x: number, y: number) => number;
export interface TableOpts {
cols: {
width: number;
}[];
style?: StrokeStyle;
format?: number;
formatHead?: number;
border?: Border;
padding?: number[];
hard?: boolean;
}
export interface TextBoxOpts {
format: number;
padding: number[];
style: StrokeStyle;
hard?: boolean;
}
export interface ImageOpts {
/**
* Target characters in order of increasing brightness (assuming
* white text on black bg).
*
* @defaultValue {@link SHADES_BLOCK}
*/
chars: string | NumOrString[];
/**
* Format to apply to each pixel. If a function is given, it will be called
* for each pixel value, normalized to `[0,1]` interval (and after gamma
* correction). The function MUST return a valid format ID.
*/
format: number | FnN;
/**
* Gamma correction value / exponent. All source pixel values will
* be raised by this exponent.
*
* @defaultValue 1
*/
gamma: number;
/**
* If true, uses inverted pixel values.
*
* @defaultValue false
*/
invert: boolean;
/**
* Number of bits/pixel in source image (only grayscale supported)
*
* @defaultValue 8
*/
bits: number;
}
export interface ClipRect {
x1: number;
y1: number;
x2: number;
y2: number;
w: number;
h: number;
}
export interface StrokeStyle {
hl: string;
vl: string;
tl: string;
tr: string;
bl: string;
br: string;
tjl: string;
tjr: string;
tjt: string;
tjb: string;
jct: string;
dot: string;
}
export declare const STYLE_ASCII: StrokeStyle;
export declare const STYLE_THIN: StrokeStyle;
export declare const STYLE_THIN_ROUNDED: StrokeStyle;
export declare const STYLE_DASHED: StrokeStyle;
export declare const STYLE_DASHED_ROUNDED: StrokeStyle;
export declare const STYLE_DOUBLE: StrokeStyle;
export declare const ENDINGS = "()[]{}<>^v\u25C0\u25B6\u25B2\u25BC\u2022\u25CF";
export declare const BARS_H = " \u258F\u258E\u258D\u258C\u258B\u258A\u2589\u2588";
export declare const BARS_V = " \u2581\u2582\u2583\u2584\u2585\u2586\u2587\u2588";
export declare const SHADES_ASCII_10 = " .-:=+*#%@";
export declare const SHADES_ASCII_16 = " .,-:+=il3GXOQW0";
export declare const SHADES_BLOCK = " \u2591\u2592\u2593\u2588";
export declare const SHADES_BLOCK_ALT = " \u2596\u259E\u259F\u2588";
//# sourceMappingURL=api.d.ts.map