@iwascreatedtocreate/asciikit 0.1.2 → 0.3.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/LICENSE CHANGED
@@ -1,24 +1,24 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 sia!
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
22
-
23
- FIGlet and TOIlet fonts included in dist/fonts are the work of their respective
24
- authors and are distributed under their original terms.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 sia!
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
23
+ FIGlet and TOIlet fonts included in dist/fonts are the work of their respective
24
+ authors and are distributed under their original terms.
package/README.md CHANGED
@@ -1,122 +1,219 @@
1
- # asciikit
2
-
3
- [![npm](https://img.shields.io/npm/v/@iwascreatedtocreate/asciikit?color=black)](https://www.npmjs.com/package/@iwascreatedtocreate/asciikit)
4
- [![downloads](https://img.shields.io/npm/dm/@iwascreatedtocreate/asciikit?color=black)](https://www.npmjs.com/package/@iwascreatedtocreate/asciikit)
5
- [![ci](https://github.com/iwascreatedtocreate/asciikit/actions/workflows/ci.yml/badge.svg)](https://github.com/iwascreatedtocreate/asciikit/actions/workflows/ci.yml)
6
-
7
- ASCII art for React & Next.js. **332 FIGlet fonts you import like icons**, a full FIGfont smushing engine, borders, shadows, gradients, animations and image-to-ASCII.
8
-
9
- ```bash
10
- npm i @iwascreatedtocreate/asciikit
11
- ```
12
-
13
- ```tsx
14
- import { Ascii } from '@iwascreatedtocreate/asciikit/react';
15
- import { Slant } from '@iwascreatedtocreate/asciikit/fonts';
16
-
17
- export default function Page() {
18
- return <Ascii text="Hello" font={Slant} border="rounded" />;
19
- }
20
- ```
21
-
22
- Live playground & font gallery: **https://asciikit.iwascreatedtocreate.com**
23
-
24
- ## Why
25
-
26
- - **Import fonts like icons** — `import { Slant, Doom, AnsiShadow } from '@iwascreatedtocreate/asciikit/fonts'`. Every font is its own module, so you only ship what you use.
27
- - **Server Components first** — `<Ascii>` renders on the server with zero client JS. When you animate, only the final string goes to the browser, never the font.
28
- - **A real FIGlet engine** — full width, fitting, all 6 horizontal + 5 vertical smushing rules, universal smushing, word wrap, alignment, RTL, FIGlet & TOIlet (`.flf` / `.tlf`) fonts. Output matches figlet.js / TAAG for 97%+ of fonts.
29
- - **Effects** — borders (15 styles), shadow, fill, flip, rotate, scale, invert, join/stack/overlay, gradients, ANSI colors for terminals.
30
- - **Animations** — scramble, typewriter, reveal, fall, flicker, glitch, wave, rain. Respects `prefers-reduced-motion`.
31
- - **Image → ASCII** — ramps, braille, edge tracing, Floyd–Steinberg / Atkinson / ordered dithering, color.
32
- - **Framework-free core** — everything works in Node, Bun, Deno, edge runtimes and CLIs.
33
- - **Export** — `toSVG()` anywhere (OG images, READMEs), `toPNG()` / `toCanvas()` in the browser.
34
- - **CLI** — `npx @iwascreatedtocreate/asciikit "hello" -f slant -g sunset`.
35
- - **Wide characters** — emoji and CJK count as two columns, so borders and alignment stay straight.
36
- - **Zero dependencies.**
37
-
38
- ## CLI
39
-
40
- ```bash
41
- npx @iwascreatedtocreate/asciikit "deploy ok" -f slant -g sunset -b rounded
42
- echo "piped" | npx @iwascreatedtocreate/asciikit -f small
43
- npx @iwascreatedtocreate/asciikit --list --preview Hi # every font
44
- npx @iwascreatedtocreate/asciikit logo --svg logo.svg # also write an SVG
45
- ```
46
-
47
- Run `--help` for all options (fonts, width, align, layout, border, shadow, fill, gradient, color).
48
-
49
- ## Export
50
-
51
- ```ts
52
- import { ascii, toSVG, toPNG, downloadFile } from '@iwascreatedtocreate/asciikit';
53
-
54
- const art = ascii('Hello', { font: Slant });
55
- const svg = toSVG(art, { gradient: 'silver', background: '#000', fontSize: 20 }); // string, works on the server
56
- const png = await toPNG(art, { color: '#fff', background: '#000' }); // Blob, browser only
57
- downloadFile('hello.png', png);
58
- ```
59
-
60
- ## React
61
-
62
- ```tsx
63
- import { Ascii, AsciiImage, AsciiSpinner, AsciiBox, createAscii, useFont } from '@iwascreatedtocreate/asciikit/react';
64
-
65
- <Ascii text="Hello" /> // Standard built in
66
- <Ascii text="Hello" font={Slant} gradient="silver" glow />
67
- <Ascii text="Hi" font={Slant} border={{ style: 'double', title: 'v1' }} shadow />
68
- <Ascii text="Boot" font={AnsiShadow} animate={{ effect: 'scramble', trigger: 'visible' }} />
69
- <AsciiImage src="/me.jpg" columns={100} mode="braille" dither="atkinson" />
70
- <AsciiSpinner spinner="dots" text="loading" />
71
- <AsciiBox variant="rounded" title="note">{'multi\nline'}</AsciiBox>
72
-
73
- export const Logo = createAscii('ACME', { font: Slant }); // lucide-style factory
74
- const { font } = useFont('ansi-shadow'); // code-split loading
75
- ```
76
-
77
- ### `<Ascii>` props
78
-
79
- | prop | type |
80
- | --- | --- |
81
- | `text` / `children` | `string` |
82
- | `font` | `FontDefinition \| string` (registered name or raw `.flf`) |
83
- | `horizontalLayout`, `verticalLayout` | `'default' \| 'full' \| 'fitted' \| 'smush' \| 'universal-smush'` |
84
- | `horizontalRules`, `verticalRules` | toggle individual smushing rules |
85
- | `width`, `whitespaceBreak`, `align` | wrapping & alignment |
86
- | `letterSpacing`, `wordSpacing`, `lineGap`, `direction`, `trim` | spacing & direction |
87
- | `fill`, `replace`, `flip`, `rotate`, `scale`, `invert`, `shadow`, `border`, `padding`, `transform` | effects |
88
- | `color`, `gradient`, `gradientDirection`, `size`, `lineHeight`, `glow`, `fontFamily` | styling |
89
- | `animate` | effect name or `{ effect, duration, delay, loop, loopDelay, trigger, intensity, noise }` |
90
- | `as`, `label` | element & accessible label |
91
-
92
- ## Core
93
-
94
- ```ts
95
- import { render, ascii, pipe, box, shadow, fill, join, toAnsi, pixelsToAscii } from '@iwascreatedtocreate/asciikit';
96
- import { Standard } from '@iwascreatedtocreate/asciikit/fonts';
97
-
98
- render('Hello', { font: Standard, width: 60, align: 'center' });
99
- ascii('OK', { font: Standard, fill: '█', shadow: true, border: 'rounded' });
100
- console.log(toAnsi(render('deploy'), { gradient: 'sunset' }));
101
- ```
102
-
103
- ## Fonts
104
-
105
- ```ts
106
- import { Slant } from '@iwascreatedtocreate/asciikit/fonts'; // barrel (tree-shaken)
107
- import Ghost from '@iwascreatedtocreate/asciikit/fonts/ghost'; // direct path
108
- import { loadFont } from '@iwascreatedtocreate/asciikit/fonts/lazy'; // async by id or name
109
- import { fontList } from '@iwascreatedtocreate/asciikit/fonts/meta'; // metadata only
110
- import { parseFont, registerFont, setDefaultFont } from '@iwascreatedtocreate/asciikit';
111
- ```
112
-
113
- Tip for Next.js dev speed when importing many fonts from the barrel:
114
-
115
- ```js
116
- // next.config.js
117
- experimental: { optimizePackageImports: ['@iwascreatedtocreate/asciikit'] }
118
- ```
119
-
120
- ## License
121
-
122
- MIT. FIGlet/TOIlet fonts are © their respective authors and distributed under their original terms (bundled via the [figlet](https://github.com/patorjk/figlet.js) font collection).
1
+ # asciikit
2
+
3
+ [![npm](https://img.shields.io/npm/v/@iwascreatedtocreate/asciikit?color=black)](https://www.npmjs.com/package/@iwascreatedtocreate/asciikit)
4
+ [![downloads](https://img.shields.io/npm/dm/@iwascreatedtocreate/asciikit?color=black)](https://www.npmjs.com/package/@iwascreatedtocreate/asciikit)
5
+ [![ci](https://github.com/iwascreatedtocreate/asciikit/actions/workflows/ci.yml/badge.svg)](https://github.com/iwascreatedtocreate/asciikit/actions/workflows/ci.yml)
6
+
7
+ ASCII art for React & Next.js. **332 FIGlet fonts you import like icons**, a full FIGfont smushing engine, borders, shadows, gradients, animations and image-to-ASCII.
8
+
9
+ ```bash
10
+ npm i @iwascreatedtocreate/asciikit
11
+ ```
12
+
13
+ ```tsx
14
+ import { Ascii } from '@iwascreatedtocreate/asciikit/react';
15
+ import { Slant } from '@iwascreatedtocreate/asciikit/fonts';
16
+
17
+ export default function Page() {
18
+ return <Ascii text="Hello" font={Slant} border="rounded" />;
19
+ }
20
+ ```
21
+
22
+ Live playground & font gallery: **https://asciikit.iwascreatedtocreate.com**
23
+
24
+ ## Why
25
+
26
+ - **Import fonts like icons** — `import { Slant, Doom, AnsiShadow } from '@iwascreatedtocreate/asciikit/fonts'`. Every font is its own module, so you only ship what you use.
27
+ - **Server Components first** — `<Ascii>` renders on the server with zero client JS. When you animate, only the final string goes to the browser, never the font.
28
+ - **A real FIGlet engine** — full width, fitting, all 6 horizontal + 5 vertical smushing rules, universal smushing, word wrap, alignment, RTL, FIGlet & TOIlet (`.flf` / `.tlf`) fonts. Output matches figlet.js / TAAG for 97%+ of fonts.
29
+ - **Effects** — borders (15 styles), shadow, fill, flip, rotate, scale, invert, join/stack/overlay, gradients, ANSI colors for terminals.
30
+ - **Animations** — scramble, typewriter, reveal, fade, slide, fall, flicker, glitch, wave, rain, marquee, sparkle. Respects `prefers-reduced-motion`.
31
+ - **Text widgets** — tables (9 styles, markdown too), trees, dividers, speech bubbles with little critters.
32
+ - **Charts** — sparklines, bar charts (horizontal / vertical, smooth eighth-blocks), braille line charts, progress bars.
33
+ - **Drawing canvas** — lines, boxes that merge into proper `┼ ├ ┬` junctions, circles, text; plus a braille pixel canvas with 8× resolution.
34
+ - **Fancy Unicode text** — 𝐛𝐨𝐥𝐝, 𝔣𝔯𝔞𝔨𝔱𝔲𝔯, 𝓈𝒸𝓇𝒾𝓅𝓉, ⓒⓘⓡⓒⓛⓔⓓ, ꜱᴍᴀʟʟ ᴄᴀᴘꜱ, uʍop ǝpısdn and 20 more styles.
35
+ - **Image → ASCII** — ramps, braille, edge tracing, Floyd–Steinberg / Atkinson / ordered dithering, color.
36
+ - **Framework-free core** — everything works in Node, Bun, Deno, edge runtimes and CLIs, plus an `<ascii-text>` custom element for Vue, Svelte, Astro and plain HTML.
37
+ - **Export** — `toSVG()` anywhere (OG images, READMEs), `toPNG()` / `toCanvas()` in the browser.
38
+ - **CLI** — `npx @iwascreatedtocreate/asciikit "hello" -f slant -g sunset`.
39
+ - **Wide characters** — emoji and CJK count as two columns, so borders and alignment stay straight.
40
+ - **Zero dependencies.**
41
+
42
+ ## CLI
43
+
44
+ ```bash
45
+ npx @iwascreatedtocreate/asciikit "deploy ok" -f slant -g sunset -b rounded
46
+ echo "piped" | npx @iwascreatedtocreate/asciikit -f small
47
+ npx @iwascreatedtocreate/asciikit --list --preview Hi # every font
48
+ npx @iwascreatedtocreate/asciikit logo --svg logo.svg # also write an SVG
49
+ npx @iwascreatedtocreate/asciikit "ship it" --say robot # speech bubble
50
+ npx @iwascreatedtocreate/asciikit hello --fancy fraktur # 𝔥𝔢𝔩𝔩𝔬
51
+ ```
52
+
53
+ Run `--help` for all options (fonts, width, align, layout, border, shadow, fill, gradient, color).
54
+
55
+ ## Export
56
+
57
+ ```ts
58
+ import { ascii, toSVG, toPNG, downloadFile } from '@iwascreatedtocreate/asciikit';
59
+
60
+ const art = ascii('Hello', { font: Slant });
61
+ const svg = toSVG(art, { gradient: 'silver', background: '#000', fontSize: 20 }); // string, works on the server
62
+ const png = await toPNG(art, { color: '#fff', background: '#000' }); // Blob, browser only
63
+ downloadFile('hello.png', png);
64
+ ```
65
+
66
+ ## Any framework: `<ascii-text>`
67
+
68
+ A custom element for plain HTML, Vue, Svelte, Astro, Angular and anything else that renders HTML. No build step needed:
69
+
70
+ ```html
71
+ <script type="module" src="https://cdn.jsdelivr.net/npm/@iwascreatedtocreate/asciikit/dist/element.js"></script>
72
+
73
+ <ascii-text font="slant" gradient="sunset" border="rounded">hello</ascii-text>
74
+ <ascii-text font="ANSI Shadow" color="#7cf" glow size="10" animate="scramble">boot</ascii-text>
75
+ ```
76
+
77
+ In a bundled app, `import '@iwascreatedtocreate/asciikit/element'` defines the tag. Fonts load on demand, one chunk each. Attributes: `font`, `text` (or the tag's content), `gradient` (preset or `#f00,#00f`), `direction`, `color`, `glow`, `size`, `line-height`, `border`, `border-title`, `shadow`, `fill`, `align`, `width`, `letter-spacing`, `layout`, `animate`, `duration`, `loop`, `trigger` (`mount` / `hover` / `visible`) and `label`. Changing an attribute or the text re-renders it. Style the inner `<pre>` with `ascii-text::part(art)`.
78
+
79
+ ## README banners
80
+
81
+ An SVG for GitHub READMEs, rendered on request. No install needed:
82
+
83
+ ```md
84
+ ![hello](https://asciikit.iwascreatedtocreate.com/api/banner?text=hello&font=slant&gradient=sunset)
85
+ ```
86
+
87
+ Query options: `text`, `font`, `gradient`, `color`, `dir`, `bg` (default transparent), `size`, `border`, `shadow`, `fill`, `align`. There's a banner maker on [the site](https://asciikit.iwascreatedtocreate.com/#banner).
88
+
89
+ ## Tables, trees and bubbles
90
+
91
+ ```ts
92
+ import { table, tree, divider, say, fancy } from '@iwascreatedtocreate/asciikit';
93
+
94
+ table([['asciikit', '332 fonts'], ['日本語', 'wide chars line up']], { head: ['name', 'notes'], style: 'rounded' });
95
+ // ╭──────────┬────────────────────╮
96
+ // │ name │ notes │
97
+ // ├──────────┼────────────────────┤
98
+ // │ asciikit │ 332 fonts │
99
+ // │ 日本語 │ wide chars line up │
100
+ // ╰──────────┴────────────────────╯
101
+
102
+ tree({ app: { src: ['index.ts', 'cli.ts'], 'package.json': null } });
103
+ // app
104
+ // ├── src
105
+ // │ ├── index.ts
106
+ // │ └── cli.ts
107
+ // └── package.json
108
+
109
+ divider('Section'); // ────────── Section ──────────
110
+ say('ship it', 'robot'); // bubble + robot (cat, robot, ghost, blob, bird, computer, or your own art)
111
+ fancy('hello', 'fraktur'); // 𝔥𝔢𝔩𝔩𝔬 (bold, script, doubleStruck, circled, smallCaps, upsideDown, strike…)
112
+ ```
113
+
114
+ Tables take `align`, `maxWidth` (cells wrap or `truncate`), `rowSeparators`, `title`, `padding` and the styles `single`, `double`, `rounded`, `heavy`, `dashed`, `ascii`, `minimal`, `markdown`, `none`. Cells can be multi-line, even ASCII art.
115
+
116
+ ## Charts
117
+
118
+ ```ts
119
+ import { sparkline, barChart, lineChart, progressBar } from '@iwascreatedtocreate/asciikit';
120
+
121
+ sparkline([1, 5, 2, 8, 3, 7]); // ▁▅▂█▃▇
122
+ barChart({ react: 92, vue: 61, svelte: 40 }, { width: 30 });
123
+ // react │██████████████████████████████ 92
124
+ // vue │███████████████████▉ 61
125
+ // svelte │█████████████ 40
126
+ barChart(data, { direction: 'vertical', height: 8 });
127
+ lineChart([3, 7, 4, 9, 12, 8, 15], { width: 40, height: 8 }); // braille dots, several series allowed
128
+ progressBar(0.42, { style: 'ascii' }); // [============> ] 42%
129
+ ```
130
+
131
+ ## Drawing canvas
132
+
133
+ ```ts
134
+ import { AsciiCanvas, BrailleCanvas } from '@iwascreatedtocreate/asciikit';
135
+
136
+ const c = new AsciiCanvas(32, 5);
137
+ c.rect(0, 0, 14, 5, { title: 'api' }).rect(18, 0, 14, 5, { title: 'db' }).line(13, 2, 18, 2);
138
+ c.toString();
139
+ // ┌─ api ──────┐ ┌─ db ───────┐
140
+ // │ │ │ │
141
+ // │ ├────┤ │
142
+ // │ │ │ │
143
+ // └────────────┘ └────────────┘
144
+
145
+ const b = new BrailleCanvas(40, 10); // 80×40 dots
146
+ b.circle(40, 20, 18).plot(Math.sin, { xMin: 0, xMax: 6.28, yMin: -1, yMax: 1 });
147
+ ```
148
+
149
+ `AsciiCanvas` also has `set`, `text`, `circle` (aspect-corrected), `draw(art, x, y)` and `clear`. Lines pick `─ │ / \` from their slope.
150
+
151
+ ## React
152
+
153
+ ```tsx
154
+ import { Ascii, AsciiImage, AsciiSpinner, AsciiBox, AsciiTable, AsciiTree, AsciiChart, AsciiProgress, AsciiArt, createAscii, useFont } from '@iwascreatedtocreate/asciikit/react';
155
+
156
+ <Ascii text="Hello" /> // Standard built in
157
+ <Ascii text="Hello" font={Slant} gradient="silver" glow />
158
+ <Ascii text="Hi" font={Slant} border={{ style: 'double', title: 'v1' }} shadow />
159
+ <Ascii text="Boot" font={AnsiShadow} animate={{ effect: 'scramble', trigger: 'visible' }} />
160
+ <AsciiImage src="/me.jpg" columns={100} mode="braille" dither="atkinson" />
161
+ <AsciiSpinner spinner="dots" text="loading" />
162
+ <AsciiBox variant="rounded" title="note">{'multi\nline'}</AsciiBox>
163
+ <AsciiTable rows={[['a', 1]]} head={['k', 'v']} variant="rounded" />
164
+ <AsciiTree data={{ src: ['index.ts'] }} />
165
+ <AsciiChart type="bar" data={{ react: 92, vue: 61 }} width={30} gradient="sunset" />
166
+ <AsciiChart type="line" data={[3, 7, 4, 9]} height={6} />
167
+ <AsciiProgress value={0.42} variant="blocks" text="build" />
168
+ <AsciiArt art={canvas.toString()} glow /> // any pre-made art string
169
+
170
+ export const Logo = createAscii('ACME', { font: Slant }); // lucide-style factory
171
+ const { font } = useFont('ansi-shadow'); // code-split loading
172
+ ```
173
+
174
+ ### `<Ascii>` props
175
+
176
+ | prop | type |
177
+ | --- | --- |
178
+ | `text` / `children` | `string` |
179
+ | `font` | `FontDefinition \| string` (registered name or raw `.flf`) |
180
+ | `horizontalLayout`, `verticalLayout` | `'default' \| 'full' \| 'fitted' \| 'smush' \| 'universal-smush'` |
181
+ | `horizontalRules`, `verticalRules` | toggle individual smushing rules |
182
+ | `width`, `whitespaceBreak`, `align` | wrapping & alignment |
183
+ | `letterSpacing`, `wordSpacing`, `lineGap`, `direction`, `trim` | spacing & direction |
184
+ | `fill`, `replace`, `flip`, `rotate`, `scale`, `invert`, `shadow`, `border`, `padding`, `transform` | effects |
185
+ | `color`, `gradient`, `gradientDirection`, `size`, `lineHeight`, `glow`, `fontFamily` | styling |
186
+ | `animate` | effect name or `{ effect, duration, delay, loop, loopDelay, trigger, intensity, noise }` |
187
+ | `as`, `label` | element & accessible label |
188
+
189
+ ## Core
190
+
191
+ ```ts
192
+ import { render, ascii, pipe, box, shadow, fill, join, toAnsi, pixelsToAscii } from '@iwascreatedtocreate/asciikit';
193
+ import { Standard } from '@iwascreatedtocreate/asciikit/fonts';
194
+
195
+ render('Hello', { font: Standard, width: 60, align: 'center' });
196
+ ascii('OK', { font: Standard, fill: '█', shadow: true, border: 'rounded' });
197
+ console.log(toAnsi(render('deploy'), { gradient: 'sunset' }));
198
+ ```
199
+
200
+ ## Fonts
201
+
202
+ ```ts
203
+ import { Slant } from '@iwascreatedtocreate/asciikit/fonts'; // barrel (tree-shaken)
204
+ import Ghost from '@iwascreatedtocreate/asciikit/fonts/ghost'; // direct path
205
+ import { loadFont } from '@iwascreatedtocreate/asciikit/fonts/lazy'; // async by id or name
206
+ import { fontList } from '@iwascreatedtocreate/asciikit/fonts/meta'; // metadata only
207
+ import { parseFont, registerFont, setDefaultFont } from '@iwascreatedtocreate/asciikit';
208
+ ```
209
+
210
+ Tip for Next.js dev speed when importing many fonts from the barrel:
211
+
212
+ ```js
213
+ // next.config.js
214
+ experimental: { optimizePackageImports: ['@iwascreatedtocreate/asciikit'] }
215
+ ```
216
+
217
+ ## License
218
+
219
+ MIT. FIGlet/TOIlet fonts are © their respective authors and distributed under their original terms (bundled via the [figlet](https://github.com/patorjk/figlet.js) font collection).
package/dist/animate.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { type Art } from './effects.js';
2
- export type AnimationEffect = 'typewriter' | 'reveal' | 'scramble' | 'glitch' | 'wave' | 'fall' | 'flicker' | 'rain';
2
+ export type AnimationEffect = 'typewriter' | 'reveal' | 'scramble' | 'glitch' | 'wave' | 'fall' | 'flicker' | 'rain' | 'fade' | 'slide' | 'marquee' | 'sparkle';
3
3
  /** Effects that run forever by default (time based rather than progress based). */
4
4
  export declare const continuousEffects: readonly AnimationEffect[];
5
5
  export interface FrameOptions {
package/dist/animate.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { normalize, toLines } from './effects.js';
2
2
  import { cells, fixCells } from './width.js';
3
3
  /** Effects that run forever by default (time based rather than progress based). */
4
- export const continuousEffects = ['glitch', 'wave', 'rain'];
4
+ export const continuousEffects = ['glitch', 'wave', 'rain', 'marquee', 'sparkle'];
5
5
  const DEFAULT_NOISE = '!<>-_\\/[]{}—=+*^?#________';
6
6
  function hash(a, b, c) {
7
7
  let h = (a * 374761393 + b * 668265263 + c * 2147483647) | 0;
@@ -96,6 +96,43 @@ export function animationFrame(art, effect, progress, options = {}) {
96
96
  return ch;
97
97
  });
98
98
  }
99
+ case 'fade': {
100
+ // each char climbs a density ramp before landing on its final glyph
101
+ const ramp = [' ', '.', ':', '-', '=', '+', '*', '#'];
102
+ return map((ch, r, c) => {
103
+ if (ch === ' ')
104
+ return ch;
105
+ const local = (p - rnd(r, c, 2) * 0.5) / 0.5;
106
+ if (local >= 1)
107
+ return ch;
108
+ if (local <= 0)
109
+ return ' ';
110
+ return ramp[Math.min(ramp.length - 1, Math.floor(local * ramp.length))];
111
+ });
112
+ }
113
+ case 'slide': {
114
+ // rows arrive from the left one after another
115
+ return map((_ch, r, c) => {
116
+ const local = ease((p - (r / Math.max(1, h)) * 0.3) / 0.7);
117
+ const off = Math.round((1 - local) * w);
118
+ return grid[r][c - off] ?? ' ';
119
+ });
120
+ }
121
+ case 'marquee': {
122
+ const gap = Math.max(4, Math.round(w * 0.3));
123
+ const span = w + gap;
124
+ const off = Math.floor(time / (90 - intensity * 70)) % span;
125
+ return map((_ch, r, c) => grid[r][(c + off) % span] ?? ' ');
126
+ }
127
+ case 'sparkle': {
128
+ const stars = ['*', '+', '·', '.'];
129
+ return map((ch, r, c) => {
130
+ if (ch === ' ')
131
+ return ch;
132
+ const t = rnd(r, c, tick);
133
+ return t < intensity * 0.06 ? stars[Math.floor(t * 1000) % stars.length] : ch;
134
+ });
135
+ }
99
136
  default:
100
137
  return map((ch) => ch);
101
138
  }
@@ -0,0 +1,101 @@
1
+ import { type Art, type BoxChars, type BoxStyle } from './effects.js';
2
+ export interface RectOptions {
3
+ /** Border style (default `single`). Single/rounded borders merge where they cross. */
4
+ style?: BoxStyle | BoxChars;
5
+ /** Fill the inside with this character. */
6
+ fill?: string;
7
+ /** Title written into the top edge. */
8
+ title?: string;
9
+ }
10
+ /**
11
+ * A fixed-size character grid you can draw on: text, lines, boxes, circles and other art.
12
+ * Light box lines that touch merge into proper junctions (┼ ├ ┬ …).
13
+ *
14
+ * ```ts
15
+ * const c = new AsciiCanvas(30, 8);
16
+ * c.rect(0, 0, 14, 5, { title: 'api' }).rect(16, 0, 14, 5, { title: 'db' }).line(14, 2, 16, 2, '─');
17
+ * c.toString();
18
+ * ```
19
+ */
20
+ export declare class AsciiCanvas {
21
+ readonly width: number;
22
+ readonly height: number;
23
+ private grid;
24
+ constructor(width: number, height: number, background?: string);
25
+ /** Read the character at a cell ('' for the right half of a wide char). */
26
+ get(x: number, y: number): string | undefined;
27
+ /** Put one character. Light box chars merge with what's already there unless `merge` is false. */
28
+ set(x: number, y: number, ch: string, merge?: boolean): this;
29
+ /** Write a string starting at (x, y). Newlines start a new row at the same x. */
30
+ text(x: number, y: number, str: string): this;
31
+ /**
32
+ * Draw a straight line (Bresenham). Without `ch` the character follows the slope:
33
+ * `─ │` for straight lines and `/ \` for diagonals.
34
+ */
35
+ line(x0: number, y0: number, x1: number, y1: number, ch?: string): this;
36
+ /** Draw a box. Width and height include the border. */
37
+ rect(x: number, y: number, w: number, h: number, options?: RectOptions): this;
38
+ /**
39
+ * Draw an ellipse outline (or a filled one with `fill`). `ry` defaults to half of `rx`
40
+ * because character cells are about twice as tall as they are wide.
41
+ */
42
+ circle(cx: number, cy: number, rx: number, options?: {
43
+ ry?: number;
44
+ char?: string;
45
+ fill?: string;
46
+ }): this;
47
+ /** Paste art at (x, y). Spaces are transparent unless `opaque` is set. */
48
+ draw(art: Art, x: number, y: number, options?: {
49
+ opaque?: boolean;
50
+ }): this;
51
+ /** Fill every cell with `ch`. */
52
+ clear(ch?: string): this;
53
+ /** The drawing as a string. Trailing spaces are removed unless `keepSpaces` is set. */
54
+ toString(options?: {
55
+ keepSpaces?: boolean;
56
+ }): string;
57
+ }
58
+ /**
59
+ * A pixel canvas drawn with braille characters (2×4 dots per character). Great for
60
+ * plots, curves and small drawings.
61
+ *
62
+ * ```ts
63
+ * const b = new BrailleCanvas(40, 10); // 80×40 dots
64
+ * b.circle(40, 20, 18).line(0, 39, 79, 0);
65
+ * b.toString();
66
+ * ```
67
+ */
68
+ export declare class BrailleCanvas {
69
+ /** Size in characters. */
70
+ readonly columns: number;
71
+ readonly rows: number;
72
+ /** Size in dots. */
73
+ readonly width: number;
74
+ readonly height: number;
75
+ private bits;
76
+ constructor(columns: number, rows: number);
77
+ private at;
78
+ set(x: number, y: number): this;
79
+ unset(x: number, y: number): this;
80
+ toggle(x: number, y: number): this;
81
+ get(x: number, y: number): boolean;
82
+ line(x0: number, y0: number, x1: number, y1: number): this;
83
+ rect(x: number, y: number, w: number, h: number, fill?: boolean): this;
84
+ /** Circle (dots are square-ish, so no aspect correction needed). `ry` makes an ellipse. */
85
+ circle(cx: number, cy: number, r: number, options?: {
86
+ ry?: number;
87
+ fill?: boolean;
88
+ }): this;
89
+ /** Plot y = fn(x) across the canvas. `fn` gets x in [xMin, xMax] and returns y in [yMin, yMax]. */
90
+ plot(fn: (x: number) => number, range?: {
91
+ xMin?: number;
92
+ xMax?: number;
93
+ yMin?: number;
94
+ yMax?: number;
95
+ }): this;
96
+ clear(): this;
97
+ /** Empty cells become spaces unless `blank` is set (U+2800 keeps width in some fonts). */
98
+ toString(options?: {
99
+ blank?: boolean;
100
+ }): string;
101
+ }