asciify-engine 4.0.0 → 4.1.0
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/README.md +10 -7
- package/dist/core.cjs +1 -1
- package/dist/core.d.cts +6 -6
- package/dist/core.d.ts +6 -6
- package/dist/core.js +1 -1
- package/dist/hover.cjs +1 -1
- package/dist/hover.d.cts +1 -1
- package/dist/hover.d.ts +1 -1
- package/dist/hover.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +1 -1
- package/dist/model-BJXd0Jl-.d.ts +202 -0
- package/dist/model-aIWlIoDT.d.cts +202 -0
- package/dist/studio.d.cts +4 -133
- package/dist/studio.d.ts +4 -133
- package/dist/types-BeXEm4UY.d.cts +323 -0
- package/dist/types-BeXEm4UY.d.ts +323 -0
- package/package.json +1 -1
- package/skills/asciify-engine/SKILL.md +5 -5
- package/skills/asciify-engine/references/hero-finish.md +1 -1
- package/skills/asciify-engine/references/upgrading.md +7 -2
- package/dist/characters-BNTu2oEF.d.cts +0 -71
- package/dist/characters-BNTu2oEF.d.ts +0 -71
- package/dist/types-CYKIEtDC.d.cts +0 -586
- package/dist/types-CYKIEtDC.d.ts +0 -586
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
type ColorMode = 'grayscale' | 'fullcolor' | 'matrix' | 'accent';
|
|
2
|
+
type RenderMode = 'ascii' | 'dots';
|
|
3
|
+
type AnimationStyle = 'none' | 'caustics' | 'current' | 'reform';
|
|
4
|
+
/** Core media draws ASCII/dots; use StudioStyle for the 15 render styles. */
|
|
5
|
+
type ArtStyle = 'classic';
|
|
6
|
+
type HoverEffect = 'spotlight' | 'magnify' | 'repel' | 'glow' | 'colorShift' | 'attract' | 'shatter' | 'trail' | 'glitchText';
|
|
7
|
+
type HoverShape = 'circle' | 'box';
|
|
8
|
+
type HoverPreset = 'none' | 'subtle' | 'flashlight' | 'magnifier' | 'forceField' | 'neon' | 'fire' | 'ice' | 'gravity' | 'shatter' | 'ghost' | 'glitchReveal';
|
|
9
|
+
type SourceCropUnit = 'percent' | 'pixel';
|
|
10
|
+
type SourceCropAnchor = 'center' | 'top' | 'bottom' | 'left' | 'right' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
|
11
|
+
interface SourceCrop {
|
|
12
|
+
/** Legacy crop origin on the source media. Percent values use 0–1. Default: centered when cropped */
|
|
13
|
+
x?: number;
|
|
14
|
+
/** Legacy crop origin on the source media. Percent values use 0–1. Default: centered when cropped */
|
|
15
|
+
y?: number;
|
|
16
|
+
/** Legacy crop width on the source media. Percent values use 0–1. Default: mirrors `height` to preserve proportions */
|
|
17
|
+
width?: number;
|
|
18
|
+
/** Legacy crop height on the source media. Percent values use 0–1. Default: mirrors `width` to preserve proportions */
|
|
19
|
+
height?: number;
|
|
20
|
+
/** CSS-like crop inset from the top edge. Percent values use 0–1. */
|
|
21
|
+
top?: number;
|
|
22
|
+
/** CSS-like crop inset from the right edge. Percent values use 0–1. */
|
|
23
|
+
right?: number;
|
|
24
|
+
/** CSS-like crop inset from the bottom edge. Percent values use 0–1. */
|
|
25
|
+
bottom?: number;
|
|
26
|
+
/** CSS-like crop inset from the left edge. Percent values use 0–1. */
|
|
27
|
+
left?: number;
|
|
28
|
+
/**
|
|
29
|
+
* Keep the source aspect ratio when deriving a crop from a single `width` or
|
|
30
|
+
* `height`. CSS-like side insets (`top`, `right`, `bottom`, `left`) already
|
|
31
|
+
* define an exact source view box, and `asciifyVideo` sizes from that crop
|
|
32
|
+
* aspect so the output does not stretch. Default: `true`.
|
|
33
|
+
*/
|
|
34
|
+
preserveAspect?: boolean;
|
|
35
|
+
/** Bias auto-centered crops toward an edge or corner. Default: `'center'` */
|
|
36
|
+
anchor?: SourceCropAnchor;
|
|
37
|
+
/** Interpret values as normalized percentages or source pixels. Default: `'percent'` */
|
|
38
|
+
unit?: SourceCropUnit;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Named colour palette presets — pass as `colorMode` for themed rendering.
|
|
42
|
+
* Applied as a post-process colour remap over the standard grayscale output.
|
|
43
|
+
*/
|
|
44
|
+
type PaletteTheme = 'dracula' | 'monokai' | 'nord' | 'catppuccin' | 'solarized' | 'gruvbox';
|
|
45
|
+
declare const PALETTE_THEMES: Record<PaletteTheme, {
|
|
46
|
+
name: string;
|
|
47
|
+
accent: string;
|
|
48
|
+
bg: string;
|
|
49
|
+
fg: string;
|
|
50
|
+
}>;
|
|
51
|
+
type SourceType = 'image' | 'video' | 'gif' | null;
|
|
52
|
+
interface AsciiOptions {
|
|
53
|
+
/** Character cell width in pixels. Smaller = more detail, more cells. Default: `7` */
|
|
54
|
+
fontSize: number;
|
|
55
|
+
/** Extra horizontal spacing between characters (pixels). Default: `1` */
|
|
56
|
+
charSpacing: number;
|
|
57
|
+
/**
|
|
58
|
+
* Brightness adjustment applied before luminance mapping.
|
|
59
|
+
* Range −1 (black) → 0 (unchanged) → 1 (white). Default: `0`
|
|
60
|
+
*/
|
|
61
|
+
brightness: number;
|
|
62
|
+
/**
|
|
63
|
+
* Contrast boost applied before luminance mapping.
|
|
64
|
+
* `0` = unchanged, positive values increase contrast, negative decrease it.
|
|
65
|
+
* Default: `0`
|
|
66
|
+
*/
|
|
67
|
+
contrast: number;
|
|
68
|
+
/**
|
|
69
|
+
* Character density ramp — ordered from lightest to darkest.
|
|
70
|
+
* Use `CHARACTER_SETS.standard.chars` for a curated ramp or supply your own string.
|
|
71
|
+
* Default: `' .:-=+*#%@'`
|
|
72
|
+
*/
|
|
73
|
+
charset: string;
|
|
74
|
+
/**
|
|
75
|
+
* Colour output mode.
|
|
76
|
+
* - `'grayscale'` — white-on-black monochrome
|
|
77
|
+
* - `'fullcolor'` — samples pixel colours from the source
|
|
78
|
+
* - `'matrix'` — green phosphor terminal look
|
|
79
|
+
* - `'accent'` — single accent colour with intensity-driven brightness
|
|
80
|
+
* Default: `'grayscale'`
|
|
81
|
+
*/
|
|
82
|
+
colorMode: ColorMode;
|
|
83
|
+
/**
|
|
84
|
+
* The accent colour used when `colorMode` is `'accent'` or `'matrix'`.
|
|
85
|
+
* Any CSS colour string. Default: `'#d4ff00'`
|
|
86
|
+
*/
|
|
87
|
+
/**
|
|
88
|
+
* Hex color string used when `colorMode` is `'accent'`.
|
|
89
|
+
* Set to `'auto'` to let the engine pick contrasting ink automatically:
|
|
90
|
+
* dark ink (`#0d0d0d`) in light mode, light ink (`#faf9f7`) in dark mode.
|
|
91
|
+
*/
|
|
92
|
+
accentColor: string;
|
|
93
|
+
/**
|
|
94
|
+
* Invert luminance mapping (light pixels → dense chars). Default: `false`
|
|
95
|
+
*
|
|
96
|
+
* Set to `'auto'` to let the engine detect the OS color scheme:
|
|
97
|
+
* - Light mode → inverts (bright pixel = dark char = visible on white background)
|
|
98
|
+
* - Dark mode → normal (bright pixel = bright char = visible on dark background)
|
|
99
|
+
*/
|
|
100
|
+
invert: boolean | 'auto';
|
|
101
|
+
/**
|
|
102
|
+
* Render mode.
|
|
103
|
+
* - `'ascii'` — characters drawn as text
|
|
104
|
+
* - `'dots'` — each cell rendered as a filled circle (particle look)
|
|
105
|
+
* Default: `'ascii'`
|
|
106
|
+
*/
|
|
107
|
+
renderMode: RenderMode;
|
|
108
|
+
/**
|
|
109
|
+
* Per-character animation driven over time.
|
|
110
|
+
* Applies wave, glitch, rain-drop, spiral, and other effects to the rendered text.
|
|
111
|
+
* Default: `'none'`
|
|
112
|
+
*/
|
|
113
|
+
animationStyle: AnimationStyle;
|
|
114
|
+
/** Speed multiplier for `animationStyle` effects. Default: `1` */
|
|
115
|
+
animationSpeed: number;
|
|
116
|
+
/**
|
|
117
|
+
* Size of each dot relative to the cell when `renderMode === 'dots'`.
|
|
118
|
+
* `1` fills the whole cell, `0.5` draws half-size circles. Default: `0.8`
|
|
119
|
+
*/
|
|
120
|
+
dotSizeRatio: number;
|
|
121
|
+
/**
|
|
122
|
+
* Ordered Bayer (4×4) dither strength applied to the luminance map.
|
|
123
|
+
* `0` = no dithering, `1` = full dithering. Default: `0`
|
|
124
|
+
*/
|
|
125
|
+
ditherStrength: number;
|
|
126
|
+
/**
|
|
127
|
+
* Assumed aspect ratio (width ÷ height) of a single output character.
|
|
128
|
+
* Controls how many rows vs columns are generated — must match your rendering
|
|
129
|
+
* environment to preserve the source image's proportions.
|
|
130
|
+
* - `0.55` — browser monospace at `line-height: 1.09` (default)
|
|
131
|
+
* - `0.52` — browser monospace at `line-height: 1.15`
|
|
132
|
+
* - `0.5` — most terminal emulators
|
|
133
|
+
* Default: `0.55`
|
|
134
|
+
*/
|
|
135
|
+
charAspect: number;
|
|
136
|
+
/**
|
|
137
|
+
* Auto-stretch the luminance range before charset mapping.
|
|
138
|
+
* When `true`, the darkest pixel in the frame maps to the first charset character
|
|
139
|
+
* and the brightest to the last, maximising perceived detail and contrast.
|
|
140
|
+
* Particularly useful for images with low inherent contrast or muted tones.
|
|
141
|
+
* Default: `false`
|
|
142
|
+
*/
|
|
143
|
+
normalize: boolean;
|
|
144
|
+
/**
|
|
145
|
+
* Overall intensity of the hover / cursor interaction effect.
|
|
146
|
+
* `0` disables the effect. Default: `0`
|
|
147
|
+
*/
|
|
148
|
+
hoverStrength: number;
|
|
149
|
+
/**
|
|
150
|
+
* Radius of the hover interaction zone as a fraction of the canvas size.
|
|
151
|
+
* `0.1` = 10% of canvas width. Default: `0.2`
|
|
152
|
+
*/
|
|
153
|
+
hoverRadius: number;
|
|
154
|
+
/**
|
|
155
|
+
* Which cursor interaction style to apply when `hoverStrength > 0`.
|
|
156
|
+
* See `HoverPreset` or `HOVER_PRESETS` for ready-made configurations.
|
|
157
|
+
* Default: `'spotlight'`
|
|
158
|
+
*/
|
|
159
|
+
hoverEffect: HoverEffect;
|
|
160
|
+
/**
|
|
161
|
+
* Tint colour used by hover effects such as spotlight, glow, and colorShift.
|
|
162
|
+
* Any CSS colour string. Default: `'#ffffff'`
|
|
163
|
+
*/
|
|
164
|
+
hoverColor: string;
|
|
165
|
+
/**
|
|
166
|
+
* Shape of the hover interaction zone.
|
|
167
|
+
* - `'circle'` — radial falloff (default)
|
|
168
|
+
* - `'box'` — rectangular zone, text fills a block around the cursor
|
|
169
|
+
* Default: `'circle'`
|
|
170
|
+
*/
|
|
171
|
+
hoverShape: HoverShape;
|
|
172
|
+
/**
|
|
173
|
+
* Text string revealed by the `'glitchText'` hover effect.
|
|
174
|
+
* Characters around the cursor scramble and resolve into this text.
|
|
175
|
+
* Supports `\n` for multi-line reveals.
|
|
176
|
+
*
|
|
177
|
+
* Pass an **array** of strings to cycle through different words based on
|
|
178
|
+
* the cursor's grid region — the engine picks one via a spatial hash so
|
|
179
|
+
* each area of the canvas shows a different word.
|
|
180
|
+
*
|
|
181
|
+
* Default: `'ASCIIFY'`
|
|
182
|
+
*
|
|
183
|
+
* @example
|
|
184
|
+
* // Single word:
|
|
185
|
+
* options: { hoverEffect: 'glitchText', hoverText: 'HELLO' }
|
|
186
|
+
*
|
|
187
|
+
* // Word pool — different text at different cursor positions:
|
|
188
|
+
* options: { hoverEffect: 'glitchText', hoverText: ['DEPLOY', 'SCALE', 'SHIP', 'BUILD'] }
|
|
189
|
+
*/
|
|
190
|
+
hoverText: string | string[];
|
|
191
|
+
/**
|
|
192
|
+
* Core renderer discriminator. No legacy preset lookup is performed.
|
|
193
|
+
* Core rendering uses `classic`; select the current render styles through `/studio`.
|
|
194
|
+
*/
|
|
195
|
+
artStyle: ArtStyle;
|
|
196
|
+
/** Explicit fine-dither treatment for the optional hover compositor. */
|
|
197
|
+
fineDither?: boolean;
|
|
198
|
+
/**
|
|
199
|
+
* Custom repeating text used when `artStyle` is `'letters'` or when you set
|
|
200
|
+
* a custom charset. Leave empty to use the selected `charset`. Default: `''`
|
|
201
|
+
*/
|
|
202
|
+
customText: string;
|
|
203
|
+
/**
|
|
204
|
+
* Chroma-key colour to remove from the source (green screen / blue screen).
|
|
205
|
+
* Pixels whose RGB distance from this colour is within `chromaKeyTolerance`
|
|
206
|
+
* are keyed out: their character becomes a space and alpha is set to 0,
|
|
207
|
+
* letting the canvas background show through.
|
|
208
|
+
*
|
|
209
|
+
* - `true` — **smart green screen**: heuristic detection (`g > r*1.4 && g > b*1.4`)
|
|
210
|
+
* catches every shade of green screen (lime, broadcast, chroma green) with no
|
|
211
|
+
* config. Works on virtually all studio/streaming footage.
|
|
212
|
+
* - `'blue-screen'` — **smart blue screen**: same heuristic for blue.
|
|
213
|
+
* - `{ r, g, b }` or CSS colour string — custom key colour + `chromaKeyTolerance`
|
|
214
|
+
* - `null` / `false` — disabled (default)
|
|
215
|
+
*
|
|
216
|
+
* @example
|
|
217
|
+
* // Standard green screen — zero config:
|
|
218
|
+
* options: { chromaKey: true }
|
|
219
|
+
*
|
|
220
|
+
* // Blue screen — zero config:
|
|
221
|
+
* options: { chromaKey: 'blue-screen' }
|
|
222
|
+
*
|
|
223
|
+
* // Custom CSS colour:
|
|
224
|
+
* options: { chromaKey: '#00b140', chromaKeyTolerance: 70 }
|
|
225
|
+
*/
|
|
226
|
+
chromaKey: {
|
|
227
|
+
r: number;
|
|
228
|
+
g: number;
|
|
229
|
+
b: number;
|
|
230
|
+
} | string | boolean | null;
|
|
231
|
+
/**
|
|
232
|
+
* Euclidean RGB tolerance radius for chroma-key detection.
|
|
233
|
+
* `0` = exact match only, `441` ≈ key out everything.
|
|
234
|
+
* Higher values remove more pixels. Default: `60`
|
|
235
|
+
*/
|
|
236
|
+
chromaKeyTolerance: number;
|
|
237
|
+
/**
|
|
238
|
+
* Extra normalized padding kept around the detected chroma-key foreground when
|
|
239
|
+
* `asciifyVideo` auto-trims keyed video content inside `sourceCrop`.
|
|
240
|
+
* `0` hugs the visible foreground. `0.01` keeps 1% safety padding.
|
|
241
|
+
* Default: `0.002`
|
|
242
|
+
*/
|
|
243
|
+
chromaKeyTrimPadding: number;
|
|
244
|
+
/**
|
|
245
|
+
* Minimum source-pixel luminance for chroma-key foreground auto-trim.
|
|
246
|
+
* Raise this when faint edge noise is counted as content and prevents a
|
|
247
|
+
* keyed subject from filling a preserved-ratio layout. Range `0–255`.
|
|
248
|
+
* Default: `0`
|
|
249
|
+
*/
|
|
250
|
+
chromaKeyTrimLuminanceThreshold: number;
|
|
251
|
+
/**
|
|
252
|
+
* How keyed video foreground trimming is applied when `chromaKey` and
|
|
253
|
+
* `sourceCrop` are enabled.
|
|
254
|
+
*
|
|
255
|
+
* - `'range'` samples the video/scroll range once and keeps a stable union
|
|
256
|
+
* crop. Best default for consistent framing.
|
|
257
|
+
* - `'frame'` remeasures each rendered frame and expands the crop to the
|
|
258
|
+
* render aspect. Best for scroll-scrubbed hero footage where foreground
|
|
259
|
+
* position changes and pure contain leaves empty edges.
|
|
260
|
+
* - `'off'` disables automatic keyed foreground trimming.
|
|
261
|
+
*
|
|
262
|
+
* Default: `'range'`
|
|
263
|
+
*/
|
|
264
|
+
chromaKeyTrimMode: 'range' | 'frame' | 'off';
|
|
265
|
+
/**
|
|
266
|
+
* Optional source crop applied before ASCII sampling.
|
|
267
|
+
*
|
|
268
|
+
* Use this when the media has empty edges or a subject that should be framed
|
|
269
|
+
* tighter without changing the destination canvas size.
|
|
270
|
+
*
|
|
271
|
+
* @example
|
|
272
|
+
* // Remove 15% from the top and 15% from the bottom, preserving proportions:
|
|
273
|
+
* options: { sourceCrop: { top: 0.15, bottom: 0.15 } }
|
|
274
|
+
*
|
|
275
|
+
* @example
|
|
276
|
+
* // Keep 70% of the source, preserve proportions, and center it:
|
|
277
|
+
* options: { sourceCrop: { height: 0.7 } }
|
|
278
|
+
*
|
|
279
|
+
* @example
|
|
280
|
+
* // Use an exact source window when manual framing should override proportions:
|
|
281
|
+
* options: { sourceCrop: { x: 0.05, y: 0.08, width: 0.9, height: 0.9, preserveAspect: false } }
|
|
282
|
+
*/
|
|
283
|
+
sourceCrop?: SourceCrop | null;
|
|
284
|
+
/**
|
|
285
|
+
* Array of charset strings to cycle through over time.
|
|
286
|
+
* The engine picks `charsetFrames[Math.floor(time * charsetFps) % length]` on each
|
|
287
|
+
* render tick, re-mapping characters from stored cell luminance.
|
|
288
|
+
* Pairs beautifully with `animationStyle` and `asciiBackground`.
|
|
289
|
+
*
|
|
290
|
+
* Supply your own array of character ramps:
|
|
291
|
+
* @example
|
|
292
|
+
* options: { charsetFrames: [CHARACTER_SETS.standard.chars, CHARACTER_SETS.blocks.chars] }
|
|
293
|
+
*/
|
|
294
|
+
charsetFrames?: string[];
|
|
295
|
+
/** Cycle rate for `charsetFrames` in frames-per-second. Default: `2` */
|
|
296
|
+
charsetFps?: number;
|
|
297
|
+
}
|
|
298
|
+
interface AsciiCell {
|
|
299
|
+
char: string;
|
|
300
|
+
r: number;
|
|
301
|
+
g: number;
|
|
302
|
+
b: number;
|
|
303
|
+
a: number;
|
|
304
|
+
/** Stored dithered luminance (0–255). Present when the frame was generated by the engine. Used for dynamic charset re-selection at render time via `charsetFrames`. */
|
|
305
|
+
lum?: number;
|
|
306
|
+
}
|
|
307
|
+
type AsciiFrame = AsciiCell[][];
|
|
308
|
+
interface AsciiResult {
|
|
309
|
+
frames: AsciiFrame[];
|
|
310
|
+
cols: number;
|
|
311
|
+
rows: number;
|
|
312
|
+
fps: number;
|
|
313
|
+
}
|
|
314
|
+
declare const DEFAULT_OPTIONS: AsciiOptions;
|
|
315
|
+
/**
|
|
316
|
+
* Hover presets — one-click configurations for the hover system.
|
|
317
|
+
*/
|
|
318
|
+
declare const HOVER_PRESETS: Record<HoverPreset, {
|
|
319
|
+
label: string;
|
|
320
|
+
options: Partial<AsciiOptions>;
|
|
321
|
+
}>;
|
|
322
|
+
|
|
323
|
+
export { type AsciiFrame as A, type ColorMode as C, DEFAULT_OPTIONS as D, type HoverEffect as H, PALETTE_THEMES as P, type RenderMode as R, type SourceType as S, type AsciiOptions as a, type ArtStyle as b, type AnimationStyle as c, type AsciiCell as d, type AsciiResult as e, HOVER_PRESETS as f, type HoverPreset as g, type HoverShape as h, type PaletteTheme as i };
|
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
type ColorMode = 'grayscale' | 'fullcolor' | 'matrix' | 'accent';
|
|
2
|
+
type RenderMode = 'ascii' | 'dots';
|
|
3
|
+
type AnimationStyle = 'none' | 'caustics' | 'current' | 'reform';
|
|
4
|
+
/** Core media draws ASCII/dots; use StudioStyle for the 15 render styles. */
|
|
5
|
+
type ArtStyle = 'classic';
|
|
6
|
+
type HoverEffect = 'spotlight' | 'magnify' | 'repel' | 'glow' | 'colorShift' | 'attract' | 'shatter' | 'trail' | 'glitchText';
|
|
7
|
+
type HoverShape = 'circle' | 'box';
|
|
8
|
+
type HoverPreset = 'none' | 'subtle' | 'flashlight' | 'magnifier' | 'forceField' | 'neon' | 'fire' | 'ice' | 'gravity' | 'shatter' | 'ghost' | 'glitchReveal';
|
|
9
|
+
type SourceCropUnit = 'percent' | 'pixel';
|
|
10
|
+
type SourceCropAnchor = 'center' | 'top' | 'bottom' | 'left' | 'right' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
|
11
|
+
interface SourceCrop {
|
|
12
|
+
/** Legacy crop origin on the source media. Percent values use 0–1. Default: centered when cropped */
|
|
13
|
+
x?: number;
|
|
14
|
+
/** Legacy crop origin on the source media. Percent values use 0–1. Default: centered when cropped */
|
|
15
|
+
y?: number;
|
|
16
|
+
/** Legacy crop width on the source media. Percent values use 0–1. Default: mirrors `height` to preserve proportions */
|
|
17
|
+
width?: number;
|
|
18
|
+
/** Legacy crop height on the source media. Percent values use 0–1. Default: mirrors `width` to preserve proportions */
|
|
19
|
+
height?: number;
|
|
20
|
+
/** CSS-like crop inset from the top edge. Percent values use 0–1. */
|
|
21
|
+
top?: number;
|
|
22
|
+
/** CSS-like crop inset from the right edge. Percent values use 0–1. */
|
|
23
|
+
right?: number;
|
|
24
|
+
/** CSS-like crop inset from the bottom edge. Percent values use 0–1. */
|
|
25
|
+
bottom?: number;
|
|
26
|
+
/** CSS-like crop inset from the left edge. Percent values use 0–1. */
|
|
27
|
+
left?: number;
|
|
28
|
+
/**
|
|
29
|
+
* Keep the source aspect ratio when deriving a crop from a single `width` or
|
|
30
|
+
* `height`. CSS-like side insets (`top`, `right`, `bottom`, `left`) already
|
|
31
|
+
* define an exact source view box, and `asciifyVideo` sizes from that crop
|
|
32
|
+
* aspect so the output does not stretch. Default: `true`.
|
|
33
|
+
*/
|
|
34
|
+
preserveAspect?: boolean;
|
|
35
|
+
/** Bias auto-centered crops toward an edge or corner. Default: `'center'` */
|
|
36
|
+
anchor?: SourceCropAnchor;
|
|
37
|
+
/** Interpret values as normalized percentages or source pixels. Default: `'percent'` */
|
|
38
|
+
unit?: SourceCropUnit;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Named colour palette presets — pass as `colorMode` for themed rendering.
|
|
42
|
+
* Applied as a post-process colour remap over the standard grayscale output.
|
|
43
|
+
*/
|
|
44
|
+
type PaletteTheme = 'dracula' | 'monokai' | 'nord' | 'catppuccin' | 'solarized' | 'gruvbox';
|
|
45
|
+
declare const PALETTE_THEMES: Record<PaletteTheme, {
|
|
46
|
+
name: string;
|
|
47
|
+
accent: string;
|
|
48
|
+
bg: string;
|
|
49
|
+
fg: string;
|
|
50
|
+
}>;
|
|
51
|
+
type SourceType = 'image' | 'video' | 'gif' | null;
|
|
52
|
+
interface AsciiOptions {
|
|
53
|
+
/** Character cell width in pixels. Smaller = more detail, more cells. Default: `7` */
|
|
54
|
+
fontSize: number;
|
|
55
|
+
/** Extra horizontal spacing between characters (pixels). Default: `1` */
|
|
56
|
+
charSpacing: number;
|
|
57
|
+
/**
|
|
58
|
+
* Brightness adjustment applied before luminance mapping.
|
|
59
|
+
* Range −1 (black) → 0 (unchanged) → 1 (white). Default: `0`
|
|
60
|
+
*/
|
|
61
|
+
brightness: number;
|
|
62
|
+
/**
|
|
63
|
+
* Contrast boost applied before luminance mapping.
|
|
64
|
+
* `0` = unchanged, positive values increase contrast, negative decrease it.
|
|
65
|
+
* Default: `0`
|
|
66
|
+
*/
|
|
67
|
+
contrast: number;
|
|
68
|
+
/**
|
|
69
|
+
* Character density ramp — ordered from lightest to darkest.
|
|
70
|
+
* Use `CHARACTER_SETS.standard.chars` for a curated ramp or supply your own string.
|
|
71
|
+
* Default: `' .:-=+*#%@'`
|
|
72
|
+
*/
|
|
73
|
+
charset: string;
|
|
74
|
+
/**
|
|
75
|
+
* Colour output mode.
|
|
76
|
+
* - `'grayscale'` — white-on-black monochrome
|
|
77
|
+
* - `'fullcolor'` — samples pixel colours from the source
|
|
78
|
+
* - `'matrix'` — green phosphor terminal look
|
|
79
|
+
* - `'accent'` — single accent colour with intensity-driven brightness
|
|
80
|
+
* Default: `'grayscale'`
|
|
81
|
+
*/
|
|
82
|
+
colorMode: ColorMode;
|
|
83
|
+
/**
|
|
84
|
+
* The accent colour used when `colorMode` is `'accent'` or `'matrix'`.
|
|
85
|
+
* Any CSS colour string. Default: `'#d4ff00'`
|
|
86
|
+
*/
|
|
87
|
+
/**
|
|
88
|
+
* Hex color string used when `colorMode` is `'accent'`.
|
|
89
|
+
* Set to `'auto'` to let the engine pick contrasting ink automatically:
|
|
90
|
+
* dark ink (`#0d0d0d`) in light mode, light ink (`#faf9f7`) in dark mode.
|
|
91
|
+
*/
|
|
92
|
+
accentColor: string;
|
|
93
|
+
/**
|
|
94
|
+
* Invert luminance mapping (light pixels → dense chars). Default: `false`
|
|
95
|
+
*
|
|
96
|
+
* Set to `'auto'` to let the engine detect the OS color scheme:
|
|
97
|
+
* - Light mode → inverts (bright pixel = dark char = visible on white background)
|
|
98
|
+
* - Dark mode → normal (bright pixel = bright char = visible on dark background)
|
|
99
|
+
*/
|
|
100
|
+
invert: boolean | 'auto';
|
|
101
|
+
/**
|
|
102
|
+
* Render mode.
|
|
103
|
+
* - `'ascii'` — characters drawn as text
|
|
104
|
+
* - `'dots'` — each cell rendered as a filled circle (particle look)
|
|
105
|
+
* Default: `'ascii'`
|
|
106
|
+
*/
|
|
107
|
+
renderMode: RenderMode;
|
|
108
|
+
/**
|
|
109
|
+
* Per-character animation driven over time.
|
|
110
|
+
* Applies wave, glitch, rain-drop, spiral, and other effects to the rendered text.
|
|
111
|
+
* Default: `'none'`
|
|
112
|
+
*/
|
|
113
|
+
animationStyle: AnimationStyle;
|
|
114
|
+
/** Speed multiplier for `animationStyle` effects. Default: `1` */
|
|
115
|
+
animationSpeed: number;
|
|
116
|
+
/**
|
|
117
|
+
* Size of each dot relative to the cell when `renderMode === 'dots'`.
|
|
118
|
+
* `1` fills the whole cell, `0.5` draws half-size circles. Default: `0.8`
|
|
119
|
+
*/
|
|
120
|
+
dotSizeRatio: number;
|
|
121
|
+
/**
|
|
122
|
+
* Ordered Bayer (4×4) dither strength applied to the luminance map.
|
|
123
|
+
* `0` = no dithering, `1` = full dithering. Default: `0`
|
|
124
|
+
*/
|
|
125
|
+
ditherStrength: number;
|
|
126
|
+
/**
|
|
127
|
+
* Assumed aspect ratio (width ÷ height) of a single output character.
|
|
128
|
+
* Controls how many rows vs columns are generated — must match your rendering
|
|
129
|
+
* environment to preserve the source image's proportions.
|
|
130
|
+
* - `0.55` — browser monospace at `line-height: 1.09` (default)
|
|
131
|
+
* - `0.52` — browser monospace at `line-height: 1.15`
|
|
132
|
+
* - `0.5` — most terminal emulators
|
|
133
|
+
* Default: `0.55`
|
|
134
|
+
*/
|
|
135
|
+
charAspect: number;
|
|
136
|
+
/**
|
|
137
|
+
* Auto-stretch the luminance range before charset mapping.
|
|
138
|
+
* When `true`, the darkest pixel in the frame maps to the first charset character
|
|
139
|
+
* and the brightest to the last, maximising perceived detail and contrast.
|
|
140
|
+
* Particularly useful for images with low inherent contrast or muted tones.
|
|
141
|
+
* Default: `false`
|
|
142
|
+
*/
|
|
143
|
+
normalize: boolean;
|
|
144
|
+
/**
|
|
145
|
+
* Overall intensity of the hover / cursor interaction effect.
|
|
146
|
+
* `0` disables the effect. Default: `0`
|
|
147
|
+
*/
|
|
148
|
+
hoverStrength: number;
|
|
149
|
+
/**
|
|
150
|
+
* Radius of the hover interaction zone as a fraction of the canvas size.
|
|
151
|
+
* `0.1` = 10% of canvas width. Default: `0.2`
|
|
152
|
+
*/
|
|
153
|
+
hoverRadius: number;
|
|
154
|
+
/**
|
|
155
|
+
* Which cursor interaction style to apply when `hoverStrength > 0`.
|
|
156
|
+
* See `HoverPreset` or `HOVER_PRESETS` for ready-made configurations.
|
|
157
|
+
* Default: `'spotlight'`
|
|
158
|
+
*/
|
|
159
|
+
hoverEffect: HoverEffect;
|
|
160
|
+
/**
|
|
161
|
+
* Tint colour used by hover effects such as spotlight, glow, and colorShift.
|
|
162
|
+
* Any CSS colour string. Default: `'#ffffff'`
|
|
163
|
+
*/
|
|
164
|
+
hoverColor: string;
|
|
165
|
+
/**
|
|
166
|
+
* Shape of the hover interaction zone.
|
|
167
|
+
* - `'circle'` — radial falloff (default)
|
|
168
|
+
* - `'box'` — rectangular zone, text fills a block around the cursor
|
|
169
|
+
* Default: `'circle'`
|
|
170
|
+
*/
|
|
171
|
+
hoverShape: HoverShape;
|
|
172
|
+
/**
|
|
173
|
+
* Text string revealed by the `'glitchText'` hover effect.
|
|
174
|
+
* Characters around the cursor scramble and resolve into this text.
|
|
175
|
+
* Supports `\n` for multi-line reveals.
|
|
176
|
+
*
|
|
177
|
+
* Pass an **array** of strings to cycle through different words based on
|
|
178
|
+
* the cursor's grid region — the engine picks one via a spatial hash so
|
|
179
|
+
* each area of the canvas shows a different word.
|
|
180
|
+
*
|
|
181
|
+
* Default: `'ASCIIFY'`
|
|
182
|
+
*
|
|
183
|
+
* @example
|
|
184
|
+
* // Single word:
|
|
185
|
+
* options: { hoverEffect: 'glitchText', hoverText: 'HELLO' }
|
|
186
|
+
*
|
|
187
|
+
* // Word pool — different text at different cursor positions:
|
|
188
|
+
* options: { hoverEffect: 'glitchText', hoverText: ['DEPLOY', 'SCALE', 'SHIP', 'BUILD'] }
|
|
189
|
+
*/
|
|
190
|
+
hoverText: string | string[];
|
|
191
|
+
/**
|
|
192
|
+
* Core renderer discriminator. No legacy preset lookup is performed.
|
|
193
|
+
* Core rendering uses `classic`; select the current render styles through `/studio`.
|
|
194
|
+
*/
|
|
195
|
+
artStyle: ArtStyle;
|
|
196
|
+
/** Explicit fine-dither treatment for the optional hover compositor. */
|
|
197
|
+
fineDither?: boolean;
|
|
198
|
+
/**
|
|
199
|
+
* Custom repeating text used when `artStyle` is `'letters'` or when you set
|
|
200
|
+
* a custom charset. Leave empty to use the selected `charset`. Default: `''`
|
|
201
|
+
*/
|
|
202
|
+
customText: string;
|
|
203
|
+
/**
|
|
204
|
+
* Chroma-key colour to remove from the source (green screen / blue screen).
|
|
205
|
+
* Pixels whose RGB distance from this colour is within `chromaKeyTolerance`
|
|
206
|
+
* are keyed out: their character becomes a space and alpha is set to 0,
|
|
207
|
+
* letting the canvas background show through.
|
|
208
|
+
*
|
|
209
|
+
* - `true` — **smart green screen**: heuristic detection (`g > r*1.4 && g > b*1.4`)
|
|
210
|
+
* catches every shade of green screen (lime, broadcast, chroma green) with no
|
|
211
|
+
* config. Works on virtually all studio/streaming footage.
|
|
212
|
+
* - `'blue-screen'` — **smart blue screen**: same heuristic for blue.
|
|
213
|
+
* - `{ r, g, b }` or CSS colour string — custom key colour + `chromaKeyTolerance`
|
|
214
|
+
* - `null` / `false` — disabled (default)
|
|
215
|
+
*
|
|
216
|
+
* @example
|
|
217
|
+
* // Standard green screen — zero config:
|
|
218
|
+
* options: { chromaKey: true }
|
|
219
|
+
*
|
|
220
|
+
* // Blue screen — zero config:
|
|
221
|
+
* options: { chromaKey: 'blue-screen' }
|
|
222
|
+
*
|
|
223
|
+
* // Custom CSS colour:
|
|
224
|
+
* options: { chromaKey: '#00b140', chromaKeyTolerance: 70 }
|
|
225
|
+
*/
|
|
226
|
+
chromaKey: {
|
|
227
|
+
r: number;
|
|
228
|
+
g: number;
|
|
229
|
+
b: number;
|
|
230
|
+
} | string | boolean | null;
|
|
231
|
+
/**
|
|
232
|
+
* Euclidean RGB tolerance radius for chroma-key detection.
|
|
233
|
+
* `0` = exact match only, `441` ≈ key out everything.
|
|
234
|
+
* Higher values remove more pixels. Default: `60`
|
|
235
|
+
*/
|
|
236
|
+
chromaKeyTolerance: number;
|
|
237
|
+
/**
|
|
238
|
+
* Extra normalized padding kept around the detected chroma-key foreground when
|
|
239
|
+
* `asciifyVideo` auto-trims keyed video content inside `sourceCrop`.
|
|
240
|
+
* `0` hugs the visible foreground. `0.01` keeps 1% safety padding.
|
|
241
|
+
* Default: `0.002`
|
|
242
|
+
*/
|
|
243
|
+
chromaKeyTrimPadding: number;
|
|
244
|
+
/**
|
|
245
|
+
* Minimum source-pixel luminance for chroma-key foreground auto-trim.
|
|
246
|
+
* Raise this when faint edge noise is counted as content and prevents a
|
|
247
|
+
* keyed subject from filling a preserved-ratio layout. Range `0–255`.
|
|
248
|
+
* Default: `0`
|
|
249
|
+
*/
|
|
250
|
+
chromaKeyTrimLuminanceThreshold: number;
|
|
251
|
+
/**
|
|
252
|
+
* How keyed video foreground trimming is applied when `chromaKey` and
|
|
253
|
+
* `sourceCrop` are enabled.
|
|
254
|
+
*
|
|
255
|
+
* - `'range'` samples the video/scroll range once and keeps a stable union
|
|
256
|
+
* crop. Best default for consistent framing.
|
|
257
|
+
* - `'frame'` remeasures each rendered frame and expands the crop to the
|
|
258
|
+
* render aspect. Best for scroll-scrubbed hero footage where foreground
|
|
259
|
+
* position changes and pure contain leaves empty edges.
|
|
260
|
+
* - `'off'` disables automatic keyed foreground trimming.
|
|
261
|
+
*
|
|
262
|
+
* Default: `'range'`
|
|
263
|
+
*/
|
|
264
|
+
chromaKeyTrimMode: 'range' | 'frame' | 'off';
|
|
265
|
+
/**
|
|
266
|
+
* Optional source crop applied before ASCII sampling.
|
|
267
|
+
*
|
|
268
|
+
* Use this when the media has empty edges or a subject that should be framed
|
|
269
|
+
* tighter without changing the destination canvas size.
|
|
270
|
+
*
|
|
271
|
+
* @example
|
|
272
|
+
* // Remove 15% from the top and 15% from the bottom, preserving proportions:
|
|
273
|
+
* options: { sourceCrop: { top: 0.15, bottom: 0.15 } }
|
|
274
|
+
*
|
|
275
|
+
* @example
|
|
276
|
+
* // Keep 70% of the source, preserve proportions, and center it:
|
|
277
|
+
* options: { sourceCrop: { height: 0.7 } }
|
|
278
|
+
*
|
|
279
|
+
* @example
|
|
280
|
+
* // Use an exact source window when manual framing should override proportions:
|
|
281
|
+
* options: { sourceCrop: { x: 0.05, y: 0.08, width: 0.9, height: 0.9, preserveAspect: false } }
|
|
282
|
+
*/
|
|
283
|
+
sourceCrop?: SourceCrop | null;
|
|
284
|
+
/**
|
|
285
|
+
* Array of charset strings to cycle through over time.
|
|
286
|
+
* The engine picks `charsetFrames[Math.floor(time * charsetFps) % length]` on each
|
|
287
|
+
* render tick, re-mapping characters from stored cell luminance.
|
|
288
|
+
* Pairs beautifully with `animationStyle` and `asciiBackground`.
|
|
289
|
+
*
|
|
290
|
+
* Supply your own array of character ramps:
|
|
291
|
+
* @example
|
|
292
|
+
* options: { charsetFrames: [CHARACTER_SETS.standard.chars, CHARACTER_SETS.blocks.chars] }
|
|
293
|
+
*/
|
|
294
|
+
charsetFrames?: string[];
|
|
295
|
+
/** Cycle rate for `charsetFrames` in frames-per-second. Default: `2` */
|
|
296
|
+
charsetFps?: number;
|
|
297
|
+
}
|
|
298
|
+
interface AsciiCell {
|
|
299
|
+
char: string;
|
|
300
|
+
r: number;
|
|
301
|
+
g: number;
|
|
302
|
+
b: number;
|
|
303
|
+
a: number;
|
|
304
|
+
/** Stored dithered luminance (0–255). Present when the frame was generated by the engine. Used for dynamic charset re-selection at render time via `charsetFrames`. */
|
|
305
|
+
lum?: number;
|
|
306
|
+
}
|
|
307
|
+
type AsciiFrame = AsciiCell[][];
|
|
308
|
+
interface AsciiResult {
|
|
309
|
+
frames: AsciiFrame[];
|
|
310
|
+
cols: number;
|
|
311
|
+
rows: number;
|
|
312
|
+
fps: number;
|
|
313
|
+
}
|
|
314
|
+
declare const DEFAULT_OPTIONS: AsciiOptions;
|
|
315
|
+
/**
|
|
316
|
+
* Hover presets — one-click configurations for the hover system.
|
|
317
|
+
*/
|
|
318
|
+
declare const HOVER_PRESETS: Record<HoverPreset, {
|
|
319
|
+
label: string;
|
|
320
|
+
options: Partial<AsciiOptions>;
|
|
321
|
+
}>;
|
|
322
|
+
|
|
323
|
+
export { type AsciiFrame as A, type ColorMode as C, DEFAULT_OPTIONS as D, type HoverEffect as H, PALETTE_THEMES as P, type RenderMode as R, type SourceType as S, type AsciiOptions as a, type ArtStyle as b, type AnimationStyle as c, type AsciiCell as d, type AsciiResult as e, HOVER_PRESETS as f, type HoverPreset as g, type HoverShape as h, type PaletteTheme as i };
|
package/package.json
CHANGED