textmode.synth.js 1.0.0-beta.1 → 1.0.0-beta.3
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/LICENSE +661 -0
- package/README.md +104 -121
- package/dist/textmode.synth.esm.js +491 -410
- package/dist/textmode.synth.umd.js +31 -52
- package/dist/types/api/index.d.ts +7 -0
- package/dist/types/api/index.d.ts.map +1 -0
- package/dist/types/api/sources.d.ts +327 -0
- package/dist/types/api/sources.d.ts.map +1 -0
- package/dist/types/augmentations/index.d.ts +7 -0
- package/dist/types/augmentations/index.d.ts.map +1 -0
- package/dist/types/augmentations/textmode.d.ts +65 -0
- package/dist/types/augmentations/textmode.d.ts.map +1 -0
- package/dist/types/bootstrap.d.ts +11 -0
- package/dist/types/bootstrap.d.ts.map +1 -0
- package/dist/types/compiler/ExternalLayerManager.d.ts +60 -0
- package/dist/types/compiler/ExternalLayerManager.d.ts.map +1 -0
- package/dist/types/compiler/FeedbackTracker.d.ts +53 -0
- package/dist/types/compiler/FeedbackTracker.d.ts.map +1 -0
- package/dist/types/compiler/GLSLGenerator.d.ts +2 -2
- package/dist/types/compiler/GLSLGenerator.d.ts.map +1 -1
- package/dist/types/compiler/SynthCompiler.d.ts +7 -1
- package/dist/types/compiler/SynthCompiler.d.ts.map +1 -1
- package/dist/types/compiler/TransformCodeGenerator.d.ts +77 -0
- package/dist/types/compiler/TransformCodeGenerator.d.ts.map +1 -0
- package/dist/types/compiler/UniformManager.d.ts.map +1 -1
- package/dist/types/compiler/index.d.ts +14 -3
- package/dist/types/compiler/index.d.ts.map +1 -1
- package/dist/types/compiler/types.d.ts +7 -7
- package/dist/types/compiler/types.d.ts.map +1 -1
- package/dist/types/core/GlobalState.d.ts +30 -0
- package/dist/types/core/GlobalState.d.ts.map +1 -0
- package/dist/types/core/ISynthSource.d.ts +173 -202
- package/dist/types/core/ISynthSource.d.ts.map +1 -1
- package/dist/types/core/SynthChain.d.ts +0 -2
- package/dist/types/core/SynthChain.d.ts.map +1 -1
- package/dist/types/core/SynthSource.d.ts +4 -3
- package/dist/types/core/SynthSource.d.ts.map +1 -1
- package/dist/types/core/index.d.ts +9 -3
- package/dist/types/core/index.d.ts.map +1 -1
- package/dist/types/core/types.d.ts +57 -4
- package/dist/types/core/types.d.ts.map +1 -1
- package/dist/types/extensions/index.d.ts +10 -0
- package/dist/types/extensions/index.d.ts.map +1 -0
- package/dist/types/extensions/textmodelayer.d.ts +22 -0
- package/dist/types/extensions/textmodelayer.d.ts.map +1 -0
- package/dist/types/extensions/textmodifier.d.ts +11 -0
- package/dist/types/extensions/textmodifier.d.ts.map +1 -0
- package/dist/types/index.d.ts +11 -364
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/lifecycle/index.d.ts +10 -0
- package/dist/types/lifecycle/index.d.ts.map +1 -0
- package/dist/types/lifecycle/synthDispose.d.ts +11 -0
- package/dist/types/lifecycle/synthDispose.d.ts.map +1 -0
- package/dist/types/lifecycle/synthRender.d.ts +11 -0
- package/dist/types/lifecycle/synthRender.d.ts.map +1 -0
- package/dist/types/{SynthPlugin.d.ts → plugin/SynthPlugin.d.ts} +1 -1
- package/dist/types/plugin/SynthPlugin.d.ts.map +1 -0
- package/dist/types/plugin/constants.d.ts +5 -0
- package/dist/types/plugin/constants.d.ts.map +1 -0
- package/dist/types/plugin/index.d.ts +10 -0
- package/dist/types/plugin/index.d.ts.map +1 -0
- package/dist/types/transforms/TransformDefinition.d.ts +0 -12
- package/dist/types/transforms/TransformDefinition.d.ts.map +1 -1
- package/dist/types/transforms/TransformFactory.d.ts +4 -7
- package/dist/types/transforms/TransformFactory.d.ts.map +1 -1
- package/dist/types/transforms/TransformRegistry.d.ts +3 -6
- package/dist/types/transforms/TransformRegistry.d.ts.map +1 -1
- package/dist/types/transforms/categories/colors.d.ts +1 -1
- package/dist/types/transforms/categories/colors.d.ts.map +1 -1
- package/dist/types/transforms/categories/combine.d.ts.map +1 -1
- package/dist/types/transforms/categories/index.d.ts +3 -4
- package/dist/types/transforms/categories/index.d.ts.map +1 -1
- package/dist/types/transforms/categories/sources.d.ts.map +1 -1
- package/dist/types/{lib → utils}/ArrayUtils.d.ts +20 -5
- package/dist/types/utils/ArrayUtils.d.ts.map +1 -0
- package/dist/types/utils/CharacterResolver.d.ts.map +1 -1
- package/dist/types/utils/collectExternalLayerRefs.d.ts +7 -0
- package/dist/types/utils/collectExternalLayerRefs.d.ts.map +1 -0
- package/dist/types/utils/index.d.ts +12 -0
- package/dist/types/utils/index.d.ts.map +1 -0
- package/package.json +16 -9
- package/dist/types/SynthPlugin.d.ts.map +0 -1
- package/dist/types/lib/ArrayUtils.d.ts.map +0 -1
- package/dist/types/transforms/categories/charModifiers.d.ts +0 -16
- package/dist/types/transforms/categories/charModifiers.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -1,15 +1,33 @@
|
|
|
1
1
|
# textmode.synth.js
|
|
2
2
|
|
|
3
|
-
A
|
|
3
|
+
**A derivative work of [hydra-synth](https://github.com/hydra-synth/hydra-synth) by [Olivia Jack](https://github.com/ojack), adapted for the [textmode.js](https://github.com/humanbydefinition/textmode.js) ecosystem.**
|
|
4
|
+
|
|
5
|
+
Create procedural ASCII/text animations with a `hydra`-inspired, chainable visual synthesis system.
|
|
6
|
+
|
|
7
|
+
> [!NOTE]
|
|
8
|
+
> This project is work-in-progress and not yet ready for production use.
|
|
9
|
+
>
|
|
10
|
+
> `textmode.synth.js` becomes usable once `textmode.js` v0.9.0 is released.
|
|
4
11
|
|
|
5
12
|
## Features
|
|
6
13
|
|
|
7
|
-
- 🎨 **Procedural
|
|
8
|
-
- 🔗 **Method
|
|
9
|
-
- 🎯 **Three-
|
|
10
|
-
- ⚡ **WebGL
|
|
11
|
-
- 🔄 **Feedback
|
|
12
|
-
- 📦 **Compositional API
|
|
14
|
+
- 🎨 **Procedural generation** - Oscillators, noise, voronoi, and more
|
|
15
|
+
- 🔗 **Method chaining** - Hydra-style fluent API for complex visuals
|
|
16
|
+
- 🎯 **Three-texture system** - Independent control over characters, foreground, and background
|
|
17
|
+
- ⚡ **WebGL powered** - Compiled to optimized GLSL shaders
|
|
18
|
+
- 🔄 **Feedback loops** - Trails, motion blur, and recursive patterns
|
|
19
|
+
- 📦 **Compositional API** - Start from any aspect and build organically
|
|
20
|
+
- 📚 **Extensible** - Add your own sources, transforms, and more
|
|
21
|
+
|
|
22
|
+
## Try it online first
|
|
23
|
+
|
|
24
|
+
> [!NOTE]
|
|
25
|
+
> The live coding environment is not yet live. It will be available in the next few days.
|
|
26
|
+
|
|
27
|
+
To go along with the release of this library, we've created a **live coding environment** where you can explore everything in the browser: [synth.textmode.art](https://synth.textmode.art)
|
|
28
|
+
|
|
29
|
+
It features IntelliSense & auto-completion, documentation on hover, curated examples to explore, and a lot more. The whole `textmode.js` ecosystem is available at your fingertips.
|
|
30
|
+
|
|
13
31
|
|
|
14
32
|
## Installation
|
|
15
33
|
|
|
@@ -17,164 +35,129 @@ A `hydra`-inspired chainable visual synthesis system for `textmode.js`. Create p
|
|
|
17
35
|
npm install textmode.synth.js
|
|
18
36
|
```
|
|
19
37
|
|
|
20
|
-
## Quick
|
|
38
|
+
## Quick start
|
|
21
39
|
|
|
22
40
|
```javascript
|
|
23
41
|
import { textmode } from 'textmode.js';
|
|
24
|
-
import { SynthPlugin, char, osc
|
|
42
|
+
import { SynthPlugin, char, osc } from 'textmode.synth.js';
|
|
25
43
|
|
|
26
44
|
const t = textmode.create({
|
|
27
|
-
width:
|
|
28
|
-
height:
|
|
29
|
-
fontSize:
|
|
45
|
+
width: window.innerWidth,
|
|
46
|
+
height: window.innerHeight,
|
|
47
|
+
fontSize: 16,
|
|
30
48
|
plugins: [SynthPlugin]
|
|
31
49
|
});
|
|
32
50
|
|
|
33
|
-
|
|
34
|
-
const
|
|
51
|
+
const charChain = osc(1, -0.1, 0.5).kaleid(50);
|
|
52
|
+
const colorChain = osc(25, -0.1, 0.5).kaleid(50);
|
|
53
|
+
|
|
35
54
|
t.layers.base.synth(
|
|
36
|
-
char(
|
|
55
|
+
char(charChain)
|
|
37
56
|
.charMap('@#%*+=-:. ')
|
|
38
|
-
.charColor(
|
|
39
|
-
.cellColor(
|
|
57
|
+
.charColor(colorChain)
|
|
58
|
+
.cellColor(colorChain.clone().invert())
|
|
40
59
|
);
|
|
60
|
+
|
|
61
|
+
t.windowResized(() => {
|
|
62
|
+
t.resizeCanvas(window.innerWidth, window.innerHeight);
|
|
63
|
+
});
|
|
41
64
|
```
|
|
42
65
|
|
|
43
|
-
## Core
|
|
66
|
+
## Core concepts
|
|
44
67
|
|
|
45
|
-
###
|
|
68
|
+
### Compositional API
|
|
46
69
|
|
|
47
|
-
textmode.
|
|
70
|
+
`textmode.js` renders to three textures: characters, foreground colors, and background colors. `textmode.synth.js` provides functions to drive each independently:
|
|
48
71
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
72
|
+
| Function | Purpose |
|
|
73
|
+
|----------|---------|
|
|
74
|
+
| `char(source, charCount?)` | Character generation |
|
|
75
|
+
| `charColor(source)` | Foreground color |
|
|
76
|
+
| `cellColor(source)` | Background color |
|
|
77
|
+
| `paint(source)` | Both foreground & background |
|
|
52
78
|
|
|
53
|
-
|
|
79
|
+
Start from any entry point and chain the others:
|
|
54
80
|
|
|
55
81
|
```javascript
|
|
56
|
-
//
|
|
57
|
-
char(noise(10),
|
|
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
|
-
```
|
|
82
|
+
// From characters
|
|
83
|
+
char(noise(10)).charColor(osc(5)).cellColor(solid(0,0,0,0.5));
|
|
72
84
|
|
|
73
|
-
|
|
85
|
+
// From colors
|
|
86
|
+
charColor(voronoi(5)).char(noise(10)).cellColor(gradient(0.5));
|
|
74
87
|
|
|
75
|
-
|
|
88
|
+
// Shorthand for pixel art style
|
|
89
|
+
paint(noise(10));
|
|
90
|
+
```
|
|
76
91
|
|
|
77
|
-
|
|
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
|
|
92
|
+
### Pixel art mode
|
|
83
93
|
|
|
84
|
-
|
|
94
|
+
Use `paint()` to color both foreground and background identically, effectively hiding the characters:
|
|
85
95
|
|
|
86
|
-
|
|
96
|
+
```javascript
|
|
97
|
+
t.fontSize(16);
|
|
98
|
+
t.layers.base.synth(paint(noise(10)));
|
|
99
|
+
```
|
|
87
100
|
|
|
88
|
-
**
|
|
89
|
-
**Color:** `brightness()`, `contrast()`, `invert()`, `hue()`, `saturate()`, `colorama()`
|
|
90
|
-
**Blend:** `add()`, `sub()`, `mult()`, `blend()`, `diff()`, `layer()`, `mask()`
|
|
91
|
-
**Modulate:** `modulate()`, `modulateScale()`, `modulateRotate()`, `modulateScrollX()`, etc.
|
|
101
|
+
> **Tip:** With `t.fontSize(1)`, you can recreate most hydra visuals 1:1.
|
|
92
102
|
|
|
93
|
-
###
|
|
103
|
+
### Direct source usage
|
|
94
104
|
|
|
95
|
-
|
|
105
|
+
You can also pass a source directly to `.synth()` without any wrapper function:
|
|
96
106
|
|
|
97
107
|
```javascript
|
|
98
|
-
|
|
99
|
-
.charMap('@#%*+=-:. ') // ASCII gradient
|
|
100
|
-
.charColor(osc(5));
|
|
101
|
-
|
|
102
|
-
char(voronoi(5))
|
|
103
|
-
.charMap('█▓▒░ ') // Block characters
|
|
104
|
-
.charColor(gradient(0.5));
|
|
108
|
+
t.layers.base.synth(noise(10));
|
|
105
109
|
```
|
|
106
110
|
|
|
107
|
-
|
|
111
|
+
This drives both characters *and* foreground colors from the same source *(background defaults to black)*. In practice, using separate sources for characters often looks better - character cycling is more rapid than color changes.
|
|
108
112
|
|
|
109
|
-
###
|
|
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
|
-
```
|
|
113
|
+
### Source generators
|
|
119
114
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
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
|
-
```
|
|
115
|
+
| Generator | Description |
|
|
116
|
+
|-----------|-------------|
|
|
117
|
+
| `osc(freq, sync, offset)` | Sine wave patterns |
|
|
118
|
+
| `noise(scale, offset)` | Perlin noise |
|
|
119
|
+
| `voronoi(scale, speed, blend)` | Cellular patterns |
|
|
120
|
+
| `gradient(speed)` | Radial gradient |
|
|
121
|
+
| `shape(sides, radius, smooth)` | Geometric polygons |
|
|
122
|
+
| `solid(r, g, b, a)` | Solid colors |
|
|
123
|
+
| `src(layer?)` | Feedback / cross-layer sampling |
|
|
124
|
+
| `...` | ...and many more..? |
|
|
143
125
|
|
|
144
|
-
###
|
|
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
|
-
```
|
|
126
|
+
### Transforms
|
|
153
127
|
|
|
154
|
-
|
|
128
|
+
Chain transforms to modify patterns:
|
|
155
129
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
130
|
+
| Category | Methods |
|
|
131
|
+
|----------|---------|
|
|
132
|
+
| **Geometry** | `rotate`, `scale`, `scroll`, `pixelate`, `repeat`, `kaleid`, ... |
|
|
133
|
+
| **Color** | `brightness`, `contrast`, `invert`, `hue`, `saturate`, `colorama`, ... |
|
|
134
|
+
| **Blend** | `add`, `sub`, `mult`, `blend`, `diff`, `layer`, `mask`, ... |
|
|
135
|
+
| **Modulate** | `modulate`, `modulateScale`, `modulateRotate`, `modulateKaleid`, ... |
|
|
159
136
|
|
|
160
|
-
|
|
137
|
+
### Character mapping
|
|
161
138
|
|
|
162
|
-
|
|
139
|
+
Use `.charMap()` to define the character set. By default, all characters available in the layer's font are used.
|
|
163
140
|
|
|
164
141
|
```javascript
|
|
165
|
-
//
|
|
166
|
-
|
|
167
|
-
.charColor(osc(10, 0.1));
|
|
168
|
-
|
|
169
|
-
// New style (recommended)
|
|
170
|
-
char(osc(10, 0.1), 16)
|
|
171
|
-
.charColor(osc(10, 0.1));
|
|
142
|
+
char(noise(10)).charMap('@#%*+=-:. '); // ASCII gradient
|
|
143
|
+
char(voronoi(5)).charMap('█▓▒░ '); // Block characters
|
|
172
144
|
```
|
|
173
145
|
|
|
146
|
+
## Documentation
|
|
147
|
+
|
|
148
|
+
There's a lot more to explore beyond this overview:
|
|
149
|
+
|
|
150
|
+
- **[Online documentation](https://code.textmode.art/docs/synth)** - Full guides and tutorials
|
|
151
|
+
- **[API reference](./api/index.md)** - Complete API documentation
|
|
152
|
+
- **[synth.textmode.art](https://synth.textmode.art)** - Live coding environment
|
|
153
|
+
|
|
174
154
|
## License
|
|
175
155
|
|
|
176
|
-
|
|
156
|
+
Distributed under the **AGPL-3.0** License. See [LICENSE](./LICENSE) for more information.
|
|
177
157
|
|
|
178
158
|
## Credits
|
|
179
159
|
|
|
180
|
-
|
|
160
|
+
This project is a derivative work of [hydra-synth](https://github.com/hydra-synth/hydra-synth) by [Olivia Jack](https://github.com/ojack), adapted for the [textmode.js](https://github.com/humanbydefinition/textmode.js) ecosystem.
|
|
161
|
+
|
|
162
|
+
- **hydra-synth**: Core synthesis logic, GLSL shader generation, and functional API design.
|
|
163
|
+
- **Modifications**: Adapted for `textmode.js`'s three-texture rendering pipeline *(characters, foreground colors, background colors)* and plugin system.
|