ansimax 1.2.4 → 1.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +215 -0
- package/README.es.md +167 -29
- package/README.md +167 -29
- package/dist/index.d.mts +308 -103
- package/dist/index.d.ts +308 -103
- package/dist/index.js +310 -0
- package/dist/index.mjs +306 -0
- package/examples/05-components.ts +4 -4
- package/examples/all-in-one.cjs +5 -5
- package/examples/all-in-one.mjs +5 -5
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -942,6 +942,95 @@ declare const animate: {
|
|
|
942
942
|
}) => Promise<void>;
|
|
943
943
|
};
|
|
944
944
|
|
|
945
|
+
interface RGBA {
|
|
946
|
+
r: number;
|
|
947
|
+
g: number;
|
|
948
|
+
b: number;
|
|
949
|
+
/** 0..1 alpha. 1 = opaque, 0 = transparent. */
|
|
950
|
+
a: number;
|
|
951
|
+
}
|
|
952
|
+
/** A pixel can be opaque RGB, semi-transparent RGBA, or null (fully transparent). */
|
|
953
|
+
type Pixel = RGB | RGBA | null;
|
|
954
|
+
type PixelGrid = Pixel[][];
|
|
955
|
+
/** Clear the ANSI escape caches. Useful for tests or after large palette changes. */
|
|
956
|
+
declare const clearAnsiCache: () => void;
|
|
957
|
+
interface RenderOptions$1 {
|
|
958
|
+
scale?: number;
|
|
959
|
+
halfBlock?: boolean;
|
|
960
|
+
/** Use braille (2×4 sub-char resolution). Overrides halfBlock. */
|
|
961
|
+
braille?: boolean;
|
|
962
|
+
}
|
|
963
|
+
declare const renderPixelArt: (pixels: PixelGrid, opts?: RenderOptions$1) => string;
|
|
964
|
+
declare const SPRITES: Record<string, {
|
|
965
|
+
pixels: PixelGrid;
|
|
966
|
+
}>;
|
|
967
|
+
declare const flipHorizontal: (pixels: PixelGrid) => PixelGrid;
|
|
968
|
+
declare const flipVertical: (pixels: PixelGrid) => PixelGrid;
|
|
969
|
+
declare const rotate90: (pixels: PixelGrid) => PixelGrid;
|
|
970
|
+
interface GradientRectOptions {
|
|
971
|
+
width?: number;
|
|
972
|
+
height?: number;
|
|
973
|
+
colors?: string[];
|
|
974
|
+
/** Built-in style. Use `angle` for arbitrary directions. */
|
|
975
|
+
style?: 'horizontal' | 'vertical' | 'diagonal' | 'radial' | 'conic';
|
|
976
|
+
/** Custom angle in degrees (0=right, 90=down). Overrides `style`. */
|
|
977
|
+
angle?: number;
|
|
978
|
+
/**
|
|
979
|
+
* Starting angle (degrees) for conic gradients. Default `0` (= right of center).
|
|
980
|
+
* Rotates the radial sweep around the center point.
|
|
981
|
+
*/
|
|
982
|
+
startAngle?: number;
|
|
983
|
+
/** Dithering algorithm. 'bayer' improves perceived smoothness. */
|
|
984
|
+
dither?: 'none' | 'bayer';
|
|
985
|
+
/** Render in braille mode for 2× horizontal × 4× vertical resolution. */
|
|
986
|
+
braille?: boolean;
|
|
987
|
+
}
|
|
988
|
+
declare const gradientRect: (opts?: GradientRectOptions) => string;
|
|
989
|
+
interface CanvasRenderOptions extends RenderOptions$1 {
|
|
990
|
+
/** Render only the dirty region instead of the whole canvas. Default: false. */
|
|
991
|
+
dirtyOnly?: boolean;
|
|
992
|
+
}
|
|
993
|
+
interface Canvas {
|
|
994
|
+
set: (x: number, y: number, color: Pixel) => void;
|
|
995
|
+
get: (x: number, y: number) => Pixel;
|
|
996
|
+
fill: (color: Pixel) => void;
|
|
997
|
+
drawRect: (x: number, y: number, w: number, h: number, color: Pixel, fill?: boolean) => void;
|
|
998
|
+
drawCircle: (cx: number, cy: number, radius: number, color: Pixel, fill?: boolean) => void;
|
|
999
|
+
/** Composite a sprite at (x, y) with optional alpha blending. */
|
|
1000
|
+
drawSprite: (x: number, y: number, sprite: PixelGrid) => void;
|
|
1001
|
+
render: (opts?: CanvasRenderOptions) => string;
|
|
1002
|
+
print: (opts?: CanvasRenderOptions) => void;
|
|
1003
|
+
/** Resize the canvas, preserving content within the new bounds. */
|
|
1004
|
+
resize: (newWidth: number, newHeight: number, fillColor?: Pixel) => void;
|
|
1005
|
+
/** Mark all pixels as dirty (forces full redraw on next dirtyOnly render). */
|
|
1006
|
+
markDirty: () => void;
|
|
1007
|
+
/** Clear the dirty region tracker (after a full render). */
|
|
1008
|
+
clearDirty: () => void;
|
|
1009
|
+
width: number;
|
|
1010
|
+
height: number;
|
|
1011
|
+
/** Deep copy of the current pixel grid. Mutations don't affect the canvas. */
|
|
1012
|
+
pixels: PixelGrid;
|
|
1013
|
+
}
|
|
1014
|
+
declare const createCanvas: (width: number, height: number, fillColor?: Pixel) => Canvas;
|
|
1015
|
+
declare const images: {
|
|
1016
|
+
render: (pixels: PixelGrid, opts?: RenderOptions$1) => string;
|
|
1017
|
+
sprites: Record<string, {
|
|
1018
|
+
pixels: PixelGrid;
|
|
1019
|
+
}>;
|
|
1020
|
+
flipHorizontal: (pixels: PixelGrid) => PixelGrid;
|
|
1021
|
+
flipVertical: (pixels: PixelGrid) => PixelGrid;
|
|
1022
|
+
rotate90: (pixels: PixelGrid) => PixelGrid;
|
|
1023
|
+
sprite(name: string, opts?: RenderOptions$1): string;
|
|
1024
|
+
gradientRect: (opts?: GradientRectOptions) => string;
|
|
1025
|
+
createCanvas: (width: number, height: number, fillColor?: Pixel) => Canvas;
|
|
1026
|
+
colors: {
|
|
1027
|
+
hex: (h: unknown) => RGB | null;
|
|
1028
|
+
lerp: (a: RGB, b: RGB, t: number) => RGB;
|
|
1029
|
+
blend: (fg: Pixel, bg: RGB) => RGB;
|
|
1030
|
+
};
|
|
1031
|
+
clearAnsiCache: () => void;
|
|
1032
|
+
};
|
|
1033
|
+
|
|
945
1034
|
/** A glyph is an array of equal-length strings (one per row). */
|
|
946
1035
|
type Glyph = string[];
|
|
947
1036
|
/** Maps a character to its glyph. Every font must define ' ' or '?'. */
|
|
@@ -1024,6 +1113,205 @@ interface StreamOptions {
|
|
|
1024
1113
|
/** Abort signal — stops yielding when triggered. */
|
|
1025
1114
|
signal?: AbortSignal;
|
|
1026
1115
|
}
|
|
1116
|
+
/**
|
|
1117
|
+
* Character ramps for luminance → glyph mapping.
|
|
1118
|
+
* Each ramp is ordered dark → light.
|
|
1119
|
+
*
|
|
1120
|
+
* - `standard` — balanced 10-char ramp, works for most images (default)
|
|
1121
|
+
* - `detailed` — 70-char ramp from Paul Bourke, max detail at small sizes
|
|
1122
|
+
* - `blocks` — Unicode block fills, looks like a real photo at distance
|
|
1123
|
+
* - `simple` — 4-char minimal ramp
|
|
1124
|
+
* - `binary` — pure 2-char ramp: space + filled block
|
|
1125
|
+
* - `dots` — Unicode braille dots (sparse aesthetic)
|
|
1126
|
+
* - `shades` — Unicode shading gradient with high tonal range
|
|
1127
|
+
* - `ascii64` — printable ASCII subset, 64 chars, good for non-Unicode terminals
|
|
1128
|
+
*
|
|
1129
|
+
* @example
|
|
1130
|
+
* ```js
|
|
1131
|
+
* import { ascii, ASCII_RAMPS } from 'ansimax';
|
|
1132
|
+
*
|
|
1133
|
+
* console.log(ASCII_RAMPS.blocks); // ' ░▒▓█'
|
|
1134
|
+
* console.log(ASCII_RAMPS.shades); // ' ⠁⠃⠇⠧⠷⡷⣷⣿█'
|
|
1135
|
+
*
|
|
1136
|
+
* // Use directly by name
|
|
1137
|
+
* ascii.fromImage(pixels, { ramp: 'shades' });
|
|
1138
|
+
*
|
|
1139
|
+
* // Or pass a custom ramp string
|
|
1140
|
+
* ascii.fromImage(pixels, { ramp: ' .oO@' });
|
|
1141
|
+
* ```
|
|
1142
|
+
*/
|
|
1143
|
+
declare const ASCII_RAMPS: {
|
|
1144
|
+
readonly standard: " .:-=+*#%@";
|
|
1145
|
+
readonly detailed: " .'`^\",:;Il!i><~+_-?][}{1)(|/tfjrxnuvczXYUJCLQ0OZmwqpdbkhao*#MW&8%B@$";
|
|
1146
|
+
readonly blocks: " ░▒▓█";
|
|
1147
|
+
readonly simple: " .+#";
|
|
1148
|
+
readonly binary: " █";
|
|
1149
|
+
readonly dots: " ⠁⠃⠇⠧⠷⡷⣷⣿";
|
|
1150
|
+
readonly shades: " ⠁⠃⠇⠧⠷⡷⣷⣿█";
|
|
1151
|
+
readonly ascii64: " `.'^,_:-+=<>i!lI?/\\|()1{}[]rcvunxzjftLCJUYXZO0Qoahkbdpqwm*WMB8&%$#@";
|
|
1152
|
+
};
|
|
1153
|
+
type AsciiRamp = keyof typeof ASCII_RAMPS | string;
|
|
1154
|
+
/**
|
|
1155
|
+
* Convert a pixel grid into colored or monochrome ASCII art.
|
|
1156
|
+
*
|
|
1157
|
+
* @example basic monochrome conversion
|
|
1158
|
+
* ```ts
|
|
1159
|
+
* import sharp from 'sharp';
|
|
1160
|
+
*
|
|
1161
|
+
* const { data, info } = await sharp('photo.png')
|
|
1162
|
+
* .raw().toBuffer({ resolveWithObject: true });
|
|
1163
|
+
* const pixels: PixelGrid = bufferToPixelGrid(data, info.width, info.height);
|
|
1164
|
+
*
|
|
1165
|
+
* console.log(ascii.fromImage(pixels, { width: 80 }));
|
|
1166
|
+
* ```
|
|
1167
|
+
*
|
|
1168
|
+
* @example with color + dither
|
|
1169
|
+
* ```ts
|
|
1170
|
+
* console.log(ascii.fromImage(pixels, {
|
|
1171
|
+
* width: 100,
|
|
1172
|
+
* color: true,
|
|
1173
|
+
* dither: 'floyd-steinberg',
|
|
1174
|
+
* ramp: 'detailed',
|
|
1175
|
+
* }));
|
|
1176
|
+
* ```
|
|
1177
|
+
*
|
|
1178
|
+
* @example with edge detection
|
|
1179
|
+
* ```ts
|
|
1180
|
+
* console.log(ascii.fromImage(pixels, {
|
|
1181
|
+
* width: 80,
|
|
1182
|
+
* edgeDetect: 'sobel',
|
|
1183
|
+
* ramp: 'blocks',
|
|
1184
|
+
* }));
|
|
1185
|
+
* ```
|
|
1186
|
+
*/
|
|
1187
|
+
interface FromImageOptions {
|
|
1188
|
+
/** Output character width. Default `80`. Aspect ratio is preserved. */
|
|
1189
|
+
width?: number;
|
|
1190
|
+
/**
|
|
1191
|
+
* Output character height. If omitted, computed from `width` and source
|
|
1192
|
+
* aspect ratio (with a 0.5 vertical correction for typical terminal cells
|
|
1193
|
+
* which are ~2x as tall as wide).
|
|
1194
|
+
*/
|
|
1195
|
+
height?: number;
|
|
1196
|
+
/** Character ramp (dark → light). Default `'standard'`. */
|
|
1197
|
+
ramp?: AsciiRamp;
|
|
1198
|
+
/** Invert luminance (dark areas become bright chars). */
|
|
1199
|
+
invert?: boolean;
|
|
1200
|
+
/**
|
|
1201
|
+
* Apply dithering for better tonal range.
|
|
1202
|
+
* - `'none'` (default) — direct mapping
|
|
1203
|
+
* - `'floyd-steinberg'` — error diffusion, better for photos
|
|
1204
|
+
*/
|
|
1205
|
+
dither?: 'none' | 'floyd-steinberg';
|
|
1206
|
+
/**
|
|
1207
|
+
* Edge detection mode. Renders edges as the brightest chars.
|
|
1208
|
+
* - `'none'` (default)
|
|
1209
|
+
* - `'sobel'` — classical 3x3 Sobel operator
|
|
1210
|
+
*/
|
|
1211
|
+
edgeDetect?: 'none' | 'sobel';
|
|
1212
|
+
/** Sobel threshold (only when `edgeDetect: 'sobel'`). Default `40`. */
|
|
1213
|
+
edgeThreshold?: number;
|
|
1214
|
+
/**
|
|
1215
|
+
* Render in color. When `true`, each char is colored with the average
|
|
1216
|
+
* color of its source pixel. Default `false` (monochrome).
|
|
1217
|
+
*/
|
|
1218
|
+
color?: boolean;
|
|
1219
|
+
/**
|
|
1220
|
+
* Use face-optimized rendering. Applies histogram stretching to enhance
|
|
1221
|
+
* midtone detail (where faces typically live). Best for portrait input.
|
|
1222
|
+
*/
|
|
1223
|
+
faceMode?: boolean;
|
|
1224
|
+
/**
|
|
1225
|
+
* Render the source pixel's color as the **background** instead of the
|
|
1226
|
+
* foreground. Useful when paired with `ramp: 'binary'` for a photo-like
|
|
1227
|
+
* effect where chars become "pixels". Default `false`.
|
|
1228
|
+
*
|
|
1229
|
+
* Implies `color: true` — does not need to be set separately.
|
|
1230
|
+
*
|
|
1231
|
+
* @since 1.2.6
|
|
1232
|
+
*/
|
|
1233
|
+
bgColor?: boolean;
|
|
1234
|
+
/**
|
|
1235
|
+
* Brightness adjustment applied to luminance before quantization.
|
|
1236
|
+
* Range `[-1, 1]`. `0` = no change, `0.2` = lighter, `-0.2` = darker.
|
|
1237
|
+
* Default `0`.
|
|
1238
|
+
*
|
|
1239
|
+
* @since 1.2.6
|
|
1240
|
+
*/
|
|
1241
|
+
brightness?: number;
|
|
1242
|
+
/**
|
|
1243
|
+
* Contrast adjustment applied to luminance before quantization.
|
|
1244
|
+
* Range `[-1, 1]`. `0` = no change, `0.5` = boosted, `-0.5` = flattened.
|
|
1245
|
+
* Default `0`.
|
|
1246
|
+
*
|
|
1247
|
+
* @since 1.2.6
|
|
1248
|
+
*/
|
|
1249
|
+
contrast?: number;
|
|
1250
|
+
}
|
|
1251
|
+
declare const fromImage: (pixels: PixelGrid, opts?: FromImageOptions) => string;
|
|
1252
|
+
/** A parsed FIGfont — opaque to the user; pass to `ascii.figlet()`. */
|
|
1253
|
+
interface FigletFont {
|
|
1254
|
+
/** Font hardblank character (used as a space inside glyphs). */
|
|
1255
|
+
hardblank: string;
|
|
1256
|
+
/** Glyph height in rows. */
|
|
1257
|
+
height: number;
|
|
1258
|
+
/** Map from ASCII codepoint → glyph rows. */
|
|
1259
|
+
glyphs: Map<number, string[]>;
|
|
1260
|
+
}
|
|
1261
|
+
/**
|
|
1262
|
+
* Parse a FIGfont (.flf) file content into a `FigletFont` object.
|
|
1263
|
+
* Use the returned font with `ascii.figlet(text, font)`.
|
|
1264
|
+
*
|
|
1265
|
+
* Supports standard FIGfont format (the most common one). Tagged fonts
|
|
1266
|
+
* and complex Unicode glyphs may not parse — use vanilla .flf files
|
|
1267
|
+
* from http://www.figlet.org/fontdb.cgi
|
|
1268
|
+
*
|
|
1269
|
+
* @example
|
|
1270
|
+
* ```ts
|
|
1271
|
+
* import { readFileSync } from 'node:fs';
|
|
1272
|
+
* import { parseFiglet, ascii } from 'ansimax';
|
|
1273
|
+
*
|
|
1274
|
+
* const fontStr = readFileSync('./standard.flf', 'utf8');
|
|
1275
|
+
* const font = parseFiglet(fontStr);
|
|
1276
|
+
*
|
|
1277
|
+
* console.log(ascii.figlet('Hello!', font));
|
|
1278
|
+
* ```
|
|
1279
|
+
*/
|
|
1280
|
+
declare const parseFiglet: (flfContent: string) => FigletFont;
|
|
1281
|
+
/**
|
|
1282
|
+
* Render text using a parsed FIGfont (.flf).
|
|
1283
|
+
* Unknown characters render as a space-equivalent.
|
|
1284
|
+
*
|
|
1285
|
+
* @example
|
|
1286
|
+
* ```ts
|
|
1287
|
+
* import { readFileSync } from 'node:fs';
|
|
1288
|
+
* import { parseFiglet, ascii } from 'ansimax';
|
|
1289
|
+
*
|
|
1290
|
+
* const font = parseFiglet(readFileSync('./big.flf', 'utf8'));
|
|
1291
|
+
* console.log(ascii.figlet('NICE', font));
|
|
1292
|
+
* ```
|
|
1293
|
+
*/
|
|
1294
|
+
interface FigletOptions {
|
|
1295
|
+
/** Trim leading/trailing blank rows. Default `true`. */
|
|
1296
|
+
trim?: boolean;
|
|
1297
|
+
/** Color function applied to the assembled output. */
|
|
1298
|
+
colorFn?: ColorFn | null;
|
|
1299
|
+
/**
|
|
1300
|
+
* Extra spacing (in characters) inserted between each glyph.
|
|
1301
|
+
* `0` = touching glyphs, `1` = one-space gap, etc. Default `0`.
|
|
1302
|
+
*
|
|
1303
|
+
* @since 1.2.6
|
|
1304
|
+
*/
|
|
1305
|
+
kerning?: number;
|
|
1306
|
+
/**
|
|
1307
|
+
* Vertical spacing (blank lines) between rendered lines when `text`
|
|
1308
|
+
* contains `\n`. Default `0`.
|
|
1309
|
+
*
|
|
1310
|
+
* @since 1.2.6
|
|
1311
|
+
*/
|
|
1312
|
+
lineSpacing?: number;
|
|
1313
|
+
}
|
|
1314
|
+
declare const figletText: (text: string, font: FigletFont, opts?: FigletOptions) => string;
|
|
1027
1315
|
declare const ascii: {
|
|
1028
1316
|
big: (text: string) => string;
|
|
1029
1317
|
small: (text: string) => string;
|
|
@@ -1037,6 +1325,9 @@ declare const ascii: {
|
|
|
1037
1325
|
logo: (text: string, opts?: LogoOptions) => string;
|
|
1038
1326
|
stream: (text: string, opts?: StreamOptions) => AsyncGenerator<string, void, unknown>;
|
|
1039
1327
|
measure: (text: string, font?: FontName | string, letterSpacing?: number) => Dimensions;
|
|
1328
|
+
fromImage: (pixels: PixelGrid, opts?: FromImageOptions) => string;
|
|
1329
|
+
figletText: (text: string, font: FigletFont, opts?: FigletOptions) => string;
|
|
1330
|
+
parseFiglet: (flfContent: string) => FigletFont;
|
|
1040
1331
|
stageRender: (text: string, font: FontName | string, letterSpacing?: number) => string;
|
|
1041
1332
|
stageAlign: (rendered: string, align: "left" | "center") => string;
|
|
1042
1333
|
stageColorize: (rendered: string, colorFn: ColorFn | null, perCharColor: boolean) => string;
|
|
@@ -1365,9 +1656,9 @@ interface TreeNode extends TreeData {
|
|
|
1365
1656
|
/** Add a child and return the parent (for fluent sibling adds). */
|
|
1366
1657
|
addLeaf(child: string | Partial<TreeData>): TreeNode;
|
|
1367
1658
|
/** Render to string using the tree's own root style. */
|
|
1368
|
-
render(opts?: RenderOptions
|
|
1659
|
+
render(opts?: RenderOptions): string;
|
|
1369
1660
|
}
|
|
1370
|
-
interface RenderOptions
|
|
1661
|
+
interface RenderOptions {
|
|
1371
1662
|
/** Visual style. Default: 'normal'. */
|
|
1372
1663
|
style?: TreeStyle;
|
|
1373
1664
|
/**
|
|
@@ -1407,13 +1698,13 @@ declare const tree: (root: string | Partial<TreeData>) => TreeNode;
|
|
|
1407
1698
|
* ],
|
|
1408
1699
|
* });
|
|
1409
1700
|
*/
|
|
1410
|
-
declare const renderTree: (root: TreeData, opts?: RenderOptions
|
|
1411
|
-
declare const renderTreeStream: (root: TreeData, opts?: RenderOptions
|
|
1701
|
+
declare const renderTree: (root: TreeData, opts?: RenderOptions) => string;
|
|
1702
|
+
declare const renderTreeStream: (root: TreeData, opts?: RenderOptions) => Generator<string, void, unknown>;
|
|
1412
1703
|
interface TreeDimensions {
|
|
1413
1704
|
width: number;
|
|
1414
1705
|
height: number;
|
|
1415
1706
|
}
|
|
1416
|
-
declare const measureTree: (root: TreeData, opts?: RenderOptions
|
|
1707
|
+
declare const measureTree: (root: TreeData, opts?: RenderOptions) => TreeDimensions;
|
|
1417
1708
|
interface WalkVisitor {
|
|
1418
1709
|
(node: TreeData, depth: number, isLast: boolean): void;
|
|
1419
1710
|
}
|
|
@@ -1454,9 +1745,9 @@ declare const filterTree: (root: TreeData, predicate: (node: TreeData, depth: nu
|
|
|
1454
1745
|
}) => TreeData | null;
|
|
1455
1746
|
declare const trees: {
|
|
1456
1747
|
tree: (root: string | Partial<TreeData>) => TreeNode;
|
|
1457
|
-
render: (root: TreeData, opts?: RenderOptions
|
|
1458
|
-
renderStream: (root: TreeData, opts?: RenderOptions
|
|
1459
|
-
measure: (root: TreeData, opts?: RenderOptions
|
|
1748
|
+
render: (root: TreeData, opts?: RenderOptions) => string;
|
|
1749
|
+
renderStream: (root: TreeData, opts?: RenderOptions) => Generator<string, void, unknown>;
|
|
1750
|
+
measure: (root: TreeData, opts?: RenderOptions) => TreeDimensions;
|
|
1460
1751
|
walk: (root: TreeData, visitor: WalkVisitor) => void;
|
|
1461
1752
|
find: (root: TreeData, predicate: (node: TreeData, depth: number) => boolean) => TreeData | null;
|
|
1462
1753
|
count: (root: TreeData) => number;
|
|
@@ -1555,95 +1846,6 @@ declare const createTheme: (initial?: string) => ThemeInstance;
|
|
|
1555
1846
|
declare const clearThemeColorCache: () => void;
|
|
1556
1847
|
declare const themes: ThemeInstance;
|
|
1557
1848
|
|
|
1558
|
-
interface RGBA {
|
|
1559
|
-
r: number;
|
|
1560
|
-
g: number;
|
|
1561
|
-
b: number;
|
|
1562
|
-
/** 0..1 alpha. 1 = opaque, 0 = transparent. */
|
|
1563
|
-
a: number;
|
|
1564
|
-
}
|
|
1565
|
-
/** A pixel can be opaque RGB, semi-transparent RGBA, or null (fully transparent). */
|
|
1566
|
-
type Pixel = RGB | RGBA | null;
|
|
1567
|
-
type PixelGrid = Pixel[][];
|
|
1568
|
-
/** Clear the ANSI escape caches. Useful for tests or after large palette changes. */
|
|
1569
|
-
declare const clearAnsiCache: () => void;
|
|
1570
|
-
interface RenderOptions {
|
|
1571
|
-
scale?: number;
|
|
1572
|
-
halfBlock?: boolean;
|
|
1573
|
-
/** Use braille (2×4 sub-char resolution). Overrides halfBlock. */
|
|
1574
|
-
braille?: boolean;
|
|
1575
|
-
}
|
|
1576
|
-
declare const renderPixelArt: (pixels: PixelGrid, opts?: RenderOptions) => string;
|
|
1577
|
-
declare const SPRITES: Record<string, {
|
|
1578
|
-
pixels: PixelGrid;
|
|
1579
|
-
}>;
|
|
1580
|
-
declare const flipHorizontal: (pixels: PixelGrid) => PixelGrid;
|
|
1581
|
-
declare const flipVertical: (pixels: PixelGrid) => PixelGrid;
|
|
1582
|
-
declare const rotate90: (pixels: PixelGrid) => PixelGrid;
|
|
1583
|
-
interface GradientRectOptions {
|
|
1584
|
-
width?: number;
|
|
1585
|
-
height?: number;
|
|
1586
|
-
colors?: string[];
|
|
1587
|
-
/** Built-in style. Use `angle` for arbitrary directions. */
|
|
1588
|
-
style?: 'horizontal' | 'vertical' | 'diagonal' | 'radial' | 'conic';
|
|
1589
|
-
/** Custom angle in degrees (0=right, 90=down). Overrides `style`. */
|
|
1590
|
-
angle?: number;
|
|
1591
|
-
/**
|
|
1592
|
-
* Starting angle (degrees) for conic gradients. Default `0` (= right of center).
|
|
1593
|
-
* Rotates the radial sweep around the center point.
|
|
1594
|
-
*/
|
|
1595
|
-
startAngle?: number;
|
|
1596
|
-
/** Dithering algorithm. 'bayer' improves perceived smoothness. */
|
|
1597
|
-
dither?: 'none' | 'bayer';
|
|
1598
|
-
/** Render in braille mode for 2× horizontal × 4× vertical resolution. */
|
|
1599
|
-
braille?: boolean;
|
|
1600
|
-
}
|
|
1601
|
-
declare const gradientRect: (opts?: GradientRectOptions) => string;
|
|
1602
|
-
interface CanvasRenderOptions extends RenderOptions {
|
|
1603
|
-
/** Render only the dirty region instead of the whole canvas. Default: false. */
|
|
1604
|
-
dirtyOnly?: boolean;
|
|
1605
|
-
}
|
|
1606
|
-
interface Canvas {
|
|
1607
|
-
set: (x: number, y: number, color: Pixel) => void;
|
|
1608
|
-
get: (x: number, y: number) => Pixel;
|
|
1609
|
-
fill: (color: Pixel) => void;
|
|
1610
|
-
drawRect: (x: number, y: number, w: number, h: number, color: Pixel, fill?: boolean) => void;
|
|
1611
|
-
drawCircle: (cx: number, cy: number, radius: number, color: Pixel, fill?: boolean) => void;
|
|
1612
|
-
/** Composite a sprite at (x, y) with optional alpha blending. */
|
|
1613
|
-
drawSprite: (x: number, y: number, sprite: PixelGrid) => void;
|
|
1614
|
-
render: (opts?: CanvasRenderOptions) => string;
|
|
1615
|
-
print: (opts?: CanvasRenderOptions) => void;
|
|
1616
|
-
/** Resize the canvas, preserving content within the new bounds. */
|
|
1617
|
-
resize: (newWidth: number, newHeight: number, fillColor?: Pixel) => void;
|
|
1618
|
-
/** Mark all pixels as dirty (forces full redraw on next dirtyOnly render). */
|
|
1619
|
-
markDirty: () => void;
|
|
1620
|
-
/** Clear the dirty region tracker (after a full render). */
|
|
1621
|
-
clearDirty: () => void;
|
|
1622
|
-
width: number;
|
|
1623
|
-
height: number;
|
|
1624
|
-
/** Deep copy of the current pixel grid. Mutations don't affect the canvas. */
|
|
1625
|
-
pixels: PixelGrid;
|
|
1626
|
-
}
|
|
1627
|
-
declare const createCanvas: (width: number, height: number, fillColor?: Pixel) => Canvas;
|
|
1628
|
-
declare const images: {
|
|
1629
|
-
render: (pixels: PixelGrid, opts?: RenderOptions) => string;
|
|
1630
|
-
sprites: Record<string, {
|
|
1631
|
-
pixels: PixelGrid;
|
|
1632
|
-
}>;
|
|
1633
|
-
flipHorizontal: (pixels: PixelGrid) => PixelGrid;
|
|
1634
|
-
flipVertical: (pixels: PixelGrid) => PixelGrid;
|
|
1635
|
-
rotate90: (pixels: PixelGrid) => PixelGrid;
|
|
1636
|
-
sprite(name: string, opts?: RenderOptions): string;
|
|
1637
|
-
gradientRect: (opts?: GradientRectOptions) => string;
|
|
1638
|
-
createCanvas: (width: number, height: number, fillColor?: Pixel) => Canvas;
|
|
1639
|
-
colors: {
|
|
1640
|
-
hex: (h: unknown) => RGB | null;
|
|
1641
|
-
lerp: (a: RGB, b: RGB, t: number) => RGB;
|
|
1642
|
-
blend: (fg: Pixel, bg: RGB) => RGB;
|
|
1643
|
-
};
|
|
1644
|
-
clearAnsiCache: () => void;
|
|
1645
|
-
};
|
|
1646
|
-
|
|
1647
1849
|
declare const ansimax: {
|
|
1648
1850
|
color: {
|
|
1649
1851
|
black: ColorFn;
|
|
@@ -1725,6 +1927,9 @@ declare const ansimax: {
|
|
|
1725
1927
|
logo: (text: string, opts?: LogoOptions) => string;
|
|
1726
1928
|
stream: (text: string, opts?: StreamOptions) => AsyncGenerator<string, void, unknown>;
|
|
1727
1929
|
measure: (text: string, font?: FontName | string, letterSpacing?: number) => Dimensions;
|
|
1930
|
+
fromImage: (pixels: PixelGrid, opts?: FromImageOptions) => string;
|
|
1931
|
+
figletText: (text: string, font: FigletFont, opts?: FigletOptions) => string;
|
|
1932
|
+
parseFiglet: (flfContent: string) => FigletFont;
|
|
1728
1933
|
stageRender: (text: string, font: FontName | string, letterSpacing?: number) => string;
|
|
1729
1934
|
stageAlign: (rendered: string, align: "left" | "center") => string;
|
|
1730
1935
|
stageColorize: (rendered: string, colorFn: ColorFn | null, perCharColor: boolean) => string;
|
|
@@ -1773,9 +1978,9 @@ declare const ansimax: {
|
|
|
1773
1978
|
};
|
|
1774
1979
|
trees: {
|
|
1775
1980
|
tree: (root: string | Partial<TreeData>) => TreeNode;
|
|
1776
|
-
render: (root: TreeData, opts?: RenderOptions
|
|
1777
|
-
renderStream: (root: TreeData, opts?: RenderOptions
|
|
1778
|
-
measure: (root: TreeData, opts?: RenderOptions
|
|
1981
|
+
render: (root: TreeData, opts?: RenderOptions) => string;
|
|
1982
|
+
renderStream: (root: TreeData, opts?: RenderOptions) => Generator<string, void, unknown>;
|
|
1983
|
+
measure: (root: TreeData, opts?: RenderOptions) => TreeDimensions;
|
|
1779
1984
|
walk: (root: TreeData, visitor: WalkVisitor) => void;
|
|
1780
1985
|
find: (root: TreeData, predicate: (node: TreeData, depth: number) => boolean) => TreeData | null;
|
|
1781
1986
|
count: (root: TreeData) => number;
|
|
@@ -1787,14 +1992,14 @@ declare const ansimax: {
|
|
|
1787
1992
|
};
|
|
1788
1993
|
themes: ThemeInstance;
|
|
1789
1994
|
images: {
|
|
1790
|
-
render: (pixels: PixelGrid, opts?: RenderOptions) => string;
|
|
1995
|
+
render: (pixels: PixelGrid, opts?: RenderOptions$1) => string;
|
|
1791
1996
|
sprites: Record<string, {
|
|
1792
1997
|
pixels: PixelGrid;
|
|
1793
1998
|
}>;
|
|
1794
1999
|
flipHorizontal: (pixels: PixelGrid) => PixelGrid;
|
|
1795
2000
|
flipVertical: (pixels: PixelGrid) => PixelGrid;
|
|
1796
2001
|
rotate90: (pixels: PixelGrid) => PixelGrid;
|
|
1797
|
-
sprite(name: string, opts?: RenderOptions): string;
|
|
2002
|
+
sprite(name: string, opts?: RenderOptions$1): string;
|
|
1798
2003
|
gradientRect: (opts?: GradientRectOptions) => string;
|
|
1799
2004
|
createCanvas: (width: number, height: number, fillColor?: Pixel) => Canvas;
|
|
1800
2005
|
colors: {
|
|
@@ -1807,4 +2012,4 @@ declare const ansimax: {
|
|
|
1807
2012
|
configure: (opts?: AnsimaxConfig, meta?: ConfigureOptions) => void;
|
|
1808
2013
|
};
|
|
1809
2014
|
|
|
1810
|
-
export { type AnimateGradientController, type AnimateGradientOptions, type AnimationHooks, type AnimationSpeed, type AnsiCode, type AnsimaxConfig, BEL, BG, type BadgeOptions, type BallOptions, type BannerOptions, type BoxOptions, type BoxStyle, type BreatheOptions, DEFAULTS as CONFIG_DEFAULTS, CSI, type Canvas, type CanvasRenderOptions, type ColorChain, type ColorFn, type ColorLevel, type ColorMode, type ColorSupport, type ColumnsOptions, type ConfigChangeListener, type ConfigKey, type ConfigKeyListener, type ConfigureOptions, type CountdownOptions, type CustomOptions, DEFAULT_TERM_COLS, DEFAULT_TERM_ROWS, type DebounceOptions, type DiffType, type Dimensions, type DividerOptions, type DotsOptions, ESC, type EasingFn, type EasingName, type EraseMode, FG, FRAME_MS, type FadeOptions, type FontMap, type FontName, type FrameCallback, type FrameHandle, type GlitchOptions, type Glyph, type GradientOptions, type GradientRectOptions, type LineDiff, type LiveController, type LiveOptions, type LoadingBarOptions, type LogoOptions, MENU_CANCELLED, type MemoizeOptions, type MenuInput, type MenuOptions, type MenuOutput, type MenuResult, type MultiLoader, type MultiLoaderItem, OSC, type OnResizeOptions, type OutputBuffer, type ParallelOptions, type ParallelStep, type Pixel, type PixelGrid, type PlayController, type PlayOptions, type PresetName, type ProgressAnimateOptions, type ProgressBarOptions, type ProgressOptions, type PulseOptions, type RGB, type RGBA, type RegisterFontOptions, type RenderOptions, type ResizeListener, type ReusableGradient, type RevealOptions, SPINNERS, SPRITES, ST, STYLE, type SectionOptions, type SleepOptions, type SlideOptions, type SpinOptions, type SpinnerType, type StatusOptions, type StatusType, type StopFn, type StreamOptions, type TableBorderStyle, type TableOptions, type Task, type TaskResult, type TasksOptions, type Theme, type BannerOpts as ThemeBannerOpts, type ThemeChangeListener, type ThemeInstance, type ThemeStyleName, type TimelineEvent, type TimelineOptions, type TreeData, type TreeDimensions, type TreeNode, type RenderOptions
|
|
2015
|
+
export { ASCII_RAMPS, type AnimateGradientController, type AnimateGradientOptions, type AnimationHooks, type AnimationSpeed, type AnsiCode, type AnsimaxConfig, type AsciiRamp, BEL, BG, type BadgeOptions, type BallOptions, type BannerOptions, type BoxOptions, type BoxStyle, type BreatheOptions, DEFAULTS as CONFIG_DEFAULTS, CSI, type Canvas, type CanvasRenderOptions, type ColorChain, type ColorFn, type ColorLevel, type ColorMode, type ColorSupport, type ColumnsOptions, type ConfigChangeListener, type ConfigKey, type ConfigKeyListener, type ConfigureOptions, type CountdownOptions, type CustomOptions, DEFAULT_TERM_COLS, DEFAULT_TERM_ROWS, type DebounceOptions, type DiffType, type Dimensions, type DividerOptions, type DotsOptions, ESC, type EasingFn, type EasingName, type EraseMode, FG, FRAME_MS, type FadeOptions, type FigletFont, type FigletOptions, type FontMap, type FontName, type FrameCallback, type FrameHandle, type FromImageOptions, type GlitchOptions, type Glyph, type GradientOptions, type GradientRectOptions, type LineDiff, type LiveController, type LiveOptions, type LoadingBarOptions, type LogoOptions, MENU_CANCELLED, type MemoizeOptions, type MenuInput, type MenuOptions, type MenuOutput, type MenuResult, type MultiLoader, type MultiLoaderItem, OSC, type OnResizeOptions, type OutputBuffer, type ParallelOptions, type ParallelStep, type Pixel, type PixelGrid, type PlayController, type PlayOptions, type PresetName, type ProgressAnimateOptions, type ProgressBarOptions, type ProgressOptions, type PulseOptions, type RGB, type RGBA, type RegisterFontOptions, type RenderOptions$1 as RenderOptions, type ResizeListener, type ReusableGradient, type RevealOptions, SPINNERS, SPRITES, ST, STYLE, type SectionOptions, type SleepOptions, type SlideOptions, type SpinOptions, type SpinnerType, type StatusOptions, type StatusType, type StopFn, type StreamOptions, type TableBorderStyle, type TableOptions, type Task, type TaskResult, type TasksOptions, type Theme, type BannerOpts as ThemeBannerOpts, type ThemeChangeListener, type ThemeInstance, type ThemeStyleName, type TimelineEvent, type TimelineOptions, type TreeData, type TreeDimensions, type TreeNode, type RenderOptions as TreeRenderOptions, type TreeStyle, type TypeDeleteOptions, type TypewriterOptions, type WalkVisitor, type WaveOptions, type WriteAsyncOptions, animate, animateGradient, ascii, bell, bg256, bgRgb, box, canAnimate, cancelTerminalFrame, center, chain, charWidth, clamp, clearAnsiCache, clearColorCache, clearRenderCache, clearThemeColorCache, color, colorLevel, presets as colorPresets, components, compose, configure, countNodes, createCanvas, createGradient, createOutputBuffer, createTheme, cursor, debounce, ansimax as default, diffLines, escapeRegex, fg256, fgRgb, figletText, filterTree, findInTree, flipHorizontal, flipVertical, frames, fromImage, getConfig, getConfigValue, getRenderCacheSize, getSpeedMultiplier, getTerminalHeight, getTerminalWidth, gradient, gradientColor, gradientRect, graphemes, hasFont, hexToRgb, hideCursor, images, isHexColor, isNoColor, lerp, lerpColor, link, listFonts, listPresets, loader, mapTree, measureTree, memoize, nextTick, onConfigChange, onConfigKeyChange, onResize, once, padBoth, padEnd, padStart, parseFiglet, pauseListeners, presetNames, presets, rainbow, registerFont, registerPreset, renderPixelArt, renderTree, renderTreeStream, repeatVisible, requestTerminalFrame, reset, resetColorSupportCache, resetConfig, resetCursorRefCount, resetFramesCursorCount, resetLoaderCursorCount, resetNoColor, resumeListeners, reverseGradient, rgbTo256, rgbToHex, rotate90, safeJson, screen, setNoColor, setTitle, sgr, showCursor, sleep, sleepFrame, sliceAnsi, stripAnsi$1 as stripAnsi, stripAnsi$2 as stripAnsiCodes, stripAnsi as stripAnsiColors, supportsColor, supportsColorLevel, termSize, themes, throttle, tree, trees, truncateAnsi, visibleLen, walkTree, withConfig, wordWrap, wrapAnsi, write, writeAsync, writeErr, writeln, writelnErr };
|