asciify-engine 1.0.36 → 1.0.37

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.
Files changed (2) hide show
  1. package/README.md +47 -5
  2. 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
- - **10 animated backgrounds** — Wave, Rain, Stars, Pulse, Noise, Grid, Aurora, Silk, Void, Morph
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 stop = asciiBackground('#hero', { type: 'stars' });
176
- stop();
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>` | Convert an image/video/canvas (or URL) to ASCII and render handles loading automatically |
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
- | `asciiBackground(selector, options)` | `() => void` | Mount a live animated ASCII background; returns a cleanup function |
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "asciify-engine",
3
- "version": "1.0.36",
3
+ "version": "1.0.37",
4
4
  "description": "Framework-agnostic ASCII art engine. Convert images, videos, and GIFs into ASCII art rendered on canvas.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",