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.
- package/README.md +180 -0
- package/dist/textmode.synth.esm.js +967 -0
- package/dist/textmode.synth.umd.js +399 -0
- package/dist/types/SynthPlugin.d.ts +22 -0
- package/dist/types/SynthPlugin.d.ts.map +1 -0
- package/dist/types/compiler/GLSLGenerator.d.ts +44 -0
- package/dist/types/compiler/GLSLGenerator.d.ts.map +1 -0
- package/dist/types/compiler/SynthCompiler.d.ts +20 -0
- package/dist/types/compiler/SynthCompiler.d.ts.map +1 -0
- package/dist/types/compiler/UniformManager.d.ts +48 -0
- package/dist/types/compiler/UniformManager.d.ts.map +1 -0
- package/dist/types/compiler/index.d.ts +9 -0
- package/dist/types/compiler/index.d.ts.map +1 -0
- package/dist/types/compiler/types.d.ts +94 -0
- package/dist/types/compiler/types.d.ts.map +1 -0
- package/dist/types/core/ISynthSource.d.ts +718 -0
- package/dist/types/core/ISynthSource.d.ts.map +1 -0
- package/dist/types/core/SynthChain.d.ts +62 -0
- package/dist/types/core/SynthChain.d.ts.map +1 -0
- package/dist/types/core/SynthSource.d.ts +126 -0
- package/dist/types/core/SynthSource.d.ts.map +1 -0
- package/dist/types/core/index.d.ts +7 -0
- package/dist/types/core/index.d.ts.map +1 -0
- package/dist/types/core/types.d.ts +106 -0
- package/dist/types/core/types.d.ts.map +1 -0
- package/dist/types/index.d.ts +395 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/lib/ArrayUtils.d.ts +225 -0
- package/dist/types/lib/ArrayUtils.d.ts.map +1 -0
- package/dist/types/transforms/TransformDefinition.d.ts +54 -0
- package/dist/types/transforms/TransformDefinition.d.ts.map +1 -0
- package/dist/types/transforms/TransformFactory.d.ts +64 -0
- package/dist/types/transforms/TransformFactory.d.ts.map +1 -0
- package/dist/types/transforms/TransformRegistry.d.ts +72 -0
- package/dist/types/transforms/TransformRegistry.d.ts.map +1 -0
- package/dist/types/transforms/categories/charModifiers.d.ts +16 -0
- package/dist/types/transforms/categories/charModifiers.d.ts.map +1 -0
- package/dist/types/transforms/categories/colors.d.ts +29 -0
- package/dist/types/transforms/categories/colors.d.ts.map +1 -0
- package/dist/types/transforms/categories/combine.d.ts +19 -0
- package/dist/types/transforms/categories/combine.d.ts.map +1 -0
- package/dist/types/transforms/categories/combineCoord.d.ts +23 -0
- package/dist/types/transforms/categories/combineCoord.d.ts.map +1 -0
- package/dist/types/transforms/categories/coordinates.d.ts +22 -0
- package/dist/types/transforms/categories/coordinates.d.ts.map +1 -0
- package/dist/types/transforms/categories/index.d.ts +15 -0
- package/dist/types/transforms/categories/index.d.ts.map +1 -0
- package/dist/types/transforms/categories/sources.d.ts +19 -0
- package/dist/types/transforms/categories/sources.d.ts.map +1 -0
- package/dist/types/transforms/index.d.ts +8 -0
- package/dist/types/transforms/index.d.ts.map +1 -0
- package/dist/types/utils/CharacterResolver.d.ts +19 -0
- package/dist/types/utils/CharacterResolver.d.ts.map +1 -0
- 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.
|