asciify-engine 1.0.36 → 1.0.38
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 +47 -5
- package/dist/index.cjs +17 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.js +17 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
- **Media → ASCII** — images, videos, and animated GIFs
|
|
17
17
|
- **13 art styles** — Standard, Blocks, Circles, Braille, Katakana, Dense, and more
|
|
18
18
|
- **4 color modes** — Grayscale, Full Color, Matrix, Accent
|
|
19
|
-
- **
|
|
19
|
+
- **14 animated backgrounds** — Wave, Rain, Stars, Pulse, Noise, Grid, Aurora, Silk, Void, Morph, Fire, DNA, Terrain, Circuit
|
|
20
20
|
- **Interactive hover effects** — Spotlight, Flashlight, Magnifier, Force Field, Neon, Fire, Ice, Gravity, Shatter, Ghost
|
|
21
21
|
- **Light & dark mode** — via `colorScheme: 'auto'` or explicit `light` / `dark`
|
|
22
22
|
- **Embed generation** — self-contained HTML output (static or animated)
|
|
@@ -56,6 +56,25 @@ await asciify('photo.jpg', canvas, {
|
|
|
56
56
|
});
|
|
57
57
|
```
|
|
58
58
|
|
|
59
|
+
> **Canvas sizing:** Set `width` and `height` as HTML attributes on the `<canvas>` element — these control the pixel grid. CSS sizing alone (`style="width:100%"`) won't work (the canvas will be 0×0). Use `canvas.width = el.clientWidth` to fill a container.
|
|
60
|
+
|
|
61
|
+
### Webcam → ASCII
|
|
62
|
+
|
|
63
|
+
```ts
|
|
64
|
+
import { asciifyWebcam } from 'asciify-engine';
|
|
65
|
+
|
|
66
|
+
const canvas = document.querySelector('canvas')!;
|
|
67
|
+
|
|
68
|
+
// Requests camera access, starts a live rAF loop, returns stop()
|
|
69
|
+
const stop = await asciifyWebcam(canvas, {
|
|
70
|
+
artStyle: 'terminal',
|
|
71
|
+
mirror: true, // horizontal flip (selfie mode)
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
// Release camera + cancel loop
|
|
75
|
+
stop();
|
|
76
|
+
```
|
|
77
|
+
|
|
59
78
|
### GIF Animation
|
|
60
79
|
|
|
61
80
|
```ts
|
|
@@ -172,8 +191,8 @@ asciiBackground('#hero', { type: 'aurora', colorScheme: 'auto' });
|
|
|
172
191
|
asciiBackground('#hero', { type: 'wave', colorScheme: 'light' });
|
|
173
192
|
|
|
174
193
|
// Stop / clean up
|
|
175
|
-
const
|
|
176
|
-
|
|
194
|
+
const { destroy } = asciiBackground('#hero', { type: 'stars' });
|
|
195
|
+
destroy();
|
|
177
196
|
```
|
|
178
197
|
|
|
179
198
|
### Background Types
|
|
@@ -190,6 +209,10 @@ stop();
|
|
|
190
209
|
| `silk` | Silky fluid swirls following the cursor |
|
|
191
210
|
| `void` | Gravitational singularity — characters spiral inward toward cursor |
|
|
192
211
|
| `morph` | Characters morph between shapes driven by noise |
|
|
212
|
+
| `fire` | Upward-drifting flame columns with heat-gradient character mapping |
|
|
213
|
+
| `dna` | Rotating double-helix strands with base-pair characters |
|
|
214
|
+
| `terrain` | Procedural heightmap landscape with parallax depth layers |
|
|
215
|
+
| `circuit` | PCB trace network that pulses with traveling electric signals |
|
|
193
216
|
|
|
194
217
|
### `asciiBackground` Options
|
|
195
218
|
|
|
@@ -324,14 +347,15 @@ animId = requestAnimationFrame(tick);
|
|
|
324
347
|
|
|
325
348
|
| Function | Returns | Description |
|
|
326
349
|
|---|---|---|
|
|
327
|
-
| `asciify(source, canvas, opts?)` | `Promise<void>` |
|
|
350
|
+
| `asciify(source, canvas, opts?)` | `Promise<void>` | Render a **single** ASCII frame from an image (or URL). For animated loops use `asciifyGif` / `asciifyVideo` |
|
|
328
351
|
| `asciifyGif(source, canvas, opts?)` | `Promise<() => void>` | Fetch a GIF, convert, and start an animation loop — returns `stop()` |
|
|
329
352
|
| `asciifyVideo(source, canvas, opts?)` | `Promise<() => void>` | Convert a video and start an animation loop — returns `stop()` |
|
|
330
353
|
| `imageToAsciiFrame(source, options, w?, h?)` | `{ frame, cols, rows }` | Convert an image, video frame, or canvas to a raw ASCII frame |
|
|
331
354
|
| `renderFrameToCanvas(ctx, frame, options, w, h, time?, hoverPos?)` | `void` | Render a raw ASCII frame to a 2D canvas context |
|
|
332
355
|
| `gifToAsciiFrames(buffer, options, w, h, onProgress?)` | `{ frames, cols, rows, fps }` | Parse an animated GIF `ArrayBuffer` into ASCII frames |
|
|
333
356
|
| `videoToAsciiFrames(video, options, w, h, fps?, maxDuration?, onProgress?)` | `{ frames, cols, rows, fps }` | Extract and convert video frames to ASCII |
|
|
334
|
-
| `
|
|
357
|
+
| `asciifyWebcam(canvas, opts?)` | `Promise<() => void>` | Start a live webcam → ASCII loop; returns `stop()` to cancel and release the camera |
|
|
358
|
+
| `asciiBackground(target, options)` | `{ destroy: () => void }` | Mount a live animated ASCII background; call `destroy()` to stop and remove |
|
|
335
359
|
| `generateEmbedCode(frame, options)` | `string` | Self-contained static HTML embed |
|
|
336
360
|
| `generateAnimatedEmbedCode(frames, options, fps)` | `string` | Self-contained animated HTML embed |
|
|
337
361
|
|
|
@@ -364,6 +388,24 @@ Used by `asciify()`, `asciifyGif()`, and `asciifyVideo()`:
|
|
|
364
388
|
| `ditherStrength` | `number` | `0` | Floyd-Steinberg dither intensity (0–1) |
|
|
365
389
|
| `dotSizeRatio` | `number` | `0.8` | Dot size when `renderMode === 'dots'` (fraction of cell) |
|
|
366
390
|
|
|
391
|
+
### Art Styles (`artStyle`)
|
|
392
|
+
|
|
393
|
+
| Value | Color mode | Description |
|
|
394
|
+
|---|---|---|
|
|
395
|
+
| `classic` | Grayscale | Standard density ramp — clean, universally readable |
|
|
396
|
+
| `art` | Full color | 70-char dense ramp for maximum tonal detail |
|
|
397
|
+
| `particles` | Full color | Dot circles (`renderMode: 'dots'`) — great for photos |
|
|
398
|
+
| `letters` | Full color | Alphabet characters with pixel-accurate color |
|
|
399
|
+
| `terminal` | Matrix | Classic charset with green phosphor / Matrix look |
|
|
400
|
+
| `claudeCode` | Accent | Box-drawing chars with accent color — technical/hacker aesthetic |
|
|
401
|
+
| `braille` | Full color | 256-char braille block — ultra-dense, printed feel |
|
|
402
|
+
| `katakana` | Matrix | Half-width katakana — anime / cyberpunk aesthetic |
|
|
403
|
+
| `box` | Grayscale | Filled block elements `▪◾◼■█` |
|
|
404
|
+
| `lines` | Grayscale | Dash/em-dash ramp — minimalist typographic look |
|
|
405
|
+
| `circles` | Accent | Concentric circle chars with accent highlight |
|
|
406
|
+
| `musical` | Accent | Music notation ♩♪♫♬♭♮♯ — playful, low density |
|
|
407
|
+
| `emoji` | Full color | Block emoji mosaic — best at larger `fontSize` |
|
|
408
|
+
|
|
367
409
|
### Background Options
|
|
368
410
|
|
|
369
411
|
| Option | Type | Default | Description |
|
package/dist/index.cjs
CHANGED
|
@@ -2014,6 +2014,22 @@ function _parseColor(c) {
|
|
|
2014
2014
|
if (rgb) return { r: +rgb[1], g: +rgb[2], b: +rgb[3] };
|
|
2015
2015
|
return null;
|
|
2016
2016
|
}
|
|
2017
|
+
var BACKGROUND_TYPES = [
|
|
2018
|
+
"wave",
|
|
2019
|
+
"rain",
|
|
2020
|
+
"stars",
|
|
2021
|
+
"pulse",
|
|
2022
|
+
"noise",
|
|
2023
|
+
"grid",
|
|
2024
|
+
"aurora",
|
|
2025
|
+
"silk",
|
|
2026
|
+
"void",
|
|
2027
|
+
"morph",
|
|
2028
|
+
"fire",
|
|
2029
|
+
"dna",
|
|
2030
|
+
"terrain",
|
|
2031
|
+
"circuit"
|
|
2032
|
+
];
|
|
2017
2033
|
function asciiBackground(target, options = {}) {
|
|
2018
2034
|
const {
|
|
2019
2035
|
type = "wave",
|
|
@@ -2427,6 +2443,7 @@ async function asciifyWebcam(canvas, {
|
|
|
2427
2443
|
}
|
|
2428
2444
|
|
|
2429
2445
|
exports.ART_STYLE_PRESETS = ART_STYLE_PRESETS;
|
|
2446
|
+
exports.BACKGROUND_TYPES = BACKGROUND_TYPES;
|
|
2430
2447
|
exports.CHARSETS = CHARSETS;
|
|
2431
2448
|
exports.DEFAULT_OPTIONS = DEFAULT_OPTIONS;
|
|
2432
2449
|
exports.HOVER_PRESETS = HOVER_PRESETS;
|