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
|
@@ -0,0 +1,718 @@
|
|
|
1
|
+
import type { SynthParameterValue } from './types';
|
|
2
|
+
export interface ISynthSource {
|
|
3
|
+
/**
|
|
4
|
+
* Map character indices to a specific character set.
|
|
5
|
+
* This is the primary textmode-native way to define which characters to use.
|
|
6
|
+
*
|
|
7
|
+
* @param chars A string of characters to map indices to
|
|
8
|
+
* @returns The SynthSource for chaining
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* // Map noise values to ASCII art characters
|
|
13
|
+
* noise(10).charMap('@#%*+=-:. ')
|
|
14
|
+
*
|
|
15
|
+
* // Use block characters
|
|
16
|
+
* osc(1).charMap(' .:-=+*#%@')
|
|
17
|
+
*
|
|
18
|
+
* // Use custom symbols
|
|
19
|
+
* gradient().charMap('-<>^v')
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
charMap(chars: string): this;
|
|
23
|
+
/**
|
|
24
|
+
* Set the character foreground color using a color source chain.
|
|
25
|
+
*
|
|
26
|
+
* @param source A SynthSource producing color values, or RGBA values
|
|
27
|
+
* @returns The SynthSource for chaining
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* // Use oscillator for grayscale colors
|
|
32
|
+
* noise(10).charColor(osc(5, 0.1))
|
|
33
|
+
*
|
|
34
|
+
* // Use solid color
|
|
35
|
+
* noise(10).charColor(solid(1, 0.5, 0))
|
|
36
|
+
*
|
|
37
|
+
* // Use gradient
|
|
38
|
+
* noise(10).charColor(gradient(0.5).hue(0.3))
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
charColor(source: ISynthSource): this;
|
|
42
|
+
/**
|
|
43
|
+
* Set the cell background colors using a color source chain.
|
|
44
|
+
*
|
|
45
|
+
* @param source A SynthSource producing color values, or RGBA values
|
|
46
|
+
* @returns The SynthSource for chaining
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```ts
|
|
50
|
+
* // Transparent background
|
|
51
|
+
* noise(10).cellColor(solid(0, 0, 0, 0))
|
|
52
|
+
*
|
|
53
|
+
* // Complement of character color
|
|
54
|
+
* noise(10).charColor(osc(5)).cellColor(osc(5).invert())
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
cellColor(source: ISynthSource): this;
|
|
58
|
+
/**
|
|
59
|
+
* Set the character indices using a character source chain.
|
|
60
|
+
*
|
|
61
|
+
* @param source A synth source producing character indices
|
|
62
|
+
* @param charCount Number of different characters to use from the character mapping
|
|
63
|
+
* @returns The SynthSource for chaining
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```ts
|
|
67
|
+
* // Use noise to select characters
|
|
68
|
+
* char(noise(10), 16)
|
|
69
|
+
*
|
|
70
|
+
* // Use oscillator to select characters
|
|
71
|
+
* char(osc(5), 8)
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
char(source: ISynthSource, charCount: number): this;
|
|
75
|
+
/**
|
|
76
|
+
* Set both character foreground and cell background color using the same source chain.
|
|
77
|
+
* This is a convenience method that combines `.charColor()` and `.cellColor()` in one call.
|
|
78
|
+
*
|
|
79
|
+
* After calling `paint()`, you can still override the cell color separately using `.cellColor()`.
|
|
80
|
+
*
|
|
81
|
+
* Otherwise useful for pixel art styles where both colors are the same, making the characters redundant.
|
|
82
|
+
*
|
|
83
|
+
* @param source A SynthSource producing color values
|
|
84
|
+
* @returns The SynthSource for chaining
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```ts
|
|
88
|
+
* // Apply same color to both character and cell background
|
|
89
|
+
* noise(10).paint(osc(5, 0.1).kaleid(4))
|
|
90
|
+
*
|
|
91
|
+
* // Apply color to both, then invert just the cell background
|
|
92
|
+
* noise(10)
|
|
93
|
+
* .paint(voronoi(10, 0.5).mult(osc(20)))
|
|
94
|
+
* .cellColor(voronoi(10, 0.5).mult(osc(20)).invert())
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
paint(source: ISynthSource): this;
|
|
98
|
+
/**
|
|
99
|
+
* Create a deep clone of this SynthSource.
|
|
100
|
+
* Useful when you want to create a modified version of an existing chain
|
|
101
|
+
* without affecting the original.
|
|
102
|
+
*
|
|
103
|
+
* @returns A new SynthSource with the same transform chain
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* ```ts
|
|
107
|
+
* // Create a color chain and use a modified clone for cell color
|
|
108
|
+
* const colorChain = voronoi(10, 0.5).mult(osc(20));
|
|
109
|
+
*
|
|
110
|
+
* noise(10)
|
|
111
|
+
* .paint(colorChain)
|
|
112
|
+
* .cellColor(colorChain.clone().invert())
|
|
113
|
+
*
|
|
114
|
+
* // Or use it to create variations of a base pattern
|
|
115
|
+
* const base = osc(10, 0.1);
|
|
116
|
+
* const rotated = base.clone().rotate(0.5);
|
|
117
|
+
* const scaled = base.clone().scale(2);
|
|
118
|
+
* ```
|
|
119
|
+
*/
|
|
120
|
+
clone(): ISynthSource;
|
|
121
|
+
/**
|
|
122
|
+
* Generate oscillating patterns using sine waves.
|
|
123
|
+
* @param frequency - Frequency of the oscillation (default: 60.0)
|
|
124
|
+
* @param sync - Synchronization offset (default: 0.1)
|
|
125
|
+
* @param offset - Phase offset (default: 0.0)
|
|
126
|
+
*/
|
|
127
|
+
osc?: (frequency?: SynthParameterValue, sync?: SynthParameterValue, offset?: SynthParameterValue) => ISynthSource;
|
|
128
|
+
/**
|
|
129
|
+
* Generate Perlin noise patterns.
|
|
130
|
+
* @param scale - Scale of the noise pattern (default: 10.0)
|
|
131
|
+
* @param speed - Animation speed (default: 0.1)
|
|
132
|
+
*/
|
|
133
|
+
noise?: (scale?: SynthParameterValue, speed?: SynthParameterValue) => ISynthSource;
|
|
134
|
+
/**
|
|
135
|
+
* Generate Voronoi (cellular) patterns.
|
|
136
|
+
* @param scale - Scale of Voronoi cells (default: 5.0)
|
|
137
|
+
* @param speed - Animation speed (default: 0.3)
|
|
138
|
+
* @param blending - Blending between cell regions (default: 0.3)
|
|
139
|
+
*/
|
|
140
|
+
voronoi?: (scale?: SynthParameterValue, speed?: SynthParameterValue, blending?: SynthParameterValue) => ISynthSource;
|
|
141
|
+
/**
|
|
142
|
+
* Generate a rotating radial gradient.
|
|
143
|
+
* @param speed - Rotation speed (default: 0.0)
|
|
144
|
+
*/
|
|
145
|
+
gradient?: (speed?: SynthParameterValue) => ISynthSource;
|
|
146
|
+
/**
|
|
147
|
+
* Generate geometric shapes (polygons).
|
|
148
|
+
* @param sides - Number of sides (default: 3)
|
|
149
|
+
* @param radius - Radius of the shape (default: 0.3)
|
|
150
|
+
* @param smoothing - Edge smoothing amount (default: 0.01)
|
|
151
|
+
*/
|
|
152
|
+
shape?: (sides?: SynthParameterValue, radius?: SynthParameterValue, smoothing?: SynthParameterValue) => ISynthSource;
|
|
153
|
+
/**
|
|
154
|
+
* Generate a solid color.
|
|
155
|
+
* @param r - Red channel (0-1, default: 0.0)
|
|
156
|
+
* @param g - Green channel (0-1, default: 0.0)
|
|
157
|
+
* @param b - Blue channel (0-1, default: 0.0)
|
|
158
|
+
* @param a - Alpha channel (0-1, default: 1.0)
|
|
159
|
+
*/
|
|
160
|
+
solid?: (r?: SynthParameterValue, g?: SynthParameterValue, b?: SynthParameterValue, a?: SynthParameterValue) => ISynthSource;
|
|
161
|
+
/**
|
|
162
|
+
* Sample the previous frame for feedback effects, or sample from another layer.
|
|
163
|
+
*
|
|
164
|
+
* **Self-feedback (no argument):** `src()` samples the current layer's previous frame.
|
|
165
|
+
* The sampled texture is context-aware based on where it's used in the synth chain:
|
|
166
|
+
*
|
|
167
|
+
* - Inside `char(...)` → samples previous frame's character data
|
|
168
|
+
* - Inside `charColor(...)` → samples previous frame's primary color (character foreground)
|
|
169
|
+
* - Inside `cellColor(...)` → samples previous frame's cell color (character background)
|
|
170
|
+
* - Outside all three → samples previous frame's primary color
|
|
171
|
+
*
|
|
172
|
+
* **Cross-layer sampling (with layer argument):** `src(layer)` samples from another
|
|
173
|
+
* layer's output, enabling hydra-style multi-output compositions. The sampled texture
|
|
174
|
+
* is still context-aware based on the current compilation target.
|
|
175
|
+
*
|
|
176
|
+
* This is the core of feedback loops and multi-layer compositions - enabling effects
|
|
177
|
+
* like trails, motion blur, recursive patterns, and complex layered visuals.
|
|
178
|
+
* Equivalent to hydra's `src(o0)`.
|
|
179
|
+
*
|
|
180
|
+
* @param layer - Optional TextmodeLayer to sample from. If omitted, samples from self (feedback).
|
|
181
|
+
*
|
|
182
|
+
* @example
|
|
183
|
+
* ```typescript
|
|
184
|
+
* // Classic hydra-style feedback loop with noise modulation
|
|
185
|
+
* src().modulate(noise(3), 0.005).blend(shape(4), 0.01)
|
|
186
|
+
*
|
|
187
|
+
* // Feedback with color shift
|
|
188
|
+
* src().hue(0.01).scale(1.01).blend(osc(10), 0.1)
|
|
189
|
+
*
|
|
190
|
+
* // Context-aware: src() samples the appropriate texture automatically
|
|
191
|
+
* char(noise(10).diff(src())) // src() → character feedback
|
|
192
|
+
* .charColor(osc(5).blend(src(), 0.5)) // src() → primary color feedback
|
|
193
|
+
* .cellColor(voronoi().diff(src())) // src() → cell color feedback
|
|
194
|
+
*
|
|
195
|
+
* // Cross-layer sampling (hydra-style o0, o1, o2, o3)
|
|
196
|
+
* const layer1 = t.layers.add();
|
|
197
|
+
* const layer2 = t.layers.add();
|
|
198
|
+
*
|
|
199
|
+
* layer1.synth(noise(10).mult(osc(20)));
|
|
200
|
+
*
|
|
201
|
+
* layer2.synth(
|
|
202
|
+
* char(voronoi(5).diff(src(layer1))) // Sample layer1's char texture
|
|
203
|
+
* .charColor(osc(10).blend(src(layer1), 0.5)) // Sample layer1's primary color
|
|
204
|
+
* );
|
|
205
|
+
*
|
|
206
|
+
* // Complex multi-layer composition
|
|
207
|
+
* t.layers.base.synth(
|
|
208
|
+
* noise(3, 0.3).thresh(0.3).diff(src(layer2), 0.3)
|
|
209
|
+
* );
|
|
210
|
+
* ```
|
|
211
|
+
*/
|
|
212
|
+
src?: (layer?: unknown) => ISynthSource;
|
|
213
|
+
/**
|
|
214
|
+
* Rotate coordinates.
|
|
215
|
+
* @param angle - Rotation angle in radians (default: 10.0)
|
|
216
|
+
* @param speed - Rotation speed multiplier (default: 0.0)
|
|
217
|
+
*
|
|
218
|
+
* @example
|
|
219
|
+
* ```typescript
|
|
220
|
+
* // Rotate shape continuously
|
|
221
|
+
* charOsc(50, 0, 0, 16)
|
|
222
|
+
* .rotate((ctx) => ctx.time % 360)
|
|
223
|
+
* .charColor(osc(50).rotate((ctx) => ctx.time % 360));
|
|
224
|
+
* ```
|
|
225
|
+
*/
|
|
226
|
+
rotate?: (angle?: SynthParameterValue, speed?: SynthParameterValue) => ISynthSource;
|
|
227
|
+
/**
|
|
228
|
+
* Scale coordinates.
|
|
229
|
+
* @param amount - Scale amount (default: 1.5)
|
|
230
|
+
* @param xMult - X axis multiplier (default: 1.0)
|
|
231
|
+
* @param yMult - Y axis multiplier (default: 1.0)
|
|
232
|
+
* @param offsetX - X offset (default: 0.5)
|
|
233
|
+
* @param offsetY - Y offset (default: 0.5)
|
|
234
|
+
*
|
|
235
|
+
* @example
|
|
236
|
+
* ```typescript
|
|
237
|
+
* // Scale a triangle shape
|
|
238
|
+
* charShape(3).scale(1.5, 1, 1);
|
|
239
|
+
* ```
|
|
240
|
+
*/
|
|
241
|
+
scale?: (amount?: SynthParameterValue, xMult?: SynthParameterValue, yMult?: SynthParameterValue, offsetX?: SynthParameterValue, offsetY?: SynthParameterValue) => ISynthSource;
|
|
242
|
+
/**
|
|
243
|
+
* Scroll coordinates in both X and Y directions.
|
|
244
|
+
* @param scrollX - X scroll amount (default: 0.5)
|
|
245
|
+
* @param scrollY - Y scroll amount (default: 0.5)
|
|
246
|
+
* @param speedX - X scroll speed (default: 0.0)
|
|
247
|
+
* @param speedY - Y scroll speed (default: 0.0)
|
|
248
|
+
*
|
|
249
|
+
* @example
|
|
250
|
+
* ```typescript
|
|
251
|
+
* // Scroll a shape diagonally
|
|
252
|
+
* charShape(3).scroll(0.1, -0.3);
|
|
253
|
+
* ```
|
|
254
|
+
*/
|
|
255
|
+
scroll?: (scrollX?: SynthParameterValue, scrollY?: SynthParameterValue, speedX?: SynthParameterValue, speedY?: SynthParameterValue) => ISynthSource;
|
|
256
|
+
/**
|
|
257
|
+
* Scroll coordinates in X direction.
|
|
258
|
+
* @param scrollX - X scroll amount (default: 0.5)
|
|
259
|
+
* @param speed - Scroll speed (default: 0.0)
|
|
260
|
+
*/
|
|
261
|
+
scrollX?: (scrollX?: SynthParameterValue, speed?: SynthParameterValue) => ISynthSource;
|
|
262
|
+
/**
|
|
263
|
+
* Scroll coordinates in Y direction.
|
|
264
|
+
* @param scrollY - Y scroll amount (default: 0.5)
|
|
265
|
+
* @param speed - Scroll speed (default: 0.0)
|
|
266
|
+
*/
|
|
267
|
+
scrollY?: (scrollY?: SynthParameterValue, speed?: SynthParameterValue) => ISynthSource;
|
|
268
|
+
/**
|
|
269
|
+
* Pixelate the output.
|
|
270
|
+
* @param pixelX - Pixel size in X (default: 20.0)
|
|
271
|
+
* @param pixelY - Pixel size in Y (default: 20.0)
|
|
272
|
+
*
|
|
273
|
+
* @example
|
|
274
|
+
* ```typescript
|
|
275
|
+
* // Pixelate noise pattern
|
|
276
|
+
* charNoise(1, 0.05)
|
|
277
|
+
* .pixelate(20, 20)
|
|
278
|
+
* .charColor(noise().pixelate(20, 20));
|
|
279
|
+
* ```
|
|
280
|
+
*/
|
|
281
|
+
pixelate?: (pixelX?: SynthParameterValue, pixelY?: SynthParameterValue) => ISynthSource;
|
|
282
|
+
/**
|
|
283
|
+
* Repeat coordinates in both X and Y directions.
|
|
284
|
+
* @param repeatX - Number of X repetitions (default: 3.0)
|
|
285
|
+
* @param repeatY - Number of Y repetitions (default: 3.0)
|
|
286
|
+
* @param offsetX - X offset between repetitions (default: 0.0)
|
|
287
|
+
* @param offsetY - Y offset between repetitions (default: 0.0)
|
|
288
|
+
*
|
|
289
|
+
* @example
|
|
290
|
+
* ```typescript
|
|
291
|
+
* // Repeat a shape in a 3x3 grid
|
|
292
|
+
* charShape(3)
|
|
293
|
+
* .repeat(3, 3, 0, 0)
|
|
294
|
+
* .charColor(shape().repeat(3, 3, 0, 0));
|
|
295
|
+
* ```
|
|
296
|
+
*/
|
|
297
|
+
repeat?: (repeatX?: SynthParameterValue, repeatY?: SynthParameterValue, offsetX?: SynthParameterValue, offsetY?: SynthParameterValue) => ISynthSource;
|
|
298
|
+
/**
|
|
299
|
+
* Repeat coordinates in X direction.
|
|
300
|
+
* @param reps - Number of repetitions (default: 3.0)
|
|
301
|
+
* @param offset - Offset between repetitions (default: 0.0)
|
|
302
|
+
*/
|
|
303
|
+
repeatX?: (reps?: SynthParameterValue, offset?: SynthParameterValue) => ISynthSource;
|
|
304
|
+
/**
|
|
305
|
+
* Repeat coordinates in Y direction.
|
|
306
|
+
* @param reps - Number of repetitions (default: 3.0)
|
|
307
|
+
* @param offset - Offset between repetitions (default: 0.0)
|
|
308
|
+
*/
|
|
309
|
+
repeatY?: (reps?: SynthParameterValue, offset?: SynthParameterValue) => ISynthSource;
|
|
310
|
+
/**
|
|
311
|
+
* Apply kaleidoscope effect.
|
|
312
|
+
* @param nSides - Number of kaleidoscope sides (default: 4.0)
|
|
313
|
+
*
|
|
314
|
+
* @example
|
|
315
|
+
* ```typescript
|
|
316
|
+
* // Create a 50-sided kaleidoscope pattern
|
|
317
|
+
* charOsc(25, -0.1, 0.5, 32)
|
|
318
|
+
* .kaleid(50)
|
|
319
|
+
* .charColor(osc(25, -0.1, 0.5).kaleid(50));
|
|
320
|
+
* ```
|
|
321
|
+
*/
|
|
322
|
+
kaleid?: (nSides?: SynthParameterValue) => ISynthSource;
|
|
323
|
+
/**
|
|
324
|
+
* Adjust brightness.
|
|
325
|
+
* @param amount - Brightness adjustment amount (default: 0.4)
|
|
326
|
+
*
|
|
327
|
+
* @example
|
|
328
|
+
* ```typescript
|
|
329
|
+
* // Animate brightness with sine wave
|
|
330
|
+
* charOsc(20, 0, 2, 16)
|
|
331
|
+
* .charColor(
|
|
332
|
+
* osc(20, 0, 2).brightness((ctx) => Math.sin(ctx.time))
|
|
333
|
+
* );
|
|
334
|
+
* ```
|
|
335
|
+
*/
|
|
336
|
+
brightness?: (amount?: SynthParameterValue) => ISynthSource;
|
|
337
|
+
/**
|
|
338
|
+
* Adjust contrast.
|
|
339
|
+
* @param amount - Contrast amount (default: 1.6)
|
|
340
|
+
*
|
|
341
|
+
* @example
|
|
342
|
+
* ```typescript
|
|
343
|
+
* // Animate contrast
|
|
344
|
+
* charOsc(20, 0.1, 0, 16)
|
|
345
|
+
* .charColor(
|
|
346
|
+
* osc(20).contrast((ctx) => Math.sin(ctx.time) * 5)
|
|
347
|
+
* );
|
|
348
|
+
* ```
|
|
349
|
+
*/
|
|
350
|
+
contrast?: (amount?: SynthParameterValue) => ISynthSource;
|
|
351
|
+
/**
|
|
352
|
+
* Invert colors.
|
|
353
|
+
* @param amount - Inversion amount (default: 1.0)
|
|
354
|
+
*
|
|
355
|
+
* @example
|
|
356
|
+
* ```typescript
|
|
357
|
+
* // Toggle inversion with array
|
|
358
|
+
* charSolid(16)
|
|
359
|
+
* .charColor(solid(1, 1, 1).invert([0, 1]))
|
|
360
|
+
* .cellColor(solid(1, 1, 1).invert([1, 0]));
|
|
361
|
+
* ```
|
|
362
|
+
*/
|
|
363
|
+
invert?: (amount?: SynthParameterValue) => ISynthSource;
|
|
364
|
+
/**
|
|
365
|
+
* Adjust color saturation.
|
|
366
|
+
* @param amount - Saturation amount (default: 2.0)
|
|
367
|
+
*
|
|
368
|
+
* @example
|
|
369
|
+
* ```typescript
|
|
370
|
+
* // Animate saturation
|
|
371
|
+
* charOsc(10, 0, 1, 16)
|
|
372
|
+
* .charColor(
|
|
373
|
+
* osc(10, 0, 1).saturate((ctx) => Math.sin(ctx.time) * 10)
|
|
374
|
+
* );
|
|
375
|
+
* ```
|
|
376
|
+
*/
|
|
377
|
+
saturate?: (amount?: SynthParameterValue) => ISynthSource;
|
|
378
|
+
/**
|
|
379
|
+
* Shift hue.
|
|
380
|
+
* @param hue - Hue shift amount (default: 0.4)
|
|
381
|
+
*
|
|
382
|
+
* @example
|
|
383
|
+
* ```typescript
|
|
384
|
+
* // Animate hue shift
|
|
385
|
+
* charOsc(30, 0.1, 1, 16)
|
|
386
|
+
* .charColor(
|
|
387
|
+
* osc(30, 0.1, 1).hue((ctx) => Math.sin(ctx.time))
|
|
388
|
+
* );
|
|
389
|
+
* ```
|
|
390
|
+
*/
|
|
391
|
+
hue?: (hue?: SynthParameterValue) => ISynthSource;
|
|
392
|
+
/**
|
|
393
|
+
* Apply colorama effect (hue rotation based on luminance).
|
|
394
|
+
* @param amount - Effect amount (default: 0.005)
|
|
395
|
+
*/
|
|
396
|
+
colorama?: (amount?: SynthParameterValue) => ISynthSource;
|
|
397
|
+
/**
|
|
398
|
+
* Posterize colors to limited palette.
|
|
399
|
+
* @param bins - Number of color bins (default: 3.0)
|
|
400
|
+
* @param gamma - Gamma correction (default: 0.6)
|
|
401
|
+
*
|
|
402
|
+
* @example
|
|
403
|
+
* ```typescript
|
|
404
|
+
* // Posterize gradient with array modulation
|
|
405
|
+
* charGradient(0, 16)
|
|
406
|
+
* .rotate(1.57)
|
|
407
|
+
* .charColor(
|
|
408
|
+
* gradient(0).posterize([1, 5, 15, 30], 0.5)
|
|
409
|
+
* );
|
|
410
|
+
* ```
|
|
411
|
+
*/
|
|
412
|
+
posterize?: (bins?: SynthParameterValue, gamma?: SynthParameterValue) => ISynthSource;
|
|
413
|
+
/**
|
|
414
|
+
* Apply threshold based on luminance.
|
|
415
|
+
* @param threshold - Threshold value (default: 0.5)
|
|
416
|
+
* @param tolerance - Tolerance range (default: 0.1)
|
|
417
|
+
*/
|
|
418
|
+
luma?: (threshold?: SynthParameterValue, tolerance?: SynthParameterValue) => ISynthSource;
|
|
419
|
+
/**
|
|
420
|
+
* Apply hard threshold.
|
|
421
|
+
* @param threshold - Threshold value (default: 0.5)
|
|
422
|
+
* @param tolerance - Tolerance range (default: 0.04)
|
|
423
|
+
*/
|
|
424
|
+
thresh?: (threshold?: SynthParameterValue, tolerance?: SynthParameterValue) => ISynthSource;
|
|
425
|
+
/**
|
|
426
|
+
* Set color channels.
|
|
427
|
+
* @param r - Red channel (default: 1.0)
|
|
428
|
+
* @param g - Green channel (default: 1.0)
|
|
429
|
+
* @param b - Blue channel (default: 1.0)
|
|
430
|
+
* @param a - Alpha channel (default: 1.0)
|
|
431
|
+
*/
|
|
432
|
+
color?: (r?: SynthParameterValue, g?: SynthParameterValue, b?: SynthParameterValue, a?: SynthParameterValue) => ISynthSource;
|
|
433
|
+
/**
|
|
434
|
+
* Scale and offset red channel.
|
|
435
|
+
* @param scale - Scale multiplier (default: 1.0)
|
|
436
|
+
* @param offset - Offset amount (default: 0.0)
|
|
437
|
+
*/
|
|
438
|
+
r?: (scale?: SynthParameterValue, offset?: SynthParameterValue) => ISynthSource;
|
|
439
|
+
/**
|
|
440
|
+
* Scale and offset green channel.
|
|
441
|
+
* @param scale - Scale multiplier (default: 1.0)
|
|
442
|
+
* @param offset - Offset amount (default: 0.0)
|
|
443
|
+
*/
|
|
444
|
+
g?: (scale?: SynthParameterValue, offset?: SynthParameterValue) => ISynthSource;
|
|
445
|
+
/**
|
|
446
|
+
* Scale and offset blue channel.
|
|
447
|
+
* @param scale - Scale multiplier (default: 1.0)
|
|
448
|
+
* @param offset - Offset amount (default: 0.0)
|
|
449
|
+
*/
|
|
450
|
+
b?: (scale?: SynthParameterValue, offset?: SynthParameterValue) => ISynthSource;
|
|
451
|
+
/**
|
|
452
|
+
* Shift color channels by adding offset values.
|
|
453
|
+
* @param r - Red channel shift (default: 0.5)
|
|
454
|
+
* @param g - Green channel shift (default: 0.0)
|
|
455
|
+
* @param b - Blue channel shift (default: 0.0)
|
|
456
|
+
* @param a - Alpha channel shift (default: 0.0)
|
|
457
|
+
*/
|
|
458
|
+
shift?: (r?: SynthParameterValue, g?: SynthParameterValue, b?: SynthParameterValue, a?: SynthParameterValue) => ISynthSource;
|
|
459
|
+
/**
|
|
460
|
+
* Apply gamma correction for nonlinear brightness control.
|
|
461
|
+
* @param amount - Gamma value (default: 1.0, < 1.0 brightens, > 1.0 darkens)
|
|
462
|
+
*
|
|
463
|
+
* @example
|
|
464
|
+
* ```typescript
|
|
465
|
+
* // Brighten midtones
|
|
466
|
+
* charNoise(10)
|
|
467
|
+
* .charColor(gradient(0).gamma(0.7))
|
|
468
|
+
*
|
|
469
|
+
* // Darken with animation
|
|
470
|
+
* charOsc(8)
|
|
471
|
+
* .charColor(osc(5).gamma([1.0, 1.5, 2.0].smooth(4)))
|
|
472
|
+
* ```
|
|
473
|
+
*/
|
|
474
|
+
gamma?: (amount?: SynthParameterValue) => ISynthSource;
|
|
475
|
+
/**
|
|
476
|
+
* Adjust input/output levels and gamma for precise tonal control.
|
|
477
|
+
* @param inMin - Input minimum (default: 0.0)
|
|
478
|
+
* @param inMax - Input maximum (default: 1.0)
|
|
479
|
+
* @param outMin - Output minimum (default: 0.0)
|
|
480
|
+
* @param outMax - Output maximum (default: 1.0)
|
|
481
|
+
* @param gamma - Gamma correction (default: 1.0)
|
|
482
|
+
*
|
|
483
|
+
* @example
|
|
484
|
+
* ```typescript
|
|
485
|
+
* // Expand tonal range from 0.2-0.8 to 0-1
|
|
486
|
+
* charNoise(10)
|
|
487
|
+
* .charColor(noise(5).levels(0.2, 0.8, 0.0, 1.0, 1.0))
|
|
488
|
+
*
|
|
489
|
+
* // Compress highlights, boost shadows
|
|
490
|
+
* charVoronoi(8)
|
|
491
|
+
* .charColor(voronoi(5).levels(0.0, 1.0, 0.2, 0.9, 0.8))
|
|
492
|
+
* ```
|
|
493
|
+
*/
|
|
494
|
+
levels?: (inMin?: SynthParameterValue, inMax?: SynthParameterValue, outMin?: SynthParameterValue, outMax?: SynthParameterValue, gamma?: SynthParameterValue) => ISynthSource;
|
|
495
|
+
/**
|
|
496
|
+
* Clamp color values to a specified range for stability.
|
|
497
|
+
* @param min - Minimum value (default: 0.0)
|
|
498
|
+
* @param max - Maximum value (default: 1.0)
|
|
499
|
+
*
|
|
500
|
+
* @example
|
|
501
|
+
* ```typescript
|
|
502
|
+
* // Prevent overflow after multiple blend operations
|
|
503
|
+
* charOsc(10)
|
|
504
|
+
* .charColor(
|
|
505
|
+
* osc(5).add(osc(8), 0.8).add(osc(12), 0.6).clampColor(0.0, 1.0)
|
|
506
|
+
* )
|
|
507
|
+
*
|
|
508
|
+
* // Create hard clip effect
|
|
509
|
+
* charNoise(8)
|
|
510
|
+
* .charColor(noise(5).brightness(0.5).clampColor(0.3, 0.7))
|
|
511
|
+
* ```
|
|
512
|
+
*/
|
|
513
|
+
clampColor?: (min?: SynthParameterValue, max?: SynthParameterValue) => ISynthSource;
|
|
514
|
+
/**
|
|
515
|
+
* Add another source.
|
|
516
|
+
* @param source - Source to add
|
|
517
|
+
* @param amount - Blend amount (default: 0.5)
|
|
518
|
+
*
|
|
519
|
+
* @example
|
|
520
|
+
* ```typescript
|
|
521
|
+
* // Add two shapes with animated blend amount
|
|
522
|
+
* charShape(3)
|
|
523
|
+
* .scale(0.5)
|
|
524
|
+
* .charColor(
|
|
525
|
+
* shape(3)
|
|
526
|
+
* .scale(0.5)
|
|
527
|
+
* .add(shape(4).scale(2), [0, 0.25, 0.5, 0.75, 1])
|
|
528
|
+
* );
|
|
529
|
+
* ```
|
|
530
|
+
*/
|
|
531
|
+
add?: (source: ISynthSource, amount?: SynthParameterValue) => ISynthSource;
|
|
532
|
+
/**
|
|
533
|
+
* Subtract another source.
|
|
534
|
+
* @param source - Source to subtract
|
|
535
|
+
* @param amount - Blend amount (default: 0.5)
|
|
536
|
+
*/
|
|
537
|
+
sub?: (source: ISynthSource, amount?: SynthParameterValue) => ISynthSource;
|
|
538
|
+
/**
|
|
539
|
+
* Multiply with another source.
|
|
540
|
+
* @param source - Source to multiply
|
|
541
|
+
* @param amount - Blend amount (default: 0.5)
|
|
542
|
+
*/
|
|
543
|
+
mult?: (source: ISynthSource, amount?: SynthParameterValue) => ISynthSource;
|
|
544
|
+
/**
|
|
545
|
+
* Blend with another source.
|
|
546
|
+
* @param source - Source to blend
|
|
547
|
+
* @param amount - Blend amount (default: 0.5)
|
|
548
|
+
*
|
|
549
|
+
* @example
|
|
550
|
+
* ```typescript
|
|
551
|
+
* // Blend two shapes
|
|
552
|
+
* charShape(3)
|
|
553
|
+
* .scale(0.5)
|
|
554
|
+
* .charColor(
|
|
555
|
+
* shape(3)
|
|
556
|
+
* .scale(0.5)
|
|
557
|
+
* .blend(shape(4).scale(2), [0, 0.25, 0.5, 0.75, 1])
|
|
558
|
+
* );
|
|
559
|
+
* ```
|
|
560
|
+
*/
|
|
561
|
+
blend?: (source: ISynthSource, amount?: SynthParameterValue) => ISynthSource;
|
|
562
|
+
/**
|
|
563
|
+
* Difference with another source.
|
|
564
|
+
* @param source - Source to compare
|
|
565
|
+
*
|
|
566
|
+
* @example
|
|
567
|
+
* ```typescript
|
|
568
|
+
* // Create difference pattern between two oscillators
|
|
569
|
+
* charOsc(9, 0.1, 2, 16)
|
|
570
|
+
* .charColor(
|
|
571
|
+
* osc(9, 0.1, 2).diff(osc(13, 0.5, 5))
|
|
572
|
+
* );
|
|
573
|
+
* ```
|
|
574
|
+
*/
|
|
575
|
+
diff?: (source: ISynthSource) => ISynthSource;
|
|
576
|
+
/**
|
|
577
|
+
* Layer another source on top.
|
|
578
|
+
* @param source - Source to layer
|
|
579
|
+
*/
|
|
580
|
+
layer?: (source: ISynthSource) => ISynthSource;
|
|
581
|
+
/**
|
|
582
|
+
* Mask using another source.
|
|
583
|
+
* @param source - Source to use as mask
|
|
584
|
+
*
|
|
585
|
+
* @example
|
|
586
|
+
* ```typescript
|
|
587
|
+
* // Mask gradient with voronoi pattern
|
|
588
|
+
* charGradient(0, 16)
|
|
589
|
+
* .charColor(
|
|
590
|
+
* gradient(5).mask(voronoi()).invert([0, 1])
|
|
591
|
+
* );
|
|
592
|
+
* ```
|
|
593
|
+
*/
|
|
594
|
+
mask?: (source: ISynthSource) => ISynthSource;
|
|
595
|
+
/**
|
|
596
|
+
* Modulate coordinates using another source.
|
|
597
|
+
* @param source - Modulation source
|
|
598
|
+
* @param amount - Modulation amount (default: 0.1)
|
|
599
|
+
*
|
|
600
|
+
* @example
|
|
601
|
+
* ```typescript
|
|
602
|
+
* // Modulate voronoi with kaleidoscope pattern
|
|
603
|
+
* charVoronoi(5, 0.3, 16)
|
|
604
|
+
* .rotate((ctx) => (ctx.time % 360) / 2)
|
|
605
|
+
* .modulate(
|
|
606
|
+
* osc(25, 0.1, 0.5)
|
|
607
|
+
* .kaleid(50)
|
|
608
|
+
* .scale((ctx) => Math.sin(ctx.time) * 0.5 + 1)
|
|
609
|
+
* .modulate(noise(0.6, 0.5)),
|
|
610
|
+
* 0.5
|
|
611
|
+
* );
|
|
612
|
+
* ```
|
|
613
|
+
*/
|
|
614
|
+
modulate?: (source: ISynthSource, amount?: SynthParameterValue) => ISynthSource;
|
|
615
|
+
/**
|
|
616
|
+
* Modulate scale using another source.
|
|
617
|
+
* @param source - Modulation source
|
|
618
|
+
* @param multiple - Scale multiplier (default: 1.0)
|
|
619
|
+
* @param offset - Offset amount (default: 1.0)
|
|
620
|
+
*/
|
|
621
|
+
modulateScale?: (source: ISynthSource, multiple?: SynthParameterValue, offset?: SynthParameterValue) => ISynthSource;
|
|
622
|
+
/**
|
|
623
|
+
* Modulate rotation using another source.
|
|
624
|
+
* @param source - Modulation source
|
|
625
|
+
* @param multiple - Rotation multiplier (default: 1.0)
|
|
626
|
+
* @param offset - Offset amount (default: 0.0)
|
|
627
|
+
*/
|
|
628
|
+
modulateRotate?: (source: ISynthSource, multiple?: SynthParameterValue, offset?: SynthParameterValue) => ISynthSource;
|
|
629
|
+
/**
|
|
630
|
+
* Modulate pixelation using another source.
|
|
631
|
+
* @param source - Modulation source
|
|
632
|
+
* @param multiple - Pixelation multiplier (default: 10.0)
|
|
633
|
+
* @param offset - Offset amount (default: 3.0)
|
|
634
|
+
*/
|
|
635
|
+
modulatePixelate?: (source: ISynthSource, multiple?: SynthParameterValue, offset?: SynthParameterValue) => ISynthSource;
|
|
636
|
+
/**
|
|
637
|
+
* Modulate kaleidoscope using another source.
|
|
638
|
+
* @param source - Modulation source
|
|
639
|
+
* @param nSides - Number of sides (default: 4.0)
|
|
640
|
+
*/
|
|
641
|
+
modulateKaleid?: (source: ISynthSource, nSides?: SynthParameterValue) => ISynthSource;
|
|
642
|
+
/**
|
|
643
|
+
* Modulate X scroll using another source.
|
|
644
|
+
* @param source - Modulation source
|
|
645
|
+
* @param scrollX - X scroll amount (default: 0.5)
|
|
646
|
+
* @param speed - Scroll speed (default: 0.0)
|
|
647
|
+
*/
|
|
648
|
+
modulateScrollX?: (source: ISynthSource, scrollX?: SynthParameterValue, speed?: SynthParameterValue) => ISynthSource;
|
|
649
|
+
/**
|
|
650
|
+
* Modulate Y scroll using another source.
|
|
651
|
+
* @param source - Modulation source
|
|
652
|
+
* @param scrollY - Y scroll amount (default: 0.5)
|
|
653
|
+
* @param speed - Scroll speed (default: 0.0)
|
|
654
|
+
*/
|
|
655
|
+
modulateScrollY?: (source: ISynthSource, scrollY?: SynthParameterValue, speed?: SynthParameterValue) => ISynthSource;
|
|
656
|
+
/**
|
|
657
|
+
* Generate character indices using Perlin noise.
|
|
658
|
+
* @param scale - Scale of the noise pattern (default: 10.0)
|
|
659
|
+
* @param speed - Animation speed (default: 0.1)
|
|
660
|
+
* @param charCount - Number of different characters to use (default: 256)
|
|
661
|
+
*/
|
|
662
|
+
charNoise?: (scale?: SynthParameterValue, speed?: SynthParameterValue, charCount?: SynthParameterValue) => ISynthSource;
|
|
663
|
+
/**
|
|
664
|
+
* Generate character indices using oscillating sine waves.
|
|
665
|
+
* @param frequency - Frequency of the oscillation (default: 60.0)
|
|
666
|
+
* @param sync - Synchronization offset (default: 0.1)
|
|
667
|
+
* @param charCount - Number of different characters to use (default: 256)
|
|
668
|
+
*/
|
|
669
|
+
charOsc?: (frequency?: SynthParameterValue, sync?: SynthParameterValue, charCount?: SynthParameterValue) => ISynthSource;
|
|
670
|
+
/**
|
|
671
|
+
* Generate character indices using a gradient.
|
|
672
|
+
* @param charCount - Number of different characters to use (default: 256)
|
|
673
|
+
* @param direction - Gradient direction (default: 0.0)
|
|
674
|
+
*/
|
|
675
|
+
charGradient?: (charCount?: SynthParameterValue, direction?: SynthParameterValue) => ISynthSource;
|
|
676
|
+
/**
|
|
677
|
+
* Generate character indices using Voronoi (cellular) patterns.
|
|
678
|
+
* @param scale - Scale of Voronoi cells (default: 5.0)
|
|
679
|
+
* @param speed - Animation speed (default: 0.3)
|
|
680
|
+
* @param charCount - Number of different characters to use (default: 256)
|
|
681
|
+
*/
|
|
682
|
+
charVoronoi?: (scale?: SynthParameterValue, speed?: SynthParameterValue, charCount?: SynthParameterValue) => ISynthSource;
|
|
683
|
+
/**
|
|
684
|
+
* Generate character indices based on geometric shapes (polygons).
|
|
685
|
+
* @param sides - Number of sides (default: 3)
|
|
686
|
+
* @param innerChar - Character index for inside the shape (default: 0)
|
|
687
|
+
* @param outerChar - Character index for outside the shape (default: 1)
|
|
688
|
+
* @param radius - Radius of the shape (default: 0.3)
|
|
689
|
+
*/
|
|
690
|
+
charShape?: (sides?: SynthParameterValue, innerChar?: SynthParameterValue, outerChar?: SynthParameterValue, radius?: SynthParameterValue) => ISynthSource;
|
|
691
|
+
/**
|
|
692
|
+
* Generate a solid character index across the entire canvas.
|
|
693
|
+
* @param charIndex - Character index to use (default: 0)
|
|
694
|
+
*/
|
|
695
|
+
charSolid?: (charIndex?: SynthParameterValue) => ISynthSource;
|
|
696
|
+
/**
|
|
697
|
+
* Flip characters horizontally.
|
|
698
|
+
* @param toggle - Toggle flip (default: 1.0)
|
|
699
|
+
*/
|
|
700
|
+
charFlipX?: (toggle?: SynthParameterValue) => ISynthSource;
|
|
701
|
+
/**
|
|
702
|
+
* Flip characters vertically.
|
|
703
|
+
* @param toggle - Toggle flip (default: 1.0)
|
|
704
|
+
*/
|
|
705
|
+
charFlipY?: (toggle?: SynthParameterValue) => ISynthSource;
|
|
706
|
+
/**
|
|
707
|
+
* Invert character indices.
|
|
708
|
+
* @param toggle - Toggle invert (default: 1.0)
|
|
709
|
+
*/
|
|
710
|
+
charInvert?: (toggle?: SynthParameterValue) => ISynthSource;
|
|
711
|
+
/**
|
|
712
|
+
* Rotate characters.
|
|
713
|
+
* @param angle - Rotation angle in radians (default: 0.0)
|
|
714
|
+
* @param speed - Rotation speed (default: 0.0)
|
|
715
|
+
*/
|
|
716
|
+
charRotate?: (angle?: SynthParameterValue, speed?: SynthParameterValue) => ISynthSource;
|
|
717
|
+
}
|
|
718
|
+
//# sourceMappingURL=ISynthSource.d.ts.map
|