asciify-engine 1.0.5 → 1.0.7

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/dist/index.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  type ColorMode = 'grayscale' | 'fullcolor' | 'matrix' | 'accent';
2
2
  type RenderMode = 'ascii' | 'dots';
3
- type AnimationStyle = 'none' | 'wave' | 'pulse' | 'rain' | 'breathe' | 'sparkle' | 'glitch' | 'spiral' | 'typewriter' | 'scatter';
3
+ type AnimationStyle = 'none' | 'wave' | 'pulse' | 'rain' | 'breathe' | 'sparkle' | 'glitch' | 'spiral' | 'typewriter' | 'scatter' | 'waveField';
4
4
  type ArtStyle = 'classic' | 'particles' | 'letters' | 'claudeCode' | 'art' | 'terminal' | 'box' | 'lines';
5
5
  type HoverEffect = 'spotlight' | 'magnify' | 'repel' | 'glow' | 'colorShift';
6
6
  type HoverPreset = 'none' | 'subtle' | 'flashlight' | 'magnifier' | 'forceField' | 'neon' | 'fire' | 'ice';
@@ -160,15 +160,87 @@ declare function asciifyGif(source: string | ArrayBuffer, canvas: HTMLCanvasElem
160
160
  */
161
161
  declare function asciifyVideo(source: HTMLVideoElement | string, canvas: HTMLCanvasElement, { fontSize, style, options }?: AsciifySimpleOptions): Promise<() => void>;
162
162
  /**
163
- * Generate a self-contained HTML embed snippet for an ASCII image.
164
- * Features: canvas rendering, animation loop, hover effects.
163
+ * Generate a professional 3-line embed snippet.
164
+ * The render runtime is loaded from jsDelivr CDN (free, served from npm).
165
+ * Only the base64-encoded frame data is inlined.
165
166
  */
166
167
  declare function generateEmbedCode(frame: AsciiFrame, options: AsciiOptions, width: number, height: number): string;
167
168
  /**
168
- * Generate animated embed code for multi-frame (video) ASCII art.
169
- * Canvas-based with frame cycling, animation effects, and hover.
169
+ * Generate an animated embed snippet for multi-frame (GIF/video) ASCII art.
170
+ * Uses the same CDN runtime as generateEmbedCode.
170
171
  */
171
172
  declare function generateAnimatedEmbedCode(frames: AsciiFrame[], options: AsciiOptions, fps: number, width: number, height: number): string;
173
+ interface WaveBackgroundOptions {
174
+ /** Font size in CSS pixels (default: 13) */
175
+ fontSize?: number;
176
+ /** Character aspect ratio width/height (default: 0.62) */
177
+ charAspect?: number;
178
+ /** Line height multiplier (default: 1.4) */
179
+ lineHeightRatio?: number;
180
+ /** Character set from dark→bright (default: ' .·:;=+*#%@░▒▓') */
181
+ chars?: string;
182
+ /** Base colour for low-intensity cells — use '{a}' as alpha placeholder (default: white) */
183
+ baseColor?: string;
184
+ /** Accent colour applied near the cursor and on wave peaks (default: '#d4ff00') */
185
+ accentColor?: string;
186
+ /** Accent threshold: normalised intensity above which accent kicks in (default: 0.52) */
187
+ accentThreshold?: number;
188
+ /** How strongly the mouse influences local intensity (default: 0.55) */
189
+ mouseInfluence?: number;
190
+ /** Radial falloff for mouse influence — higher = tighter spotlight (default: 2.8) */
191
+ mouseFalloff?: number;
192
+ /** Base wave animation speed (default: 1) */
193
+ speed?: number;
194
+ /** Enable vortex swirl effect around cursor (default: true) */
195
+ vortex?: boolean;
196
+ /** Enable sparkle / pop flicker layered on top (default: true) */
197
+ sparkles?: boolean;
198
+ /** Enable a slow global breathe pulse (default: true) */
199
+ breathe?: boolean;
200
+ /** Light mode: swap fill colours to dark-on-light (default: false) */
201
+ lightMode?: boolean;
202
+ }
203
+ /**
204
+ * Render a procedural interactive wave-field of ASCII characters.
205
+ *
206
+ * Layers stacked per cell:
207
+ * 1. Three cardinal sine waves (classic feel)
208
+ * 2. Fractal Brownian Motion noise (organic structure)
209
+ * 3. Diagonal drift ripple (depth / perspective)
210
+ * 4. Slow global breathe pulse (heartbeat)
211
+ * 5. Vortex swirl near cursor (energy field)
212
+ * 6. Proximity spotlight (cursor highlight)
213
+ * 7. Sparkle flickers on bright peaks (life)
214
+ *
215
+ * Call inside a requestAnimationFrame loop with accumulated time in seconds
216
+ * and the current normalised mouse position {x, y} (0-1 range each).
217
+ *
218
+ * @example
219
+ * ```ts
220
+ * import { renderWaveBackground } from 'asciify-engine';
221
+ *
222
+ * const canvas = document.getElementById('bg') as HTMLCanvasElement;
223
+ * const ctx = canvas.getContext('2d')!;
224
+ * const mouse = { x: 0.5, y: 0.5 };
225
+ * canvas.addEventListener('mousemove', e => {
226
+ * const r = canvas.getBoundingClientRect();
227
+ * mouse.x = (e.clientX - r.left) / r.width;
228
+ * mouse.y = (e.clientY - r.top) / r.height;
229
+ * });
230
+ *
231
+ * let t = 0;
232
+ * const tick = () => {
233
+ * renderWaveBackground(ctx, canvas.clientWidth, canvas.clientHeight, t, mouse);
234
+ * t += 0.016;
235
+ * requestAnimationFrame(tick);
236
+ * };
237
+ * requestAnimationFrame(tick);
238
+ * ```
239
+ */
240
+ declare function renderWaveBackground(ctx: CanvasRenderingContext2D, width: number, height: number, time: number, mousePos?: {
241
+ x: number;
242
+ y: number;
243
+ }, options?: WaveBackgroundOptions): void;
172
244
 
173
245
  interface WebGLRenderer {
174
246
  render(frame: AsciiFrame, options: AsciiOptions, displayW: number, displayH: number, time: number, hoverPos?: {
@@ -187,4 +259,4 @@ interface WebGLRenderer {
187
259
  */
188
260
  declare function tryCreateWebGLRenderer(canvas: HTMLCanvasElement): WebGLRenderer | null;
189
261
 
190
- export { ART_STYLE_PRESETS, type AnimationStyle, type ArtStyle, type AsciiCell, type AsciiFrame, type AsciiOptions, type AsciiResult, type AsciifySimpleOptions, CHARSETS, type CharsetKey, type ColorMode, DEFAULT_OPTIONS, HOVER_PRESETS, type HoverEffect, type HoverPreset, type RenderMode, type SourceType, type WebGLRenderer, asciify, asciifyGif, asciifyVideo, generateAnimatedEmbedCode, generateEmbedCode, gifToAsciiFrames, imageToAsciiFrame, renderFrameToCanvas, tryCreateWebGLRenderer, videoToAsciiFrames };
262
+ export { ART_STYLE_PRESETS, type AnimationStyle, type ArtStyle, type AsciiCell, type AsciiFrame, type AsciiOptions, type AsciiResult, type AsciifySimpleOptions, CHARSETS, type CharsetKey, type ColorMode, DEFAULT_OPTIONS, HOVER_PRESETS, type HoverEffect, type HoverPreset, type RenderMode, type SourceType, type WaveBackgroundOptions, type WebGLRenderer, asciify, asciifyGif, asciifyVideo, generateAnimatedEmbedCode, generateEmbedCode, gifToAsciiFrames, imageToAsciiFrame, renderFrameToCanvas, renderWaveBackground, tryCreateWebGLRenderer, videoToAsciiFrames };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  type ColorMode = 'grayscale' | 'fullcolor' | 'matrix' | 'accent';
2
2
  type RenderMode = 'ascii' | 'dots';
3
- type AnimationStyle = 'none' | 'wave' | 'pulse' | 'rain' | 'breathe' | 'sparkle' | 'glitch' | 'spiral' | 'typewriter' | 'scatter';
3
+ type AnimationStyle = 'none' | 'wave' | 'pulse' | 'rain' | 'breathe' | 'sparkle' | 'glitch' | 'spiral' | 'typewriter' | 'scatter' | 'waveField';
4
4
  type ArtStyle = 'classic' | 'particles' | 'letters' | 'claudeCode' | 'art' | 'terminal' | 'box' | 'lines';
5
5
  type HoverEffect = 'spotlight' | 'magnify' | 'repel' | 'glow' | 'colorShift';
6
6
  type HoverPreset = 'none' | 'subtle' | 'flashlight' | 'magnifier' | 'forceField' | 'neon' | 'fire' | 'ice';
@@ -160,15 +160,87 @@ declare function asciifyGif(source: string | ArrayBuffer, canvas: HTMLCanvasElem
160
160
  */
161
161
  declare function asciifyVideo(source: HTMLVideoElement | string, canvas: HTMLCanvasElement, { fontSize, style, options }?: AsciifySimpleOptions): Promise<() => void>;
162
162
  /**
163
- * Generate a self-contained HTML embed snippet for an ASCII image.
164
- * Features: canvas rendering, animation loop, hover effects.
163
+ * Generate a professional 3-line embed snippet.
164
+ * The render runtime is loaded from jsDelivr CDN (free, served from npm).
165
+ * Only the base64-encoded frame data is inlined.
165
166
  */
166
167
  declare function generateEmbedCode(frame: AsciiFrame, options: AsciiOptions, width: number, height: number): string;
167
168
  /**
168
- * Generate animated embed code for multi-frame (video) ASCII art.
169
- * Canvas-based with frame cycling, animation effects, and hover.
169
+ * Generate an animated embed snippet for multi-frame (GIF/video) ASCII art.
170
+ * Uses the same CDN runtime as generateEmbedCode.
170
171
  */
171
172
  declare function generateAnimatedEmbedCode(frames: AsciiFrame[], options: AsciiOptions, fps: number, width: number, height: number): string;
173
+ interface WaveBackgroundOptions {
174
+ /** Font size in CSS pixels (default: 13) */
175
+ fontSize?: number;
176
+ /** Character aspect ratio width/height (default: 0.62) */
177
+ charAspect?: number;
178
+ /** Line height multiplier (default: 1.4) */
179
+ lineHeightRatio?: number;
180
+ /** Character set from dark→bright (default: ' .·:;=+*#%@░▒▓') */
181
+ chars?: string;
182
+ /** Base colour for low-intensity cells — use '{a}' as alpha placeholder (default: white) */
183
+ baseColor?: string;
184
+ /** Accent colour applied near the cursor and on wave peaks (default: '#d4ff00') */
185
+ accentColor?: string;
186
+ /** Accent threshold: normalised intensity above which accent kicks in (default: 0.52) */
187
+ accentThreshold?: number;
188
+ /** How strongly the mouse influences local intensity (default: 0.55) */
189
+ mouseInfluence?: number;
190
+ /** Radial falloff for mouse influence — higher = tighter spotlight (default: 2.8) */
191
+ mouseFalloff?: number;
192
+ /** Base wave animation speed (default: 1) */
193
+ speed?: number;
194
+ /** Enable vortex swirl effect around cursor (default: true) */
195
+ vortex?: boolean;
196
+ /** Enable sparkle / pop flicker layered on top (default: true) */
197
+ sparkles?: boolean;
198
+ /** Enable a slow global breathe pulse (default: true) */
199
+ breathe?: boolean;
200
+ /** Light mode: swap fill colours to dark-on-light (default: false) */
201
+ lightMode?: boolean;
202
+ }
203
+ /**
204
+ * Render a procedural interactive wave-field of ASCII characters.
205
+ *
206
+ * Layers stacked per cell:
207
+ * 1. Three cardinal sine waves (classic feel)
208
+ * 2. Fractal Brownian Motion noise (organic structure)
209
+ * 3. Diagonal drift ripple (depth / perspective)
210
+ * 4. Slow global breathe pulse (heartbeat)
211
+ * 5. Vortex swirl near cursor (energy field)
212
+ * 6. Proximity spotlight (cursor highlight)
213
+ * 7. Sparkle flickers on bright peaks (life)
214
+ *
215
+ * Call inside a requestAnimationFrame loop with accumulated time in seconds
216
+ * and the current normalised mouse position {x, y} (0-1 range each).
217
+ *
218
+ * @example
219
+ * ```ts
220
+ * import { renderWaveBackground } from 'asciify-engine';
221
+ *
222
+ * const canvas = document.getElementById('bg') as HTMLCanvasElement;
223
+ * const ctx = canvas.getContext('2d')!;
224
+ * const mouse = { x: 0.5, y: 0.5 };
225
+ * canvas.addEventListener('mousemove', e => {
226
+ * const r = canvas.getBoundingClientRect();
227
+ * mouse.x = (e.clientX - r.left) / r.width;
228
+ * mouse.y = (e.clientY - r.top) / r.height;
229
+ * });
230
+ *
231
+ * let t = 0;
232
+ * const tick = () => {
233
+ * renderWaveBackground(ctx, canvas.clientWidth, canvas.clientHeight, t, mouse);
234
+ * t += 0.016;
235
+ * requestAnimationFrame(tick);
236
+ * };
237
+ * requestAnimationFrame(tick);
238
+ * ```
239
+ */
240
+ declare function renderWaveBackground(ctx: CanvasRenderingContext2D, width: number, height: number, time: number, mousePos?: {
241
+ x: number;
242
+ y: number;
243
+ }, options?: WaveBackgroundOptions): void;
172
244
 
173
245
  interface WebGLRenderer {
174
246
  render(frame: AsciiFrame, options: AsciiOptions, displayW: number, displayH: number, time: number, hoverPos?: {
@@ -187,4 +259,4 @@ interface WebGLRenderer {
187
259
  */
188
260
  declare function tryCreateWebGLRenderer(canvas: HTMLCanvasElement): WebGLRenderer | null;
189
261
 
190
- export { ART_STYLE_PRESETS, type AnimationStyle, type ArtStyle, type AsciiCell, type AsciiFrame, type AsciiOptions, type AsciiResult, type AsciifySimpleOptions, CHARSETS, type CharsetKey, type ColorMode, DEFAULT_OPTIONS, HOVER_PRESETS, type HoverEffect, type HoverPreset, type RenderMode, type SourceType, type WebGLRenderer, asciify, asciifyGif, asciifyVideo, generateAnimatedEmbedCode, generateEmbedCode, gifToAsciiFrames, imageToAsciiFrame, renderFrameToCanvas, tryCreateWebGLRenderer, videoToAsciiFrames };
262
+ export { ART_STYLE_PRESETS, type AnimationStyle, type ArtStyle, type AsciiCell, type AsciiFrame, type AsciiOptions, type AsciiResult, type AsciifySimpleOptions, CHARSETS, type CharsetKey, type ColorMode, DEFAULT_OPTIONS, HOVER_PRESETS, type HoverEffect, type HoverPreset, type RenderMode, type SourceType, type WaveBackgroundOptions, type WebGLRenderer, asciify, asciifyGif, asciifyVideo, generateAnimatedEmbedCode, generateEmbedCode, gifToAsciiFrames, imageToAsciiFrame, renderFrameToCanvas, renderWaveBackground, tryCreateWebGLRenderer, videoToAsciiFrames };