video2ascii 1.0.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 ADDED
@@ -0,0 +1,45 @@
1
+ # video2ascii
2
+
3
+ WebGL-powered video to ASCII converter for React.
4
+
5
+ ## Usage
6
+
7
+ ```tsx
8
+ import { VideoToAscii } from "@/components/VideoToAscii";
9
+
10
+ <VideoToAscii src="/video.mp4" fontSize={12} colored audioReactivity={50} />;
11
+ ```
12
+
13
+ ## Props
14
+
15
+ | Prop | Type | Default | Description |
16
+ | ------------------ | ------------ | ------------ | -------------------------------------- |
17
+ | `src` | `string` | required | Video URL |
18
+ | `fontSize` | `number` | `10` | Character size (smaller = more detail) |
19
+ | `colored` | `boolean` | `false` | Use video colors vs green terminal |
20
+ | `blend` | `number` | `0` | 0 = ASCII, 100 = original video |
21
+ | `highlight` | `number` | `0` | Background behind characters (0-100) |
22
+ | `charset` | `CharsetKey` | `"standard"` | Character set |
23
+ | `maxWidth` | `number` | `900` | Max width in pixels |
24
+ | `enableMouse` | `boolean` | `true` | Cursor glow effect |
25
+ | `trailLength` | `number` | `24` | Mouse trail length |
26
+ | `enableRipple` | `boolean` | `false` | Click ripple effect |
27
+ | `rippleSpeed` | `number` | `40` | Ripple expansion speed |
28
+ | `audioReactivity` | `number` | `0` | Brightness from audio (0-100) |
29
+ | `audioSensitivity` | `number` | `50` | How dramatic audio effect is |
30
+ | `showStats` | `boolean` | `false` | Show FPS overlay |
31
+
32
+ ## Character Sets
33
+
34
+ ```tsx
35
+ import { ASCII_CHARSETS } from "@/lib/ascii-charsets";
36
+ ```
37
+
38
+ - `standard` — `@%#*+=-:. `
39
+ - `detailed` — Full gradient with 70 characters
40
+ - `blocks` — `█▓▒░ `
41
+ - `minimal` — `@#. `
42
+ - `binary` — `10 `
43
+ - `dots` — `●◉○◌ `
44
+ - `arrows` — `↑↗→↘↓↙←↖ `
45
+ - `emoji` — Various emoji
@@ -0,0 +1,87 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+
3
+ /**
4
+ * ASCII Character Set Definitions
5
+ *
6
+ * Character sets are ordered from dark (low brightness) to light (high brightness).
7
+ * The shader maps pixel brightness to character index, so the first character
8
+ * represents the darkest pixels and the last represents the brightest.
9
+ *
10
+ * To add a new character set:
11
+ * 1. Add an entry to ASCII_CHARSETS with a unique key
12
+ * 2. Order characters from dark → light (spaces/dots first, dense chars last)
13
+ * 3. The key becomes available in CharsetKey type automatically
14
+ */
15
+ declare const ASCII_CHARSETS: {
16
+ /** Classic 10-character gradient - good balance of detail and performance */
17
+ readonly standard: {
18
+ readonly name: "Standard";
19
+ readonly chars: " .:-=+*#%@";
20
+ };
21
+ /** Unicode block characters - chunky retro aesthetic */
22
+ readonly blocks: {
23
+ readonly name: "Blocks";
24
+ readonly chars: " ░▒▓█";
25
+ };
26
+ /** Minimal 5-character set - high contrast, fast rendering */
27
+ readonly minimal: {
28
+ readonly name: "Minimal";
29
+ readonly chars: " .oO@";
30
+ };
31
+ /** Binary on/off - pure silhouette mode */
32
+ readonly binary: {
33
+ readonly name: "Binary";
34
+ readonly chars: " █";
35
+ };
36
+ /** 70-character gradient - maximum detail, best for high resolution */
37
+ readonly detailed: {
38
+ readonly name: "Detailed";
39
+ readonly chars: " .'`^\",:;Il!i><~+_-?][}{1)(|/tfjrxnuvczXYUJCLQ0OZmwqpdbkhao*#MW&8%B@$";
40
+ };
41
+ /** Dot-based - pointillist aesthetic */
42
+ readonly dots: {
43
+ readonly name: "Dots";
44
+ readonly chars: " ·•●";
45
+ };
46
+ /** Directional arrows - experimental */
47
+ readonly arrows: {
48
+ readonly name: "Arrows";
49
+ readonly chars: " ←↙↓↘→↗↑↖";
50
+ };
51
+ /** Moon phases - decorative gradient */
52
+ readonly emoji: {
53
+ readonly name: "Emoji";
54
+ readonly chars: " ░▒▓🌑🌒🌓🌔🌕";
55
+ };
56
+ };
57
+ /** Type-safe key for selecting character sets */
58
+ type CharsetKey = keyof typeof ASCII_CHARSETS;
59
+
60
+ interface AsciiStats {
61
+ fps: number;
62
+ frameTime: number;
63
+ }
64
+ interface UseVideoToAsciiOptions {
65
+ fontSize?: number;
66
+ colored?: boolean;
67
+ blend?: number;
68
+ highlight?: number;
69
+ charset?: CharsetKey;
70
+ maxWidth?: number;
71
+ onStats?: (stats: AsciiStats) => void;
72
+ }
73
+ interface VideoToAsciiProps extends UseVideoToAsciiOptions {
74
+ src: string;
75
+ enableMouse?: boolean;
76
+ trailLength?: number;
77
+ enableRipple?: boolean;
78
+ rippleSpeed?: number;
79
+ audioReactivity?: number;
80
+ audioSensitivity?: number;
81
+ showStats?: boolean;
82
+ className?: string;
83
+ }
84
+
85
+ declare function VideoToAscii({ src, fontSize, colored, blend, highlight, charset, maxWidth, enableMouse, trailLength, enableRipple, rippleSpeed, audioReactivity, audioSensitivity, showStats, className, }: VideoToAsciiProps): react_jsx_runtime.JSX.Element;
86
+
87
+ export { ASCII_CHARSETS, type CharsetKey, VideoToAscii, type VideoToAsciiProps };
@@ -0,0 +1,87 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+
3
+ /**
4
+ * ASCII Character Set Definitions
5
+ *
6
+ * Character sets are ordered from dark (low brightness) to light (high brightness).
7
+ * The shader maps pixel brightness to character index, so the first character
8
+ * represents the darkest pixels and the last represents the brightest.
9
+ *
10
+ * To add a new character set:
11
+ * 1. Add an entry to ASCII_CHARSETS with a unique key
12
+ * 2. Order characters from dark → light (spaces/dots first, dense chars last)
13
+ * 3. The key becomes available in CharsetKey type automatically
14
+ */
15
+ declare const ASCII_CHARSETS: {
16
+ /** Classic 10-character gradient - good balance of detail and performance */
17
+ readonly standard: {
18
+ readonly name: "Standard";
19
+ readonly chars: " .:-=+*#%@";
20
+ };
21
+ /** Unicode block characters - chunky retro aesthetic */
22
+ readonly blocks: {
23
+ readonly name: "Blocks";
24
+ readonly chars: " ░▒▓█";
25
+ };
26
+ /** Minimal 5-character set - high contrast, fast rendering */
27
+ readonly minimal: {
28
+ readonly name: "Minimal";
29
+ readonly chars: " .oO@";
30
+ };
31
+ /** Binary on/off - pure silhouette mode */
32
+ readonly binary: {
33
+ readonly name: "Binary";
34
+ readonly chars: " █";
35
+ };
36
+ /** 70-character gradient - maximum detail, best for high resolution */
37
+ readonly detailed: {
38
+ readonly name: "Detailed";
39
+ readonly chars: " .'`^\",:;Il!i><~+_-?][}{1)(|/tfjrxnuvczXYUJCLQ0OZmwqpdbkhao*#MW&8%B@$";
40
+ };
41
+ /** Dot-based - pointillist aesthetic */
42
+ readonly dots: {
43
+ readonly name: "Dots";
44
+ readonly chars: " ·•●";
45
+ };
46
+ /** Directional arrows - experimental */
47
+ readonly arrows: {
48
+ readonly name: "Arrows";
49
+ readonly chars: " ←↙↓↘→↗↑↖";
50
+ };
51
+ /** Moon phases - decorative gradient */
52
+ readonly emoji: {
53
+ readonly name: "Emoji";
54
+ readonly chars: " ░▒▓🌑🌒🌓🌔🌕";
55
+ };
56
+ };
57
+ /** Type-safe key for selecting character sets */
58
+ type CharsetKey = keyof typeof ASCII_CHARSETS;
59
+
60
+ interface AsciiStats {
61
+ fps: number;
62
+ frameTime: number;
63
+ }
64
+ interface UseVideoToAsciiOptions {
65
+ fontSize?: number;
66
+ colored?: boolean;
67
+ blend?: number;
68
+ highlight?: number;
69
+ charset?: CharsetKey;
70
+ maxWidth?: number;
71
+ onStats?: (stats: AsciiStats) => void;
72
+ }
73
+ interface VideoToAsciiProps extends UseVideoToAsciiOptions {
74
+ src: string;
75
+ enableMouse?: boolean;
76
+ trailLength?: number;
77
+ enableRipple?: boolean;
78
+ rippleSpeed?: number;
79
+ audioReactivity?: number;
80
+ audioSensitivity?: number;
81
+ showStats?: boolean;
82
+ className?: string;
83
+ }
84
+
85
+ declare function VideoToAscii({ src, fontSize, colored, blend, highlight, charset, maxWidth, enableMouse, trailLength, enableRipple, rippleSpeed, audioReactivity, audioSensitivity, showStats, className, }: VideoToAsciiProps): react_jsx_runtime.JSX.Element;
86
+
87
+ export { ASCII_CHARSETS, type CharsetKey, VideoToAscii, type VideoToAsciiProps };