ansimax 1.2.3 → 1.2.5
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 +195 -0
- package/README.es.md +122 -9
- package/README.md +122 -9
- package/dist/index.d.mts +287 -104
- package/dist/index.d.ts +287 -104
- package/dist/index.js +288 -3
- package/dist/index.mjs +282 -3
- package/examples/all-in-one.cjs +1 -1
- package/examples/all-in-one.mjs +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -622,7 +622,47 @@ declare const gradient: (text: unknown, stops: string[] | null | undefined, opts
|
|
|
622
622
|
* }
|
|
623
623
|
* ```
|
|
624
624
|
*/
|
|
625
|
-
|
|
625
|
+
/**
|
|
626
|
+
* The function returned by `createGradient()`. Callable just like `gradient()`,
|
|
627
|
+
* but also exposes metadata for inspection and chaining.
|
|
628
|
+
*/
|
|
629
|
+
interface ReusableGradient {
|
|
630
|
+
/** Apply the gradient to text. */
|
|
631
|
+
(text: unknown, opts?: GradientOptions): string;
|
|
632
|
+
/** The original hex stops that were passed to `createGradient()`. */
|
|
633
|
+
readonly stops: readonly string[];
|
|
634
|
+
/** The resolved RGB stops (after filtering invalid hex). */
|
|
635
|
+
readonly resolvedStops: readonly Readonly<RGB>[];
|
|
636
|
+
/** Default options frozen at factory time. */
|
|
637
|
+
readonly defaultOptions: Readonly<Omit<GradientOptions, 'phase'>>;
|
|
638
|
+
}
|
|
639
|
+
declare const createGradient: (stops: string[] | null | undefined, defaultOpts?: Omit<GradientOptions, "phase">) => ReusableGradient;
|
|
640
|
+
/**
|
|
641
|
+
* Return a new gradient with the stops reversed. Useful for symmetric
|
|
642
|
+
* effects (e.g. fade in / fade out) or to flip an existing palette.
|
|
643
|
+
*
|
|
644
|
+
* Accepts either:
|
|
645
|
+
* - A `ReusableGradient` returned from `createGradient()` — returns a new one
|
|
646
|
+
* - An array of hex stops — returns a new array with the order flipped
|
|
647
|
+
*
|
|
648
|
+
* @example
|
|
649
|
+
* ```ts
|
|
650
|
+
* const fire = createGradient(['#ff5555', '#ffb86c', '#f1fa8c']);
|
|
651
|
+
* const ice = reverseGradient(fire); // ReusableGradient with reversed stops
|
|
652
|
+
*
|
|
653
|
+
* console.log(fire('warm side'));
|
|
654
|
+
* console.log(ice('cool side'));
|
|
655
|
+
* ```
|
|
656
|
+
*
|
|
657
|
+
* @example with plain stops
|
|
658
|
+
* ```ts
|
|
659
|
+
* const stops = ['#ff0000', '#00ff00', '#0000ff'];
|
|
660
|
+
* const reversed = reverseGradient(stops);
|
|
661
|
+
* // → ['#0000ff', '#00ff00', '#ff0000']
|
|
662
|
+
* ```
|
|
663
|
+
*/
|
|
664
|
+
declare function reverseGradient(grad: ReusableGradient): ReusableGradient;
|
|
665
|
+
declare function reverseGradient(stops: string[]): string[];
|
|
626
666
|
declare const rainbow: ColorFn;
|
|
627
667
|
interface AnimateGradientOptions {
|
|
628
668
|
/** Total animation duration in ms. Default `2000`. */
|
|
@@ -902,6 +942,95 @@ declare const animate: {
|
|
|
902
942
|
}) => Promise<void>;
|
|
903
943
|
};
|
|
904
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
|
+
|
|
905
1034
|
/** A glyph is an array of equal-length strings (one per row). */
|
|
906
1035
|
type Glyph = string[];
|
|
907
1036
|
/** Maps a character to its glyph. Every font must define ' ' or '?'. */
|
|
@@ -984,6 +1113,143 @@ interface StreamOptions {
|
|
|
984
1113
|
/** Abort signal — stops yielding when triggered. */
|
|
985
1114
|
signal?: AbortSignal;
|
|
986
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
|
|
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
|
+
*/
|
|
1125
|
+
declare const ASCII_RAMPS: {
|
|
1126
|
+
readonly standard: " .:-=+*#%@";
|
|
1127
|
+
readonly detailed: " .'`^\",:;Il!i><~+_-?][}{1)(|/tfjrxnuvczXYUJCLQ0OZmwqpdbkhao*#MW&8%B@$";
|
|
1128
|
+
readonly blocks: " ░▒▓█";
|
|
1129
|
+
readonly simple: " .+#";
|
|
1130
|
+
};
|
|
1131
|
+
type AsciiRamp = keyof typeof ASCII_RAMPS | string;
|
|
1132
|
+
/**
|
|
1133
|
+
* Convert a pixel grid into colored or monochrome ASCII art.
|
|
1134
|
+
*
|
|
1135
|
+
* @example basic monochrome conversion
|
|
1136
|
+
* ```ts
|
|
1137
|
+
* import sharp from 'sharp';
|
|
1138
|
+
*
|
|
1139
|
+
* const { data, info } = await sharp('photo.png')
|
|
1140
|
+
* .raw().toBuffer({ resolveWithObject: true });
|
|
1141
|
+
* const pixels: PixelGrid = bufferToPixelGrid(data, info.width, info.height);
|
|
1142
|
+
*
|
|
1143
|
+
* console.log(ascii.fromImage(pixels, { width: 80 }));
|
|
1144
|
+
* ```
|
|
1145
|
+
*
|
|
1146
|
+
* @example with color + dither
|
|
1147
|
+
* ```ts
|
|
1148
|
+
* console.log(ascii.fromImage(pixels, {
|
|
1149
|
+
* width: 100,
|
|
1150
|
+
* color: true,
|
|
1151
|
+
* dither: 'floyd-steinberg',
|
|
1152
|
+
* ramp: 'detailed',
|
|
1153
|
+
* }));
|
|
1154
|
+
* ```
|
|
1155
|
+
*
|
|
1156
|
+
* @example with edge detection
|
|
1157
|
+
* ```ts
|
|
1158
|
+
* console.log(ascii.fromImage(pixels, {
|
|
1159
|
+
* width: 80,
|
|
1160
|
+
* edgeDetect: 'sobel',
|
|
1161
|
+
* ramp: 'blocks',
|
|
1162
|
+
* }));
|
|
1163
|
+
* ```
|
|
1164
|
+
*/
|
|
1165
|
+
interface FromImageOptions {
|
|
1166
|
+
/** Output character width. Default `80`. Aspect ratio is preserved. */
|
|
1167
|
+
width?: number;
|
|
1168
|
+
/**
|
|
1169
|
+
* Output character height. If omitted, computed from `width` and source
|
|
1170
|
+
* aspect ratio (with a 0.5 vertical correction for typical terminal cells
|
|
1171
|
+
* which are ~2x as tall as wide).
|
|
1172
|
+
*/
|
|
1173
|
+
height?: number;
|
|
1174
|
+
/** Character ramp (dark → light). Default `'standard'`. */
|
|
1175
|
+
ramp?: AsciiRamp;
|
|
1176
|
+
/** Invert luminance (dark areas become bright chars). */
|
|
1177
|
+
invert?: boolean;
|
|
1178
|
+
/**
|
|
1179
|
+
* Apply dithering for better tonal range.
|
|
1180
|
+
* - `'none'` (default) — direct mapping
|
|
1181
|
+
* - `'floyd-steinberg'` — error diffusion, better for photos
|
|
1182
|
+
*/
|
|
1183
|
+
dither?: 'none' | 'floyd-steinberg';
|
|
1184
|
+
/**
|
|
1185
|
+
* Edge detection mode. Renders edges as the brightest chars.
|
|
1186
|
+
* - `'none'` (default)
|
|
1187
|
+
* - `'sobel'` — classical 3x3 Sobel operator
|
|
1188
|
+
*/
|
|
1189
|
+
edgeDetect?: 'none' | 'sobel';
|
|
1190
|
+
/** Sobel threshold (only when `edgeDetect: 'sobel'`). Default `40`. */
|
|
1191
|
+
edgeThreshold?: number;
|
|
1192
|
+
/**
|
|
1193
|
+
* Render in color. When `true`, each char is colored with the average
|
|
1194
|
+
* color of its source pixel. Default `false` (monochrome).
|
|
1195
|
+
*/
|
|
1196
|
+
color?: boolean;
|
|
1197
|
+
/**
|
|
1198
|
+
* Use face-optimized rendering. Applies histogram stretching to enhance
|
|
1199
|
+
* midtone detail (where faces typically live). Best for portrait input.
|
|
1200
|
+
*/
|
|
1201
|
+
faceMode?: boolean;
|
|
1202
|
+
}
|
|
1203
|
+
declare const fromImage: (pixels: PixelGrid, opts?: FromImageOptions) => string;
|
|
1204
|
+
/** A parsed FIGfont — opaque to the user; pass to `ascii.figlet()`. */
|
|
1205
|
+
interface FigletFont {
|
|
1206
|
+
/** Font hardblank character (used as a space inside glyphs). */
|
|
1207
|
+
hardblank: string;
|
|
1208
|
+
/** Glyph height in rows. */
|
|
1209
|
+
height: number;
|
|
1210
|
+
/** Map from ASCII codepoint → glyph rows. */
|
|
1211
|
+
glyphs: Map<number, string[]>;
|
|
1212
|
+
}
|
|
1213
|
+
/**
|
|
1214
|
+
* Parse a FIGfont (.flf) file content into a `FigletFont` object.
|
|
1215
|
+
* Use the returned font with `ascii.figlet(text, font)`.
|
|
1216
|
+
*
|
|
1217
|
+
* Supports standard FIGfont format (the most common one). Tagged fonts
|
|
1218
|
+
* and complex Unicode glyphs may not parse — use vanilla .flf files
|
|
1219
|
+
* from http://www.figlet.org/fontdb.cgi
|
|
1220
|
+
*
|
|
1221
|
+
* @example
|
|
1222
|
+
* ```ts
|
|
1223
|
+
* import { readFileSync } from 'node:fs';
|
|
1224
|
+
* import { parseFiglet, ascii } from 'ansimax';
|
|
1225
|
+
*
|
|
1226
|
+
* const fontStr = readFileSync('./standard.flf', 'utf8');
|
|
1227
|
+
* const font = parseFiglet(fontStr);
|
|
1228
|
+
*
|
|
1229
|
+
* console.log(ascii.figlet('Hello!', font));
|
|
1230
|
+
* ```
|
|
1231
|
+
*/
|
|
1232
|
+
declare const parseFiglet: (flfContent: string) => FigletFont;
|
|
1233
|
+
/**
|
|
1234
|
+
* Render text using a parsed FIGfont (.flf).
|
|
1235
|
+
* Unknown characters render as a space-equivalent.
|
|
1236
|
+
*
|
|
1237
|
+
* @example
|
|
1238
|
+
* ```ts
|
|
1239
|
+
* import { readFileSync } from 'node:fs';
|
|
1240
|
+
* import { parseFiglet, ascii } from 'ansimax';
|
|
1241
|
+
*
|
|
1242
|
+
* const font = parseFiglet(readFileSync('./big.flf', 'utf8'));
|
|
1243
|
+
* console.log(ascii.figlet('NICE', font));
|
|
1244
|
+
* ```
|
|
1245
|
+
*/
|
|
1246
|
+
interface FigletOptions {
|
|
1247
|
+
/** Trim leading/trailing spaces per row. Default `true`. */
|
|
1248
|
+
trim?: boolean;
|
|
1249
|
+
/** Color function applied to the assembled output. */
|
|
1250
|
+
colorFn?: ColorFn | null;
|
|
1251
|
+
}
|
|
1252
|
+
declare const figletText: (text: string, font: FigletFont, opts?: FigletOptions) => string;
|
|
987
1253
|
declare const ascii: {
|
|
988
1254
|
big: (text: string) => string;
|
|
989
1255
|
small: (text: string) => string;
|
|
@@ -997,6 +1263,9 @@ declare const ascii: {
|
|
|
997
1263
|
logo: (text: string, opts?: LogoOptions) => string;
|
|
998
1264
|
stream: (text: string, opts?: StreamOptions) => AsyncGenerator<string, void, unknown>;
|
|
999
1265
|
measure: (text: string, font?: FontName | string, letterSpacing?: number) => Dimensions;
|
|
1266
|
+
fromImage: (pixels: PixelGrid, opts?: FromImageOptions) => string;
|
|
1267
|
+
figletText: (text: string, font: FigletFont, opts?: FigletOptions) => string;
|
|
1268
|
+
parseFiglet: (flfContent: string) => FigletFont;
|
|
1000
1269
|
stageRender: (text: string, font: FontName | string, letterSpacing?: number) => string;
|
|
1001
1270
|
stageAlign: (rendered: string, align: "left" | "center") => string;
|
|
1002
1271
|
stageColorize: (rendered: string, colorFn: ColorFn | null, perCharColor: boolean) => string;
|
|
@@ -1325,9 +1594,9 @@ interface TreeNode extends TreeData {
|
|
|
1325
1594
|
/** Add a child and return the parent (for fluent sibling adds). */
|
|
1326
1595
|
addLeaf(child: string | Partial<TreeData>): TreeNode;
|
|
1327
1596
|
/** Render to string using the tree's own root style. */
|
|
1328
|
-
render(opts?: RenderOptions
|
|
1597
|
+
render(opts?: RenderOptions): string;
|
|
1329
1598
|
}
|
|
1330
|
-
interface RenderOptions
|
|
1599
|
+
interface RenderOptions {
|
|
1331
1600
|
/** Visual style. Default: 'normal'. */
|
|
1332
1601
|
style?: TreeStyle;
|
|
1333
1602
|
/**
|
|
@@ -1367,13 +1636,13 @@ declare const tree: (root: string | Partial<TreeData>) => TreeNode;
|
|
|
1367
1636
|
* ],
|
|
1368
1637
|
* });
|
|
1369
1638
|
*/
|
|
1370
|
-
declare const renderTree: (root: TreeData, opts?: RenderOptions
|
|
1371
|
-
declare const renderTreeStream: (root: TreeData, opts?: RenderOptions
|
|
1639
|
+
declare const renderTree: (root: TreeData, opts?: RenderOptions) => string;
|
|
1640
|
+
declare const renderTreeStream: (root: TreeData, opts?: RenderOptions) => Generator<string, void, unknown>;
|
|
1372
1641
|
interface TreeDimensions {
|
|
1373
1642
|
width: number;
|
|
1374
1643
|
height: number;
|
|
1375
1644
|
}
|
|
1376
|
-
declare const measureTree: (root: TreeData, opts?: RenderOptions
|
|
1645
|
+
declare const measureTree: (root: TreeData, opts?: RenderOptions) => TreeDimensions;
|
|
1377
1646
|
interface WalkVisitor {
|
|
1378
1647
|
(node: TreeData, depth: number, isLast: boolean): void;
|
|
1379
1648
|
}
|
|
@@ -1414,9 +1683,9 @@ declare const filterTree: (root: TreeData, predicate: (node: TreeData, depth: nu
|
|
|
1414
1683
|
}) => TreeData | null;
|
|
1415
1684
|
declare const trees: {
|
|
1416
1685
|
tree: (root: string | Partial<TreeData>) => TreeNode;
|
|
1417
|
-
render: (root: TreeData, opts?: RenderOptions
|
|
1418
|
-
renderStream: (root: TreeData, opts?: RenderOptions
|
|
1419
|
-
measure: (root: TreeData, opts?: RenderOptions
|
|
1686
|
+
render: (root: TreeData, opts?: RenderOptions) => string;
|
|
1687
|
+
renderStream: (root: TreeData, opts?: RenderOptions) => Generator<string, void, unknown>;
|
|
1688
|
+
measure: (root: TreeData, opts?: RenderOptions) => TreeDimensions;
|
|
1420
1689
|
walk: (root: TreeData, visitor: WalkVisitor) => void;
|
|
1421
1690
|
find: (root: TreeData, predicate: (node: TreeData, depth: number) => boolean) => TreeData | null;
|
|
1422
1691
|
count: (root: TreeData) => number;
|
|
@@ -1515,95 +1784,6 @@ declare const createTheme: (initial?: string) => ThemeInstance;
|
|
|
1515
1784
|
declare const clearThemeColorCache: () => void;
|
|
1516
1785
|
declare const themes: ThemeInstance;
|
|
1517
1786
|
|
|
1518
|
-
interface RGBA {
|
|
1519
|
-
r: number;
|
|
1520
|
-
g: number;
|
|
1521
|
-
b: number;
|
|
1522
|
-
/** 0..1 alpha. 1 = opaque, 0 = transparent. */
|
|
1523
|
-
a: number;
|
|
1524
|
-
}
|
|
1525
|
-
/** A pixel can be opaque RGB, semi-transparent RGBA, or null (fully transparent). */
|
|
1526
|
-
type Pixel = RGB | RGBA | null;
|
|
1527
|
-
type PixelGrid = Pixel[][];
|
|
1528
|
-
/** Clear the ANSI escape caches. Useful for tests or after large palette changes. */
|
|
1529
|
-
declare const clearAnsiCache: () => void;
|
|
1530
|
-
interface RenderOptions {
|
|
1531
|
-
scale?: number;
|
|
1532
|
-
halfBlock?: boolean;
|
|
1533
|
-
/** Use braille (2×4 sub-char resolution). Overrides halfBlock. */
|
|
1534
|
-
braille?: boolean;
|
|
1535
|
-
}
|
|
1536
|
-
declare const renderPixelArt: (pixels: PixelGrid, opts?: RenderOptions) => string;
|
|
1537
|
-
declare const SPRITES: Record<string, {
|
|
1538
|
-
pixels: PixelGrid;
|
|
1539
|
-
}>;
|
|
1540
|
-
declare const flipHorizontal: (pixels: PixelGrid) => PixelGrid;
|
|
1541
|
-
declare const flipVertical: (pixels: PixelGrid) => PixelGrid;
|
|
1542
|
-
declare const rotate90: (pixels: PixelGrid) => PixelGrid;
|
|
1543
|
-
interface GradientRectOptions {
|
|
1544
|
-
width?: number;
|
|
1545
|
-
height?: number;
|
|
1546
|
-
colors?: string[];
|
|
1547
|
-
/** Built-in style. Use `angle` for arbitrary directions. */
|
|
1548
|
-
style?: 'horizontal' | 'vertical' | 'diagonal' | 'radial' | 'conic';
|
|
1549
|
-
/** Custom angle in degrees (0=right, 90=down). Overrides `style`. */
|
|
1550
|
-
angle?: number;
|
|
1551
|
-
/**
|
|
1552
|
-
* Starting angle (degrees) for conic gradients. Default `0` (= right of center).
|
|
1553
|
-
* Rotates the radial sweep around the center point.
|
|
1554
|
-
*/
|
|
1555
|
-
startAngle?: number;
|
|
1556
|
-
/** Dithering algorithm. 'bayer' improves perceived smoothness. */
|
|
1557
|
-
dither?: 'none' | 'bayer';
|
|
1558
|
-
/** Render in braille mode for 2× horizontal × 4× vertical resolution. */
|
|
1559
|
-
braille?: boolean;
|
|
1560
|
-
}
|
|
1561
|
-
declare const gradientRect: (opts?: GradientRectOptions) => string;
|
|
1562
|
-
interface CanvasRenderOptions extends RenderOptions {
|
|
1563
|
-
/** Render only the dirty region instead of the whole canvas. Default: false. */
|
|
1564
|
-
dirtyOnly?: boolean;
|
|
1565
|
-
}
|
|
1566
|
-
interface Canvas {
|
|
1567
|
-
set: (x: number, y: number, color: Pixel) => void;
|
|
1568
|
-
get: (x: number, y: number) => Pixel;
|
|
1569
|
-
fill: (color: Pixel) => void;
|
|
1570
|
-
drawRect: (x: number, y: number, w: number, h: number, color: Pixel, fill?: boolean) => void;
|
|
1571
|
-
drawCircle: (cx: number, cy: number, radius: number, color: Pixel, fill?: boolean) => void;
|
|
1572
|
-
/** Composite a sprite at (x, y) with optional alpha blending. */
|
|
1573
|
-
drawSprite: (x: number, y: number, sprite: PixelGrid) => void;
|
|
1574
|
-
render: (opts?: CanvasRenderOptions) => string;
|
|
1575
|
-
print: (opts?: CanvasRenderOptions) => void;
|
|
1576
|
-
/** Resize the canvas, preserving content within the new bounds. */
|
|
1577
|
-
resize: (newWidth: number, newHeight: number, fillColor?: Pixel) => void;
|
|
1578
|
-
/** Mark all pixels as dirty (forces full redraw on next dirtyOnly render). */
|
|
1579
|
-
markDirty: () => void;
|
|
1580
|
-
/** Clear the dirty region tracker (after a full render). */
|
|
1581
|
-
clearDirty: () => void;
|
|
1582
|
-
width: number;
|
|
1583
|
-
height: number;
|
|
1584
|
-
/** Deep copy of the current pixel grid. Mutations don't affect the canvas. */
|
|
1585
|
-
pixels: PixelGrid;
|
|
1586
|
-
}
|
|
1587
|
-
declare const createCanvas: (width: number, height: number, fillColor?: Pixel) => Canvas;
|
|
1588
|
-
declare const images: {
|
|
1589
|
-
render: (pixels: PixelGrid, opts?: RenderOptions) => string;
|
|
1590
|
-
sprites: Record<string, {
|
|
1591
|
-
pixels: PixelGrid;
|
|
1592
|
-
}>;
|
|
1593
|
-
flipHorizontal: (pixels: PixelGrid) => PixelGrid;
|
|
1594
|
-
flipVertical: (pixels: PixelGrid) => PixelGrid;
|
|
1595
|
-
rotate90: (pixels: PixelGrid) => PixelGrid;
|
|
1596
|
-
sprite(name: string, opts?: RenderOptions): string;
|
|
1597
|
-
gradientRect: (opts?: GradientRectOptions) => string;
|
|
1598
|
-
createCanvas: (width: number, height: number, fillColor?: Pixel) => Canvas;
|
|
1599
|
-
colors: {
|
|
1600
|
-
hex: (h: unknown) => RGB | null;
|
|
1601
|
-
lerp: (a: RGB, b: RGB, t: number) => RGB;
|
|
1602
|
-
blend: (fg: Pixel, bg: RGB) => RGB;
|
|
1603
|
-
};
|
|
1604
|
-
clearAnsiCache: () => void;
|
|
1605
|
-
};
|
|
1606
|
-
|
|
1607
1787
|
declare const ansimax: {
|
|
1608
1788
|
color: {
|
|
1609
1789
|
black: ColorFn;
|
|
@@ -1685,6 +1865,9 @@ declare const ansimax: {
|
|
|
1685
1865
|
logo: (text: string, opts?: LogoOptions) => string;
|
|
1686
1866
|
stream: (text: string, opts?: StreamOptions) => AsyncGenerator<string, void, unknown>;
|
|
1687
1867
|
measure: (text: string, font?: FontName | string, letterSpacing?: number) => Dimensions;
|
|
1868
|
+
fromImage: (pixels: PixelGrid, opts?: FromImageOptions) => string;
|
|
1869
|
+
figletText: (text: string, font: FigletFont, opts?: FigletOptions) => string;
|
|
1870
|
+
parseFiglet: (flfContent: string) => FigletFont;
|
|
1688
1871
|
stageRender: (text: string, font: FontName | string, letterSpacing?: number) => string;
|
|
1689
1872
|
stageAlign: (rendered: string, align: "left" | "center") => string;
|
|
1690
1873
|
stageColorize: (rendered: string, colorFn: ColorFn | null, perCharColor: boolean) => string;
|
|
@@ -1733,9 +1916,9 @@ declare const ansimax: {
|
|
|
1733
1916
|
};
|
|
1734
1917
|
trees: {
|
|
1735
1918
|
tree: (root: string | Partial<TreeData>) => TreeNode;
|
|
1736
|
-
render: (root: TreeData, opts?: RenderOptions
|
|
1737
|
-
renderStream: (root: TreeData, opts?: RenderOptions
|
|
1738
|
-
measure: (root: TreeData, opts?: RenderOptions
|
|
1919
|
+
render: (root: TreeData, opts?: RenderOptions) => string;
|
|
1920
|
+
renderStream: (root: TreeData, opts?: RenderOptions) => Generator<string, void, unknown>;
|
|
1921
|
+
measure: (root: TreeData, opts?: RenderOptions) => TreeDimensions;
|
|
1739
1922
|
walk: (root: TreeData, visitor: WalkVisitor) => void;
|
|
1740
1923
|
find: (root: TreeData, predicate: (node: TreeData, depth: number) => boolean) => TreeData | null;
|
|
1741
1924
|
count: (root: TreeData) => number;
|
|
@@ -1747,14 +1930,14 @@ declare const ansimax: {
|
|
|
1747
1930
|
};
|
|
1748
1931
|
themes: ThemeInstance;
|
|
1749
1932
|
images: {
|
|
1750
|
-
render: (pixels: PixelGrid, opts?: RenderOptions) => string;
|
|
1933
|
+
render: (pixels: PixelGrid, opts?: RenderOptions$1) => string;
|
|
1751
1934
|
sprites: Record<string, {
|
|
1752
1935
|
pixels: PixelGrid;
|
|
1753
1936
|
}>;
|
|
1754
1937
|
flipHorizontal: (pixels: PixelGrid) => PixelGrid;
|
|
1755
1938
|
flipVertical: (pixels: PixelGrid) => PixelGrid;
|
|
1756
1939
|
rotate90: (pixels: PixelGrid) => PixelGrid;
|
|
1757
|
-
sprite(name: string, opts?: RenderOptions): string;
|
|
1940
|
+
sprite(name: string, opts?: RenderOptions$1): string;
|
|
1758
1941
|
gradientRect: (opts?: GradientRectOptions) => string;
|
|
1759
1942
|
createCanvas: (width: number, height: number, fillColor?: Pixel) => Canvas;
|
|
1760
1943
|
colors: {
|
|
@@ -1767,4 +1950,4 @@ declare const ansimax: {
|
|
|
1767
1950
|
configure: (opts?: AnsimaxConfig, meta?: ConfigureOptions) => void;
|
|
1768
1951
|
};
|
|
1769
1952
|
|
|
1770
|
-
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 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
|
|
1953
|
+
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 };
|