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,395 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A `hydra`-inspired chainable visual synthesis system for `textmode.js`.
|
|
3
|
+
* Enables procedural generation of characters, colors, and visual effects
|
|
4
|
+
* through method chaining.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* import { textmode } from 'textmode.js';
|
|
9
|
+
* import { SynthPlugin, osc, noise } from 'textmode.synth.js';
|
|
10
|
+
*
|
|
11
|
+
* // Create textmode instance with SynthPlugin
|
|
12
|
+
* const t = textmode.create({
|
|
13
|
+
* width: 800,
|
|
14
|
+
* height: 600,
|
|
15
|
+
* fontSize: 16,
|
|
16
|
+
* plugins: [SynthPlugin]
|
|
17
|
+
* });
|
|
18
|
+
*
|
|
19
|
+
* // Create a synth chain with procedural characters and colors
|
|
20
|
+
* const synth = noise(10)
|
|
21
|
+
* .rotate(0.1)
|
|
22
|
+
* .scroll(0.1, 0)
|
|
23
|
+
*
|
|
24
|
+
* .charColor(osc(5).kaleid(4))
|
|
25
|
+
* .cellColor(osc(5).kaleid(4).invert())
|
|
26
|
+
*
|
|
27
|
+
* .charMap('@#%*+=-:. ');
|
|
28
|
+
*
|
|
29
|
+
*
|
|
30
|
+
* // Apply synth to the base layer
|
|
31
|
+
* t.layers.base.synth(synth);
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* @packageDocumentation
|
|
35
|
+
*/
|
|
36
|
+
import { SynthSource } from './core/SynthSource';
|
|
37
|
+
import type { SynthContext } from './core/types';
|
|
38
|
+
/**
|
|
39
|
+
* Create a character source from any color/pattern source.
|
|
40
|
+
*
|
|
41
|
+
* This function converts any pattern (like `osc()`, `noise()`, `voronoi()`) into
|
|
42
|
+
* character indices. The pattern's luminance or color values are mapped to character indices.
|
|
43
|
+
*
|
|
44
|
+
* This is the recommended way to define character generation in textmode.synth.js,
|
|
45
|
+
* as it provides a unified, compositional API where the same patterns can drive
|
|
46
|
+
* characters, character colors, and cell colors.
|
|
47
|
+
*
|
|
48
|
+
* @param source - A SynthSource producing color values that will be mapped to characters
|
|
49
|
+
* @param charCount - Number of different characters to use (default: 256)
|
|
50
|
+
* @returns A new SynthSource configured for character generation
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```typescript
|
|
54
|
+
* // Simple usage - same pattern for chars and colors
|
|
55
|
+
* const pattern = osc(1, 0.1);
|
|
56
|
+
* layer.synth(
|
|
57
|
+
* char(pattern)
|
|
58
|
+
* .charColor(pattern.clone())
|
|
59
|
+
* );
|
|
60
|
+
*
|
|
61
|
+
* // With limited character count
|
|
62
|
+
* layer.synth(
|
|
63
|
+
* char(noise(10), 16)
|
|
64
|
+
* .charMap('@#%*+=-:. ')
|
|
65
|
+
* );
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
export declare const char: (source: SynthSource, charCount?: number) => SynthSource;
|
|
69
|
+
/**
|
|
70
|
+
* Create a synth source with character foreground color defined.
|
|
71
|
+
*
|
|
72
|
+
* This function creates a SynthSource where the character foreground color
|
|
73
|
+
* is driven by the provided source pattern. This is compositional and can be
|
|
74
|
+
* combined with `char()` and `cellColor()`.
|
|
75
|
+
*
|
|
76
|
+
* @param source - A SynthSource producing color values for character foreground
|
|
77
|
+
* @returns A new SynthSource configured with character color
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```typescript
|
|
81
|
+
* const t = textmode.create({
|
|
82
|
+
* width: 800,
|
|
83
|
+
* height: 600,
|
|
84
|
+
* plugins: [SynthPlugin]
|
|
85
|
+
* });
|
|
86
|
+
*
|
|
87
|
+
* // Start with character color
|
|
88
|
+
* const pattern = osc(10, 0.1);
|
|
89
|
+
* t.layers.base.synth(
|
|
90
|
+
* charColor(pattern)
|
|
91
|
+
* .char(noise(10))
|
|
92
|
+
* .cellColor(solid(0, 0, 0, 0.5))
|
|
93
|
+
* );
|
|
94
|
+
*
|
|
95
|
+
* // Using different patterns for each aspect
|
|
96
|
+
* t.layers.base.synth(
|
|
97
|
+
* charColor(voronoi(5).mult(osc(20)))
|
|
98
|
+
* .char(noise(10), 16)
|
|
99
|
+
* .charMap('@#%*+=-:. ')
|
|
100
|
+
* );
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
103
|
+
export declare const charColor: (source: SynthSource) => SynthSource;
|
|
104
|
+
/**
|
|
105
|
+
* Create a synth source with cell background color defined.
|
|
106
|
+
*
|
|
107
|
+
* This function creates a SynthSource where the cell background color
|
|
108
|
+
* is driven by the provided source pattern. This is compositional and can be
|
|
109
|
+
* combined with `char()` and `charColor()`.
|
|
110
|
+
*
|
|
111
|
+
* @param source - A SynthSource producing color values for cell background
|
|
112
|
+
* @returns A new SynthSource configured with cell color
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```typescript
|
|
116
|
+
* const t = textmode.create({
|
|
117
|
+
* width: 800,
|
|
118
|
+
* height: 600,
|
|
119
|
+
* plugins: [SynthPlugin]
|
|
120
|
+
* });
|
|
121
|
+
*
|
|
122
|
+
* // Start with cell color
|
|
123
|
+
* t.layers.base.synth(
|
|
124
|
+
* cellColor(solid(0, 0, 0, 0.5))
|
|
125
|
+
* .char(noise(10))
|
|
126
|
+
* .charColor(osc(5))
|
|
127
|
+
* );
|
|
128
|
+
*
|
|
129
|
+
* // Complete composition - all three defined
|
|
130
|
+
* const colorPattern = voronoi(5, 0.3);
|
|
131
|
+
* t.layers.base.synth(
|
|
132
|
+
* cellColor(colorPattern.clone().invert())
|
|
133
|
+
* .char(noise(10), 16)
|
|
134
|
+
* .charMap('@#%*+=-:. ')
|
|
135
|
+
* .charColor(colorPattern)
|
|
136
|
+
* );
|
|
137
|
+
* ```
|
|
138
|
+
*/
|
|
139
|
+
export declare const cellColor: (source: SynthSource) => SynthSource;
|
|
140
|
+
/**
|
|
141
|
+
* Create a synth source with both character and cell colors defined.
|
|
142
|
+
*
|
|
143
|
+
* This function creates a SynthSource where both the character foreground color
|
|
144
|
+
* and the cell background color are driven by the same source pattern.
|
|
145
|
+
* This is a convenience function equivalent to calling both `charColor()` and
|
|
146
|
+
* `cellColor()` with the same source.
|
|
147
|
+
*
|
|
148
|
+
* @param source - A SynthSource producing color values for both character and cell colors
|
|
149
|
+
* @returns A new SynthSource configured with both color sources
|
|
150
|
+
*
|
|
151
|
+
* @example
|
|
152
|
+
* ```typescript
|
|
153
|
+
* const t = textmode.create({
|
|
154
|
+
* width: 800,
|
|
155
|
+
* height: 600,
|
|
156
|
+
* plugins: [SynthPlugin]
|
|
157
|
+
* });
|
|
158
|
+
*
|
|
159
|
+
* // Use same pattern for both foreground and background colors
|
|
160
|
+
* const colorPattern = osc(10, 0.1).mult(voronoi(5));
|
|
161
|
+
* t.layers.base.synth(
|
|
162
|
+
* paint(colorPattern)
|
|
163
|
+
* .char(noise(10), 16)
|
|
164
|
+
* .charMap('@#%*+=-:. ')
|
|
165
|
+
* );
|
|
166
|
+
*
|
|
167
|
+
* // Paint with gradient
|
|
168
|
+
* t.layers.base.synth(
|
|
169
|
+
* paint(gradient(0.5))
|
|
170
|
+
* );
|
|
171
|
+
* ```
|
|
172
|
+
*/
|
|
173
|
+
export declare const paint: (source: SynthSource) => SynthSource;
|
|
174
|
+
export { SynthPlugin } from './SynthPlugin';
|
|
175
|
+
export type { SynthTransformType, SynthParameterValue, SynthContext, } from './core/types';
|
|
176
|
+
export { SynthSource } from './core/SynthSource';
|
|
177
|
+
/**
|
|
178
|
+
* Generate oscillating patterns using sine waves.
|
|
179
|
+
* @param frequency - Frequency of the oscillation (default: 60.0)
|
|
180
|
+
* @param sync - Synchronization offset (default: 0.1)
|
|
181
|
+
* @param offset - Phase offset (default: 0.0)
|
|
182
|
+
*
|
|
183
|
+
* @example
|
|
184
|
+
* ```typescript
|
|
185
|
+
* const t = textmode.create({
|
|
186
|
+
* width: 800,
|
|
187
|
+
* height: 600,
|
|
188
|
+
* plugins: [SynthPlugin]
|
|
189
|
+
* });
|
|
190
|
+
*
|
|
191
|
+
* // Basic oscillating color pattern
|
|
192
|
+
* t.layers.base.synth(
|
|
193
|
+
* osc(1, 0.1)
|
|
194
|
+
* .charColor(osc(10, 0.1))
|
|
195
|
+
* );
|
|
196
|
+
*
|
|
197
|
+
* // Animated frequency using array modulation
|
|
198
|
+
* t.layers.base.synth(
|
|
199
|
+
* osc([1, 10, 50, 100].fast(2), 0.001)
|
|
200
|
+
* .charColor(osc([1, 10, 50, 100].fast(2), 0.001))
|
|
201
|
+
* );
|
|
202
|
+
* ```
|
|
203
|
+
*/
|
|
204
|
+
export declare const osc: (frequency?: number | number[] | ((ctx: SynthContext) => number), sync?: number | number[] | ((ctx: SynthContext) => number), offset?: number | number[] | ((ctx: SynthContext) => number)) => SynthSource;
|
|
205
|
+
/**
|
|
206
|
+
* Generate Perlin noise patterns.
|
|
207
|
+
* @param scale - Scale of the noise pattern (default: 10.0)
|
|
208
|
+
* @param offset - Offset in noise space (default: 0.1)
|
|
209
|
+
*
|
|
210
|
+
* @example
|
|
211
|
+
* ```typescript
|
|
212
|
+
* const t = textmode.create({
|
|
213
|
+
* width: 800,
|
|
214
|
+
* height: 600,
|
|
215
|
+
* plugins: [SynthPlugin]
|
|
216
|
+
* });
|
|
217
|
+
*
|
|
218
|
+
* // Basic noise pattern
|
|
219
|
+
* t.layers.base.synth(
|
|
220
|
+
* noise(10, 0.1)
|
|
221
|
+
* .charColor(noise(10, 0.1))
|
|
222
|
+
* );
|
|
223
|
+
* ```
|
|
224
|
+
*/
|
|
225
|
+
export declare const noise: (scale?: number | number[] | ((ctx: SynthContext) => number), offset?: number | number[] | ((ctx: SynthContext) => number)) => SynthSource;
|
|
226
|
+
/**
|
|
227
|
+
* Generate Voronoi (cellular) patterns.
|
|
228
|
+
* @param scale - Scale of Voronoi cells (default: 5.0)
|
|
229
|
+
* @param speed - Animation speed (default: 0.3)
|
|
230
|
+
* @param blending - Blending between cell regions (default: 0.3)
|
|
231
|
+
*
|
|
232
|
+
* @example
|
|
233
|
+
* ```typescript
|
|
234
|
+
* const t = textmode.create({
|
|
235
|
+
* width: 800,
|
|
236
|
+
* height: 600,
|
|
237
|
+
* plugins: [SynthPlugin]
|
|
238
|
+
* });
|
|
239
|
+
*
|
|
240
|
+
* // Animated Voronoi pattern
|
|
241
|
+
* t.layers.base.synth(
|
|
242
|
+
* voronoi(5, 0.3, 0.3)
|
|
243
|
+
* .charColor(voronoi(5, 0.3, 0.3))
|
|
244
|
+
* );
|
|
245
|
+
* ```
|
|
246
|
+
*/
|
|
247
|
+
export declare const voronoi: (scale?: number | number[] | ((ctx: SynthContext) => number), speed?: number | number[] | ((ctx: SynthContext) => number), blending?: number | number[] | ((ctx: SynthContext) => number)) => SynthSource;
|
|
248
|
+
/**
|
|
249
|
+
* Generate a rotating radial gradient.
|
|
250
|
+
* @param speed - Rotation speed (default: 0.0)
|
|
251
|
+
*
|
|
252
|
+
* @example
|
|
253
|
+
* ```typescript
|
|
254
|
+
* const t = textmode.create({
|
|
255
|
+
* width: 800,
|
|
256
|
+
* height: 600,
|
|
257
|
+
* plugins: [SynthPlugin]
|
|
258
|
+
* });
|
|
259
|
+
*
|
|
260
|
+
* // Animated gradient with array modulation
|
|
261
|
+
* t.layers.base.synth(
|
|
262
|
+
* gradient([1, 2, 4])
|
|
263
|
+
* .charColor(gradient([1, 2, 4]))
|
|
264
|
+
* .cellColor(
|
|
265
|
+
* gradient([1, 2, 4])
|
|
266
|
+
* .invert((ctx) => Math.sin(ctx.time) * 2)
|
|
267
|
+
* )
|
|
268
|
+
* );
|
|
269
|
+
* ```
|
|
270
|
+
*/
|
|
271
|
+
export declare const gradient: (speed?: number | number[] | ((ctx: SynthContext) => number)) => SynthSource;
|
|
272
|
+
/**
|
|
273
|
+
* Generate geometric shapes (polygons).
|
|
274
|
+
* @param sides - Number of sides (default: 3)
|
|
275
|
+
* @param radius - Radius of the shape (default: 0.3)
|
|
276
|
+
* @param smoothing - Edge smoothing amount (default: 0.01)
|
|
277
|
+
*
|
|
278
|
+
* @example
|
|
279
|
+
* ```typescript
|
|
280
|
+
* const t = textmode.create({
|
|
281
|
+
* width: 800,
|
|
282
|
+
* height: 600,
|
|
283
|
+
* plugins: [SynthPlugin]
|
|
284
|
+
* });
|
|
285
|
+
*
|
|
286
|
+
* // Triangle
|
|
287
|
+
* t.layers.base.synth(
|
|
288
|
+
* shape(3)
|
|
289
|
+
* .charMap('. ')
|
|
290
|
+
* );
|
|
291
|
+
*
|
|
292
|
+
* // High-sided polygon (circle-like)
|
|
293
|
+
* t.layers.base.synth(
|
|
294
|
+
* shape(100)
|
|
295
|
+
* .charMap('. ')
|
|
296
|
+
* );
|
|
297
|
+
* ```
|
|
298
|
+
*/
|
|
299
|
+
export declare const shape: (sides?: number | number[] | ((ctx: SynthContext) => number), radius?: number | number[] | ((ctx: SynthContext) => number), smoothing?: number | number[] | ((ctx: SynthContext) => number)) => SynthSource;
|
|
300
|
+
/**
|
|
301
|
+
* Generate a solid color.
|
|
302
|
+
* @param r - Red channel (0-1, default: 0.0)
|
|
303
|
+
* @param g - Green channel (0-1, default: 0.0)
|
|
304
|
+
* @param b - Blue channel (0-1, default: 0.0)
|
|
305
|
+
* @param a - Alpha channel (0-1, default: 1.0)
|
|
306
|
+
*
|
|
307
|
+
* @example
|
|
308
|
+
* ```typescript
|
|
309
|
+
* const t = textmode.create({
|
|
310
|
+
* width: 800,
|
|
311
|
+
* height: 600,
|
|
312
|
+
* plugins: [SynthPlugin]
|
|
313
|
+
* });
|
|
314
|
+
*
|
|
315
|
+
* // Solid colors with array modulation
|
|
316
|
+
* t.layers.base.synth(
|
|
317
|
+
* solid(0.6, 0, 0, 1)
|
|
318
|
+
* .charColor(solid([1, 0, 0], [0, 1, 0], [0, 0, 1], 1))
|
|
319
|
+
* .cellColor(
|
|
320
|
+
* solid([1, 0, 0], [0, 1, 0], [0, 0, 1], 1)
|
|
321
|
+
* .invert()
|
|
322
|
+
* )
|
|
323
|
+
* );
|
|
324
|
+
* ```
|
|
325
|
+
*/
|
|
326
|
+
export declare const solid: (r?: number | number[] | ((ctx: SynthContext) => number), g?: number | number[] | ((ctx: SynthContext) => number), b?: number | number[] | ((ctx: SynthContext) => number), a?: number | number[] | ((ctx: SynthContext) => number)) => SynthSource;
|
|
327
|
+
/**
|
|
328
|
+
* Sample the previous frame's primary color output for feedback effects.
|
|
329
|
+
* This is the core of feedback loops - it reads from the previous frame's
|
|
330
|
+
* character foreground color, enabling effects like trails, motion blur,
|
|
331
|
+
* and recursive patterns.
|
|
332
|
+
*
|
|
333
|
+
* **Context-aware behavior:** When called without arguments, `src()` automatically
|
|
334
|
+
* samples the appropriate texture based on where it's used in the synth chain:
|
|
335
|
+
* - Inside `char(...)` → samples previous frame's character data
|
|
336
|
+
* - Inside `charColor(...)` → samples previous frame's primary color
|
|
337
|
+
* - Inside `cellColor(...)` → samples previous frame's cell color
|
|
338
|
+
*
|
|
339
|
+
* **Cross-layer sampling:** When called with a layer argument, `src(layer)` samples
|
|
340
|
+
* from another layer's output, enabling hydra-style multi-output compositions:
|
|
341
|
+
* - The sampled texture is still context-aware based on the current compilation target
|
|
342
|
+
*
|
|
343
|
+
* Equivalent to hydra's `src(o0)`.
|
|
344
|
+
*
|
|
345
|
+
* @param layer - Optional TextmodeLayer to sample from. If omitted, samples from self (feedback).
|
|
346
|
+
* @returns A new SynthSource that samples the specified layer or self
|
|
347
|
+
*
|
|
348
|
+
* @example
|
|
349
|
+
* ```typescript
|
|
350
|
+
* const t = textmode.create({
|
|
351
|
+
* width: 800,
|
|
352
|
+
* height: 600,
|
|
353
|
+
* plugins: [SynthPlugin]
|
|
354
|
+
* });
|
|
355
|
+
*
|
|
356
|
+
* // Classic hydra-style feedback loop with noise modulation
|
|
357
|
+
* t.layers.base.synth(
|
|
358
|
+
* src().modulate(noise(3), 0.005).blend(shape(4), 0.01)
|
|
359
|
+
* );
|
|
360
|
+
*
|
|
361
|
+
* // Cross-layer sampling (hydra-style o0, o1, etc.)
|
|
362
|
+
* const layer1 = t.layers.add();
|
|
363
|
+
* const layer2 = t.layers.add();
|
|
364
|
+
*
|
|
365
|
+
* layer1.synth(noise(10).mult(osc(20)));
|
|
366
|
+
*
|
|
367
|
+
* layer2.synth(
|
|
368
|
+
* char(voronoi(5).diff(src(layer1))) // Sample layer1's char texture
|
|
369
|
+
* .charColor(osc(10).blend(src(layer1), 0.5)) // Sample layer1's primary color
|
|
370
|
+
* );
|
|
371
|
+
*
|
|
372
|
+
* // Complex multi-layer composition
|
|
373
|
+
* t.layers.base.synth(
|
|
374
|
+
* noise(3, 0.3).thresh(0.3).diff(src(layer2), 0.3)
|
|
375
|
+
* );
|
|
376
|
+
* ```
|
|
377
|
+
*/
|
|
378
|
+
export declare const src: (layer?: {
|
|
379
|
+
id?: string;
|
|
380
|
+
}) => SynthSource;
|
|
381
|
+
export type { ModulatedArray, EasingFunction } from './lib/ArrayUtils';
|
|
382
|
+
declare module 'textmode.js' {
|
|
383
|
+
interface TextmodeLayer {
|
|
384
|
+
/**
|
|
385
|
+
* Set a synth source for this layer.
|
|
386
|
+
*
|
|
387
|
+
* The synth will render procedurally generated characters and colors
|
|
388
|
+
* directly to the layer's MRT framebuffer before the draw callback runs.
|
|
389
|
+
*
|
|
390
|
+
* @param source A SynthSource chain defining the procedural generation
|
|
391
|
+
*/
|
|
392
|
+
synth(source: SynthSource): void;
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAUH,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,YAAY,EAAwB,MAAM,cAAc,CAAC;AA0CvE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,eAAO,MAAM,IAAI,WA7CuB,WAAW,cAAc,MAAM,KAAK,WA6CpC,CAAC;AAEzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,eAAO,MAAM,SAAS,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,WAIhD,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,eAAO,MAAM,SAAS,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,WAIhD,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,eAAO,MAAM,KAAK,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,WAK5C,CAAC;AAMF,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,YAAY,EACX,kBAAkB,EAClB,mBAAmB,EACnB,YAAY,GACZ,MAAM,cAAc,CAAC;AAMtB,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAQjD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,GAAG,EAAgC,CAC/C,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,CAAC,GAAG,EAAE,YAAY,KAAK,MAAM,CAAC,EAC/D,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,CAAC,GAAG,EAAE,YAAY,KAAK,MAAM,CAAC,EAC1D,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,CAAC,GAAG,EAAE,YAAY,KAAK,MAAM,CAAC,KACxD,WAAW,CAAC;AAEjB;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,KAAK,EAAkC,CACnD,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,CAAC,GAAG,EAAE,YAAY,KAAK,MAAM,CAAC,EAC3D,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,CAAC,GAAG,EAAE,YAAY,KAAK,MAAM,CAAC,KACxD,WAAW,CAAC;AAEjB;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,OAAO,EAAoC,CACvD,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,CAAC,GAAG,EAAE,YAAY,KAAK,MAAM,CAAC,EAC3D,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,CAAC,GAAG,EAAE,YAAY,KAAK,MAAM,CAAC,EAC3D,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,CAAC,GAAG,EAAE,YAAY,KAAK,MAAM,CAAC,KAC1D,WAAW,CAAC;AAEjB;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,QAAQ,EAAqC,CACzD,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,CAAC,GAAG,EAAE,YAAY,KAAK,MAAM,CAAC,KACvD,WAAW,CAAC;AAEjB;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,KAAK,EAAkC,CACnD,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,CAAC,GAAG,EAAE,YAAY,KAAK,MAAM,CAAC,EAC3D,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,CAAC,GAAG,EAAE,YAAY,KAAK,MAAM,CAAC,EAC5D,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,CAAC,GAAG,EAAE,YAAY,KAAK,MAAM,CAAC,KAC3D,WAAW,CAAC;AAEjB;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,KAAK,EAAkC,CACnD,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,CAAC,GAAG,EAAE,YAAY,KAAK,MAAM,CAAC,EACvD,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,CAAC,GAAG,EAAE,YAAY,KAAK,MAAM,CAAC,EACvD,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,CAAC,GAAG,EAAE,YAAY,KAAK,MAAM,CAAC,EACvD,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,CAAC,GAAG,EAAE,YAAY,KAAK,MAAM,CAAC,KACnD,WAAW,CAAC;AAEjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AACH,eAAO,MAAM,GAAG,WAMuB;IAAE,EAAE,CAAC,EAAE,MAAM,CAAA;CAAE,KAAK,WAAW,AANhC,CAAC;AAiCvC,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAOvE,OAAO,QAAQ,aAAa,CAAC;IAC5B,UAAU,aAAa;QACtB;;;;;;;WAOG;QACH,KAAK,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,CAAC;KACjC;CACD"}
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ArrayUtils - Hydra-style array modulation utilities.
|
|
3
|
+
*
|
|
4
|
+
* Provides methods for arrays to modulate values over time,
|
|
5
|
+
* similar to Hydra's array functionality.
|
|
6
|
+
*/
|
|
7
|
+
import type { SynthContext } from '../core/types';
|
|
8
|
+
/**
|
|
9
|
+
* Easing functions from https://gist.github.com/gre/1650294
|
|
10
|
+
*/
|
|
11
|
+
export declare const EASING_FUNCTIONS: {
|
|
12
|
+
linear: (t: number) => number;
|
|
13
|
+
easeInQuad: (t: number) => number;
|
|
14
|
+
easeOutQuad: (t: number) => number;
|
|
15
|
+
easeInOutQuad: (t: number) => number;
|
|
16
|
+
easeInCubic: (t: number) => number;
|
|
17
|
+
easeOutCubic: (t: number) => number;
|
|
18
|
+
easeInOutCubic: (t: number) => number;
|
|
19
|
+
easeInQuart: (t: number) => number;
|
|
20
|
+
easeOutQuart: (t: number) => number;
|
|
21
|
+
easeInOutQuart: (t: number) => number;
|
|
22
|
+
easeInQuint: (t: number) => number;
|
|
23
|
+
easeOutQuint: (t: number) => number;
|
|
24
|
+
easeInOutQuint: (t: number) => number;
|
|
25
|
+
sin: (t: number) => number;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Easing functions from https://gist.github.com/gre/1650294
|
|
29
|
+
*
|
|
30
|
+
* Available easing functions: `'linear'`, `'easeInQuad'`, `'easeOutQuad'`, `'easeInOutQuad'`,
|
|
31
|
+
* `'easeInCubic'`, `'easeOutCubic'`, `'easeInOutCubic'`, `'easeInQuart'`, `'easeOutQuart'`,
|
|
32
|
+
* `'easeInOutQuart'`, `'easeInQuint'`, `'easeOutQuint'`, `'easeInOutQuint'`, `'sin'`
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```typescript
|
|
36
|
+
* const t = textmode.create({
|
|
37
|
+
* width: 800,
|
|
38
|
+
* height: 600,
|
|
39
|
+
* plugins: [SynthPlugin]
|
|
40
|
+
* });
|
|
41
|
+
*
|
|
42
|
+
* // Rotating shape with eased animation
|
|
43
|
+
* t.layers.base.synth(
|
|
44
|
+
* shape(4)
|
|
45
|
+
* .rotate([-3.14, 3.14].ease('easeInOutCubic'))
|
|
46
|
+
* );
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export type EasingFunction = keyof typeof EASING_FUNCTIONS | ((t: number) => number);
|
|
50
|
+
/**
|
|
51
|
+
* Extended array interface with modulation methods.
|
|
52
|
+
*
|
|
53
|
+
* Arrays in textmode.synth.js behave like Hydra - they cycle through values over time,
|
|
54
|
+
* creating dynamic, time-varying parameters. This enables complex animations without
|
|
55
|
+
* manually tracking time or state.
|
|
56
|
+
*/
|
|
57
|
+
export interface ModulatedArray extends Array<number> {
|
|
58
|
+
/** Speed multiplier for array cycling */
|
|
59
|
+
_speed?: number;
|
|
60
|
+
/** Smoothing amount (0-1) for interpolation */
|
|
61
|
+
_smooth?: number;
|
|
62
|
+
/** Easing function for interpolation */
|
|
63
|
+
_ease?: (t: number) => number;
|
|
64
|
+
/** Time offset for array cycling */
|
|
65
|
+
_offset?: number;
|
|
66
|
+
/**
|
|
67
|
+
* Set speed multiplier for array cycling.
|
|
68
|
+
*
|
|
69
|
+
* Controls how fast the array cycles through its values over time.
|
|
70
|
+
* A speed of 1 is the default rate. Values > 1 cycle faster, values < 1 cycle slower.
|
|
71
|
+
*
|
|
72
|
+
* @param speed - Speed multiplier (default: 1)
|
|
73
|
+
* @returns The array for chaining
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```typescript
|
|
77
|
+
* // Fast cycling through frequencies
|
|
78
|
+
* osc([1, 2, 4].fast(2), 0.1, 1.5)
|
|
79
|
+
*
|
|
80
|
+
* // Slow cycling through scroll positions
|
|
81
|
+
* shape(4).scrollX([-0.5, 0.5].fast(0.3))
|
|
82
|
+
*
|
|
83
|
+
* // Use same array for multiple parameters
|
|
84
|
+
* const speeds = [1, 3, 6].fast(2);
|
|
85
|
+
* osc(speeds, 0.1, 1.5, 16)
|
|
86
|
+
* .charColor(osc(speeds, 0.1, 1.5))
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
fast(speed: number): this;
|
|
90
|
+
/**
|
|
91
|
+
* Enable smooth interpolation between array values.
|
|
92
|
+
*
|
|
93
|
+
* Instead of jumping from one value to the next, smooth() creates gradual
|
|
94
|
+
* transitions. The amount parameter controls the smoothing duration.
|
|
95
|
+
* When amount is 1 (default), smoothing is applied across the full transition.
|
|
96
|
+
*
|
|
97
|
+
* @param amount - Smoothing amount 0-1 (default: 1)
|
|
98
|
+
* @returns The array for chaining
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* ```typescript
|
|
102
|
+
* // Smooth scrolling between positions
|
|
103
|
+
* shape(999).scrollX([-0.2, 0.2].smooth())
|
|
104
|
+
*
|
|
105
|
+
* // Gentle rotation animation
|
|
106
|
+
* shape(4).rotate([-3.14, 0, 3.14].smooth(0.8))
|
|
107
|
+
*
|
|
108
|
+
* // Smooth color transitions
|
|
109
|
+
* solid([0, 0.5, 1].smooth(), 0, 0)
|
|
110
|
+
* ```
|
|
111
|
+
*/
|
|
112
|
+
smooth(amount?: number): this;
|
|
113
|
+
/**
|
|
114
|
+
* Apply easing function to interpolation between array values.
|
|
115
|
+
*
|
|
116
|
+
* Easing controls the acceleration curve of transitions between values.
|
|
117
|
+
* Automatically enables smoothing when applied. Use built-in easing names
|
|
118
|
+
* or provide a custom function that takes a value 0-1 and returns 0-1.
|
|
119
|
+
*
|
|
120
|
+
* Available easing functions: `'linear'`, `'easeInQuad'`, `'easeOutQuad'`,
|
|
121
|
+
* `'easeInOutQuad'`, `'easeInCubic'`, `'easeOutCubic'`, `'easeInOutCubic'`,
|
|
122
|
+
* `'easeInQuart'`, `'easeOutQuart'`, `'easeInOutQuart'`, `'easeInQuint'`,
|
|
123
|
+
* `'easeOutQuint'`, `'easeInOutQuint'`, `'sin'`
|
|
124
|
+
*
|
|
125
|
+
* @param ease - Easing function name or custom function (default: 'linear')
|
|
126
|
+
* @returns The array for chaining
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
* ```typescript
|
|
130
|
+
* // Smooth rotation with cubic easing
|
|
131
|
+
* shape(4).rotate([-3.14, 3.14].ease('easeInOutCubic'))
|
|
132
|
+
*
|
|
133
|
+
* // Sine wave easing for natural motion
|
|
134
|
+
* shape(3).scale([0.5, 1.5].ease('sin'))
|
|
135
|
+
*
|
|
136
|
+
* // Custom easing function (bounce effect)
|
|
137
|
+
* const bounce = (t) => {
|
|
138
|
+
* const n1 = 7.5625;
|
|
139
|
+
* const d1 = 2.75;
|
|
140
|
+
* if (t < 1 / d1) return n1 * t * t;
|
|
141
|
+
* if (t < 2 / d1) return n1 * (t -= 1.5 / d1) * t + 0.75;
|
|
142
|
+
* if (t < 2.5 / d1) return n1 * (t -= 2.25 / d1) * t + 0.9375;
|
|
143
|
+
* return n1 * (t -= 2.625 / d1) * t + 0.984375;
|
|
144
|
+
* };
|
|
145
|
+
* shape(5).scale([0.8, 1.2].ease(bounce))
|
|
146
|
+
* ```
|
|
147
|
+
*/
|
|
148
|
+
ease(ease: EasingFunction): this;
|
|
149
|
+
/**
|
|
150
|
+
* Set time offset for array cycling.
|
|
151
|
+
*
|
|
152
|
+
* Shifts when the array starts cycling through its values.
|
|
153
|
+
* Useful for creating phase-shifted animations where multiple arrays
|
|
154
|
+
* cycle with the same speed but at different times.
|
|
155
|
+
*
|
|
156
|
+
* The offset wraps around at 1.0, so offset(0.5) starts halfway through
|
|
157
|
+
* the cycle, and offset(1.5) is equivalent to offset(0.5).
|
|
158
|
+
*
|
|
159
|
+
* @param offset - Time offset 0-1, wraps at 1.0 (default: 0)
|
|
160
|
+
* @returns The array for chaining
|
|
161
|
+
*
|
|
162
|
+
* @example
|
|
163
|
+
* ```typescript
|
|
164
|
+
* // Two shapes scrolling in opposite phase
|
|
165
|
+
* shape(999).scrollX([-0.2, 0.2])
|
|
166
|
+
* .add(shape(4).scrollX([-0.2, 0.2].offset(0.5)))
|
|
167
|
+
*
|
|
168
|
+
* // Create layered animations with phase shifts
|
|
169
|
+
* const positions = [-0.3, 0.3];
|
|
170
|
+
* shape(3).scroll(positions, positions.offset(0.25))
|
|
171
|
+
*
|
|
172
|
+
* // Three oscillators with 120° phase difference
|
|
173
|
+
* osc([5, 10].offset(0)).add(
|
|
174
|
+
* osc([5, 10].offset(0.33)), 0.5
|
|
175
|
+
* ).add(
|
|
176
|
+
* osc([5, 10].offset(0.66)), 0.5
|
|
177
|
+
* )
|
|
178
|
+
* ```
|
|
179
|
+
*/
|
|
180
|
+
offset(offset: number): this;
|
|
181
|
+
/**
|
|
182
|
+
* Fit (remap) array values to a new range.
|
|
183
|
+
*
|
|
184
|
+
* Takes the minimum and maximum values in the array and linearly maps them
|
|
185
|
+
* to the specified low and high values. All intermediate values are scaled
|
|
186
|
+
* proportionally. The original array is not modified.
|
|
187
|
+
*
|
|
188
|
+
* Preserves any modulation settings (speed, smooth, ease, offset) from the
|
|
189
|
+
* original array.
|
|
190
|
+
*
|
|
191
|
+
* @param low - New minimum value
|
|
192
|
+
* @param high - New maximum value
|
|
193
|
+
* @returns A new ModulatedArray with remapped values
|
|
194
|
+
*
|
|
195
|
+
* @example
|
|
196
|
+
* ```typescript
|
|
197
|
+
* // Remap 0-4 range to -0.2 to 0.2 for subtle scrolling
|
|
198
|
+
* shape(999).scrollX([0, 1, 2, 3, 4].fit(-0.2, 0.2))
|
|
199
|
+
*
|
|
200
|
+
* // Normalize arbitrary values to 0-1 range
|
|
201
|
+
* const values = [50, 100, 75, 125].fit(0, 1);
|
|
202
|
+
* solid(values, 0, 0)
|
|
203
|
+
*
|
|
204
|
+
* // Combine with other modulation
|
|
205
|
+
* shape(3).scale([0, 100].fit(0.5, 1.5).smooth().fast(0.5))
|
|
206
|
+
* ```
|
|
207
|
+
*/
|
|
208
|
+
fit(low: number, high: number): ModulatedArray;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Initialize array utilities by extending Array prototype.
|
|
212
|
+
* This adds Hydra-style methods to arrays.
|
|
213
|
+
*/
|
|
214
|
+
export declare function initArrayUtils(): void;
|
|
215
|
+
/**
|
|
216
|
+
* Get the current value from a modulated array based on context.
|
|
217
|
+
*/
|
|
218
|
+
export declare function getArrayValue(arr: ModulatedArray, ctx: SynthContext): number;
|
|
219
|
+
/**
|
|
220
|
+
* Check if a value is a modulated array.
|
|
221
|
+
* In Hydra, ALL number arrays are treated as time-varying sequences,
|
|
222
|
+
* even without explicit .fast() or .smooth() modulation.
|
|
223
|
+
*/
|
|
224
|
+
export declare function isModulatedArray(value: unknown): value is ModulatedArray;
|
|
225
|
+
//# sourceMappingURL=ArrayUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ArrayUtils.d.ts","sourceRoot":"","sources":["../../../src/lib/ArrayUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAElD;;GAEG;AACH,eAAO,MAAM,gBAAgB;gBAChB,MAAM;oBACF,MAAM;qBACL,MAAM;uBACJ,MAAM;qBACR,MAAM;sBACL,MAAM;wBACJ,MAAM;qBACT,MAAM;sBACL,MAAM;wBACJ,MAAM;qBACT,MAAM;sBACL,MAAM;wBACJ,MAAM;aACjB,MAAM;CACf,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,OAAO,gBAAgB,GAAG,CAAC,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC,CAAC;AAErF;;;;;;GAMG;AACH,MAAM,WAAW,cAAe,SAAQ,KAAK,CAAC,MAAM,CAAC;IACpD,yCAAyC;IACzC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,+CAA+C;IAC/C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,wCAAwC;IACxC,KAAK,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IAC9B,oCAAoC;IACpC,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAE1B;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAE9B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAkCG;IACH,IAAI,CAAC,IAAI,EAAE,cAAc,GAAG,IAAI,CAAC;IAEjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACH,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAE7B;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,cAAc,CAAC;CAC/C;AAgBD;;;GAGG;AACH,wBAAgB,cAAc,IAAI,IAAI,CAuCrC;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,cAAc,EAAE,GAAG,EAAE,YAAY,GAAG,MAAM,CAwB5E;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,cAAc,CAMxE"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transform definition types and interfaces.
|
|
3
|
+
*
|
|
4
|
+
* This module provides the base types and helper functions for defining
|
|
5
|
+
* synthesis transforms in a declarative way.
|
|
6
|
+
*/
|
|
7
|
+
import type { SynthTransformType, TransformInput } from '../core/types';
|
|
8
|
+
export type { TransformInput };
|
|
9
|
+
/**
|
|
10
|
+
* Definition of a synthesis transform function.
|
|
11
|
+
*/
|
|
12
|
+
export interface TransformDefinition {
|
|
13
|
+
/** Function name (used in JS API and GLSL) */
|
|
14
|
+
name: string;
|
|
15
|
+
/** Transform type determining composition behavior */
|
|
16
|
+
type: SynthTransformType;
|
|
17
|
+
/** Input parameters */
|
|
18
|
+
inputs: TransformInput[];
|
|
19
|
+
/** GLSL function body (without function signature) */
|
|
20
|
+
glsl: string;
|
|
21
|
+
/** Optional description for documentation */
|
|
22
|
+
description?: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* A processed transform with complete GLSL function.
|
|
26
|
+
*/
|
|
27
|
+
export interface ProcessedTransform extends TransformDefinition {
|
|
28
|
+
/** Complete GLSL function code */
|
|
29
|
+
glslFunction: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Process a transform definition into a processed transform with complete GLSL function.
|
|
33
|
+
*/
|
|
34
|
+
export declare function processTransform(def: TransformDefinition): ProcessedTransform;
|
|
35
|
+
/**
|
|
36
|
+
* Helper to define a transform with type inference.
|
|
37
|
+
* This makes transform definitions more concise and type-safe.
|
|
38
|
+
*/
|
|
39
|
+
export declare function defineTransform<T extends SynthTransformType>(definition: TransformDefinition & {
|
|
40
|
+
type: T;
|
|
41
|
+
}): TransformDefinition;
|
|
42
|
+
/**
|
|
43
|
+
* Get default values for a transform's inputs.
|
|
44
|
+
*/
|
|
45
|
+
export declare function getDefaultArgs(def: TransformDefinition): (number | number[] | null)[];
|
|
46
|
+
/**
|
|
47
|
+
* Check if a transform type requires a nested source.
|
|
48
|
+
*/
|
|
49
|
+
export declare function requiresNestedSource(type: SynthTransformType): boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Check if a transform type is a source generator.
|
|
52
|
+
*/
|
|
53
|
+
export declare function isSourceType(type: SynthTransformType): boolean;
|
|
54
|
+
//# sourceMappingURL=TransformDefinition.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TransformDefinition.d.ts","sourceRoot":"","sources":["../../../src/transforms/TransformDefinition.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACxE,YAAY,EAAE,cAAc,EAAE,CAAC;AAG/B;;GAEG;AACH,MAAM,WAAW,mBAAmB;IACnC,8CAA8C;IAC9C,IAAI,EAAE,MAAM,CAAC;IACb,sDAAsD;IACtD,IAAI,EAAE,kBAAkB,CAAC;IACzB,uBAAuB;IACvB,MAAM,EAAE,cAAc,EAAE,CAAC;IACzB,sDAAsD;IACtD,IAAI,EAAE,MAAM,CAAC;IACb,6CAA6C;IAC7C,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAmB,SAAQ,mBAAmB;IAC9D,kCAAkC;IAClC,YAAY,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,mBAAmB,GAAG,kBAAkB,CAc7E;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS,kBAAkB,EAC3D,UAAU,EAAE,mBAAmB,GAAG;IAAE,IAAI,EAAE,CAAC,CAAA;CAAE,GAC3C,mBAAmB,CAErB;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,mBAAmB,GAAG,CAAC,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI,CAAC,EAAE,CAErF;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAEtE;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAE9D"}
|