textmode.synth.js 1.0.0-beta.1

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 (54) hide show
  1. package/README.md +180 -0
  2. package/dist/textmode.synth.esm.js +967 -0
  3. package/dist/textmode.synth.umd.js +399 -0
  4. package/dist/types/SynthPlugin.d.ts +22 -0
  5. package/dist/types/SynthPlugin.d.ts.map +1 -0
  6. package/dist/types/compiler/GLSLGenerator.d.ts +44 -0
  7. package/dist/types/compiler/GLSLGenerator.d.ts.map +1 -0
  8. package/dist/types/compiler/SynthCompiler.d.ts +20 -0
  9. package/dist/types/compiler/SynthCompiler.d.ts.map +1 -0
  10. package/dist/types/compiler/UniformManager.d.ts +48 -0
  11. package/dist/types/compiler/UniformManager.d.ts.map +1 -0
  12. package/dist/types/compiler/index.d.ts +9 -0
  13. package/dist/types/compiler/index.d.ts.map +1 -0
  14. package/dist/types/compiler/types.d.ts +94 -0
  15. package/dist/types/compiler/types.d.ts.map +1 -0
  16. package/dist/types/core/ISynthSource.d.ts +718 -0
  17. package/dist/types/core/ISynthSource.d.ts.map +1 -0
  18. package/dist/types/core/SynthChain.d.ts +62 -0
  19. package/dist/types/core/SynthChain.d.ts.map +1 -0
  20. package/dist/types/core/SynthSource.d.ts +126 -0
  21. package/dist/types/core/SynthSource.d.ts.map +1 -0
  22. package/dist/types/core/index.d.ts +7 -0
  23. package/dist/types/core/index.d.ts.map +1 -0
  24. package/dist/types/core/types.d.ts +106 -0
  25. package/dist/types/core/types.d.ts.map +1 -0
  26. package/dist/types/index.d.ts +395 -0
  27. package/dist/types/index.d.ts.map +1 -0
  28. package/dist/types/lib/ArrayUtils.d.ts +225 -0
  29. package/dist/types/lib/ArrayUtils.d.ts.map +1 -0
  30. package/dist/types/transforms/TransformDefinition.d.ts +54 -0
  31. package/dist/types/transforms/TransformDefinition.d.ts.map +1 -0
  32. package/dist/types/transforms/TransformFactory.d.ts +64 -0
  33. package/dist/types/transforms/TransformFactory.d.ts.map +1 -0
  34. package/dist/types/transforms/TransformRegistry.d.ts +72 -0
  35. package/dist/types/transforms/TransformRegistry.d.ts.map +1 -0
  36. package/dist/types/transforms/categories/charModifiers.d.ts +16 -0
  37. package/dist/types/transforms/categories/charModifiers.d.ts.map +1 -0
  38. package/dist/types/transforms/categories/colors.d.ts +29 -0
  39. package/dist/types/transforms/categories/colors.d.ts.map +1 -0
  40. package/dist/types/transforms/categories/combine.d.ts +19 -0
  41. package/dist/types/transforms/categories/combine.d.ts.map +1 -0
  42. package/dist/types/transforms/categories/combineCoord.d.ts +23 -0
  43. package/dist/types/transforms/categories/combineCoord.d.ts.map +1 -0
  44. package/dist/types/transforms/categories/coordinates.d.ts +22 -0
  45. package/dist/types/transforms/categories/coordinates.d.ts.map +1 -0
  46. package/dist/types/transforms/categories/index.d.ts +15 -0
  47. package/dist/types/transforms/categories/index.d.ts.map +1 -0
  48. package/dist/types/transforms/categories/sources.d.ts +19 -0
  49. package/dist/types/transforms/categories/sources.d.ts.map +1 -0
  50. package/dist/types/transforms/index.d.ts +8 -0
  51. package/dist/types/transforms/index.d.ts.map +1 -0
  52. package/dist/types/utils/CharacterResolver.d.ts +19 -0
  53. package/dist/types/utils/CharacterResolver.d.ts.map +1 -0
  54. package/package.json +54 -0
package/README.md ADDED
@@ -0,0 +1,180 @@
1
+ # textmode.synth.js
2
+
3
+ A `hydra`-inspired chainable visual synthesis system for `textmode.js`. Create procedural ASCII/text animations with simple, expressive code.
4
+
5
+ ## Features
6
+
7
+ - 🎨 **Procedural Generation**: Generate characters, colors, and patterns using oscillators, noise, voronoi, and more
8
+ - 🔗 **Method Chaining**: Hydra-style fluent API for building complex visual effects
9
+ - 🎯 **Three-Texture System**: Independent control over characters, character colors, and cell backgrounds
10
+ - âš¡ **WebGL Powered**: Compiled to optimized GLSL shaders for real-time performance
11
+ - 🔄 **Feedback Loops**: Create trails, motion blur, and recursive patterns
12
+ - 📦 **Compositional API**: Start with any aspect (char, color, background) and build from there
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ npm install textmode.synth.js
18
+ ```
19
+
20
+ ## Quick Start
21
+
22
+ ```javascript
23
+ import { textmode } from 'textmode.js';
24
+ import { SynthPlugin, char, osc, noise, solid } from 'textmode.synth.js';
25
+
26
+ const t = textmode.create({
27
+ width: 800,
28
+ height: 600,
29
+ fontSize: 12,
30
+ plugins: [SynthPlugin]
31
+ });
32
+
33
+ // Create a simple animated pattern
34
+ const pattern = osc(10, 0.1, 1.5);
35
+ t.layers.base.synth(
36
+ char(pattern)
37
+ .charMap('@#%*+=-:. ')
38
+ .charColor(pattern.clone())
39
+ .cellColor(pattern.clone().invert())
40
+ );
41
+ ```
42
+
43
+ ## Core Concepts
44
+
45
+ ### The New Compositional API
46
+
47
+ textmode.synth.js provides three standalone functions for defining different aspects of your visual:
48
+
49
+ - **`char(source, charCount?)`** - Define which pattern drives character generation
50
+ - **`charColor(source)`** - Define character foreground colors
51
+ - **`cellColor(source)`** - Define cell background colors
52
+
53
+ You can start with any of these and chain the others:
54
+
55
+ ```javascript
56
+ // Start with character generation
57
+ char(noise(10), 16)
58
+ .charMap('@#%*+=-:. ')
59
+ .charColor(osc(5))
60
+ .cellColor(solid(0, 0, 0, 0.5));
61
+
62
+ // Start with colors
63
+ charColor(voronoi(5).mult(osc(20)))
64
+ .char(noise(10), 16)
65
+ .cellColor(gradient(0.5));
66
+
67
+ // Start with background
68
+ cellColor(solid(0, 0, 0, 0.8))
69
+ .char(noise(10))
70
+ .charColor(osc(5).kaleid(4));
71
+ ```
72
+
73
+ ### Source Generators
74
+
75
+ Create patterns using these generators:
76
+
77
+ - `osc(frequency, sync, offset)` - Oscillating sine wave patterns
78
+ - `noise(scale, offset)` - Perlin noise
79
+ - `voronoi(scale, speed, blending)` - Cellular/voronoi patterns
80
+ - `gradient(speed)` - Rotating radial gradient
81
+ - `shape(sides, radius, smoothing)` - Geometric shapes
82
+ - `solid(r, g, b, a)` - Solid colors
83
+
84
+ ### Transforms
85
+
86
+ Chain transforms to modify patterns:
87
+
88
+ **Geometry:** `rotate()`, `scale()`, `scroll()`, `pixelate()`, `repeat()`, `kaleid()`
89
+ **Color:** `brightness()`, `contrast()`, `invert()`, `hue()`, `saturate()`, `colorama()`
90
+ **Blend:** `add()`, `sub()`, `mult()`, `blend()`, `diff()`, `layer()`, `mask()`
91
+ **Modulate:** `modulate()`, `modulateScale()`, `modulateRotate()`, `modulateScrollX()`, etc.
92
+
93
+ ### Character Mapping
94
+
95
+ Use `.charMap()` to define which characters to display:
96
+
97
+ ```javascript
98
+ char(noise(10))
99
+ .charMap('@#%*+=-:. ') // ASCII gradient
100
+ .charColor(osc(5));
101
+
102
+ char(voronoi(5))
103
+ .charMap('█▓▒░ ') // Block characters
104
+ .charColor(gradient(0.5));
105
+ ```
106
+
107
+ ## Examples
108
+
109
+ ### Same Pattern for Everything
110
+ ```javascript
111
+ const pattern = osc([10, 30, 60].fast(2), 0.1);
112
+ layer.synth(
113
+ char(pattern)
114
+ .charMap('@#%*+=-:. ')
115
+ .charColor(pattern.clone())
116
+ .cellColor(pattern.clone().invert())
117
+ );
118
+ ```
119
+
120
+ ### Different Patterns for Each Aspect
121
+ ```javascript
122
+ const charPattern = noise(5);
123
+ const colorPattern = voronoi(10, 0.5).mult(osc(20));
124
+ const bgPattern = gradient(0.2);
125
+
126
+ layer.synth(
127
+ char(charPattern, 16)
128
+ .charMap(' .:-=+*#%@')
129
+ .charColor(colorPattern)
130
+ .cellColor(bgPattern.invert())
131
+ );
132
+ ```
133
+
134
+ ### Feedback Loop
135
+ ```javascript
136
+ // Classic hydra-style feedback
137
+ layer.synth(
138
+ src()
139
+ .modulate(noise(3), 0.005)
140
+ .blend(shape(4), 0.01)
141
+ );
142
+ ```
143
+
144
+ ### Array Modulation
145
+ ```javascript
146
+ // Animate between multiple values
147
+ layer.synth(
148
+ char(osc([1, 10, 50, 100].fast(2), 0.1), 16)
149
+ .charMap('@#%*+=-:. ')
150
+ .charColor(osc([1, 10, 50, 100].fast(2), 0.1))
151
+ );
152
+ ```
153
+
154
+ ## Documentation
155
+
156
+ - [Full API Documentation](./api/index.md)
157
+ - [Compositional API Guide](./docs/COMPOSITIONAL-API.md)
158
+ - [Examples](./examples/)
159
+
160
+ ## Backward Compatibility
161
+
162
+ The old `charOsc()`, `charNoise()`, etc. functions still work:
163
+
164
+ ```javascript
165
+ // Old style (still works)
166
+ charOsc(10, 0.1, 0, 16)
167
+ .charColor(osc(10, 0.1));
168
+
169
+ // New style (recommended)
170
+ char(osc(10, 0.1), 16)
171
+ .charColor(osc(10, 0.1));
172
+ ```
173
+
174
+ ## License
175
+
176
+ MIT
177
+
178
+ ## Credits
179
+
180
+ Inspired by [hydra-synth](https://github.com/hydra-synth/hydra-synth) by Olivia Jack.