textmode.synth.js 1.5.0 → 1.5.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.
@@ -1,12 +1,12 @@
1
- const $ = { charColor: "prevCharColorBuffer", char: "prevCharBuffer", cellColor: "prevCellColorBuffer" }, P = { charColor: "_charColor", char: "_char", cellColor: "_cellColor" }, le = "src", ue = "coord", fe = "color", pe = "combine", de = "combineCoord", ee = /* @__PURE__ */ new Set(["combine", "combineCoord"]), Q = /* @__PURE__ */ new Set(["coord", "combineCoord"]), me = { [le]: { returnType: "vec4", args: [{ type: "vec2", name: "_st" }] }, [ue]: { returnType: "vec2", args: [{ type: "vec2", name: "_st" }] }, [fe]: { returnType: "vec4", args: [{ type: "vec4", name: "_c0" }] }, [pe]: { returnType: "vec4", args: [{ type: "vec4", name: "_c0" }, { type: "vec4", name: "_c1" }] }, [de]: { returnType: "vec2", args: [{ type: "vec2", name: "_st" }, { type: "vec4", name: "_c0" }] } };
2
- function he(t) {
3
- const e = me[t.type], n = [...e.args, ...t.inputs.map((o) => ({ type: o.type, name: o.name }))].map((o) => `${o.type} ${o.name}`).join(", "), r = `
1
+ const $ = { charColor: "prevCharColorBuffer", char: "prevCharBuffer", cellColor: "prevCellColorBuffer" }, P = { charColor: "_charColor", char: "_char", cellColor: "_cellColor" }, ue = "src", fe = "coord", de = "color", pe = "combine", me = "combineCoord", ee = /* @__PURE__ */ new Set(["combine", "combineCoord"]), Q = /* @__PURE__ */ new Set(["coord", "combineCoord"]), he = { [ue]: { returnType: "vec4", args: [{ type: "vec2", name: "_st" }] }, [fe]: { returnType: "vec2", args: [{ type: "vec2", name: "_st" }] }, [de]: { returnType: "vec4", args: [{ type: "vec4", name: "_c0" }] }, [pe]: { returnType: "vec4", args: [{ type: "vec4", name: "_c0" }, { type: "vec4", name: "_c1" }] }, [me]: { returnType: "vec2", args: [{ type: "vec2", name: "_st" }, { type: "vec4", name: "_c0" }] } };
2
+ function ye(t) {
3
+ const e = he[t.type], n = [...e.args, ...t.inputs.map((o) => ({ type: o.type, name: o.name }))].map((o) => `${o.type} ${o.name}`).join(", "), r = `
4
4
  ${e.returnType} ${t.name}(${n}) {
5
5
  ${t.glsl}
6
6
  }`;
7
7
  return { ...t, glslFunction: r };
8
8
  }
9
- class ye {
9
+ class ge {
10
10
  _transforms = /* @__PURE__ */ new Map();
11
11
  _processedCache = /* @__PURE__ */ new Map();
12
12
  register(e) {
@@ -22,7 +22,7 @@ class ye {
22
22
  let n = this._processedCache.get(e);
23
23
  if (!n) {
24
24
  const r = this._transforms.get(e);
25
- r && (n = he(r), this._processedCache.set(e, n));
25
+ r && (n = ye(r), this._processedCache.set(e, n));
26
26
  }
27
27
  return n;
28
28
  }
@@ -51,8 +51,8 @@ class ye {
51
51
  return this._transforms.size;
52
52
  }
53
53
  }
54
- const U = new ye(), W = /* @__PURE__ */ new Set(["src"]);
55
- class ge {
54
+ const U = new ge(), W = /* @__PURE__ */ new Set(["src"]);
55
+ class _e {
56
56
  _generatedFunctions = {};
57
57
  _synthSourceClass = null;
58
58
  setSynthSourceClass(e) {
@@ -64,18 +64,18 @@ class ge {
64
64
  }
65
65
  _injectMethod(e, n) {
66
66
  const r = this._synthSourceClass, { name: o, inputs: a, type: i } = n, u = e;
67
- if (ee.has(i)) u[o] = function(p, ...d) {
68
- let s = p;
69
- if (r && !(p instanceof r)) {
70
- const c = new r(), l = typeof p == "number" ? [p, p, p, null] : [p, null, null, null];
67
+ if (ee.has(i)) u[o] = function(d, ...p) {
68
+ let s = d;
69
+ if (r && !(d instanceof r)) {
70
+ const c = new r(), l = typeof d == "number" ? [d, d, d, null] : [d, null, null, null];
71
71
  c.addTransform("solid", l), s = c;
72
72
  }
73
- return this.addCombineTransform(o, s, O(a, d));
73
+ return this.addCombineTransform(o, s, O(a, p));
74
74
  };
75
75
  else {
76
- const p = this;
77
- u[o] = function(...d) {
78
- return d = p._expandColorArgs(o, d), this.addTransform(o, O(a, d));
76
+ const d = this;
77
+ u[o] = function(...p) {
78
+ return p = d._expandColorArgs(o, p), this.addTransform(o, O(a, p));
79
79
  };
80
80
  }
81
81
  }
@@ -92,8 +92,8 @@ class ge {
92
92
  for (const o of n) if (W.has(o.type)) {
93
93
  const { name: a, inputs: i } = o;
94
94
  e[a] = (...u) => {
95
- const p = new r();
96
- return u = this._expandColorArgs(a, u), p.addTransform(a, O(i, u));
95
+ const d = new r();
96
+ return u = this._expandColorArgs(a, u), d.addTransform(a, O(i, u));
97
97
  };
98
98
  }
99
99
  return this._generatedFunctions = e, e;
@@ -114,15 +114,15 @@ class ge {
114
114
  function O(t, e) {
115
115
  return t.map((n, r) => e[r] ?? n.default);
116
116
  }
117
- const V = new ge(), _e = { name: "osc", type: "src", inputs: [{ name: "frequency", type: "float", default: 60 }, { name: "sync", type: "float", default: 0.1 }, { name: "offset", type: "float", default: 0 }], glsl: `
117
+ const V = new _e(), ve = { name: "osc", type: "src", inputs: [{ name: "frequency", type: "float", default: 60 }, { name: "sync", type: "float", default: 0.1 }, { name: "offset", type: "float", default: 0 }], glsl: `
118
118
  vec2 st = _st;
119
119
  float r = sin((st.x - offset/frequency + time*sync) * frequency) * 0.5 + 0.5;
120
120
  float g = sin((st.x + time*sync) * frequency) * 0.5 + 0.5;
121
121
  float b = sin((st.x + offset/frequency + time*sync) * frequency) * 0.5 + 0.5;
122
122
  return vec4(r, g, b, 1.0);
123
- `, description: "Generate oscillating color pattern" }, ve = { name: "noise", type: "src", inputs: [{ name: "scale", type: "float", default: 10 }, { name: "offset", type: "float", default: 0.1 }], glsl: `
123
+ `, description: "Generate oscillating color pattern" }, xe = { name: "noise", type: "src", inputs: [{ name: "scale", type: "float", default: 10 }, { name: "offset", type: "float", default: 0.1 }], glsl: `
124
124
  return vec4(vec3(_noise(vec3(_st * scale, offset * time))), 1.0);
125
- `, description: "Generate noise pattern" }, xe = { name: "plasma", type: "src", inputs: [{ name: "scale", type: "float", default: 10 }, { name: "speed", type: "float", default: 0.5 }, { name: "phase", type: "float", default: 0 }, { name: "contrast", type: "float", default: 1 }], glsl: `
125
+ `, description: "Generate noise pattern" }, Ce = { name: "plasma", type: "src", inputs: [{ name: "scale", type: "float", default: 10 }, { name: "speed", type: "float", default: 0.5 }, { name: "phase", type: "float", default: 0 }, { name: "contrast", type: "float", default: 1 }], glsl: `
126
126
  float t = time * speed + phase;
127
127
  float v = 0.0;
128
128
  v += sin((_st.x * scale) + t);
@@ -132,7 +132,7 @@ const V = new ge(), _e = { name: "osc", type: "src", inputs: [{ name: "frequency
132
132
  v = v * 0.5 + 0.5;
133
133
  v = clamp((v - 0.5) * contrast + 0.5, 0.0, 1.0);
134
134
  return vec4(vec3(v), 1.0);
135
- `, description: "Generate plasma-like sine field" }, Ce = { name: "moire", type: "src", inputs: [{ name: "freqA", type: "float", default: 20 }, { name: "freqB", type: "float", default: 21 }, { name: "angleA", type: "float", default: 0 }, { name: "angleB", type: "float", default: 1.5708 }, { name: "speed", type: "float", default: 0.1 }, { name: "phase", type: "float", default: 0 }], glsl: `
135
+ `, description: "Generate plasma-like sine field" }, be = { name: "moire", type: "src", inputs: [{ name: "freqA", type: "float", default: 20 }, { name: "freqB", type: "float", default: 21 }, { name: "angleA", type: "float", default: 0 }, { name: "angleB", type: "float", default: 1.5708 }, { name: "speed", type: "float", default: 0.1 }, { name: "phase", type: "float", default: 0 }], glsl: `
136
136
  float t = time * speed + phase;
137
137
  vec2 p = _st - vec2(0.5);
138
138
  vec2 dirA = vec2(cos(angleA), sin(angleA));
@@ -142,7 +142,7 @@ const V = new ge(), _e = { name: "osc", type: "src", inputs: [{ name: "frequency
142
142
  float v = a * b;
143
143
  v = v * 0.5 + 0.5;
144
144
  return vec4(vec3(v), 1.0);
145
- `, description: "Generate moire interference patterns" }, be = { name: "voronoi", type: "src", inputs: [{ name: "scale", type: "float", default: 5 }, { name: "speed", type: "float", default: 0.3 }, { name: "blending", type: "float", default: 0.3 }], glsl: `
145
+ `, description: "Generate moire interference patterns" }, Se = { name: "voronoi", type: "src", inputs: [{ name: "scale", type: "float", default: 5 }, { name: "speed", type: "float", default: 0.3 }, { name: "blending", type: "float", default: 0.3 }], glsl: `
146
146
  vec3 color = vec3(0.0);
147
147
  vec2 st = _st * scale;
148
148
  vec2 i_st = floor(st);
@@ -169,22 +169,22 @@ const V = new ge(), _e = { name: "osc", type: "src", inputs: [{ name: "frequency
169
169
  color += dot(m_point, vec2(0.3, 0.6));
170
170
  color *= 1.0 - blending * m_dist;
171
171
  return vec4(color, 1.0);
172
- `, description: "Generate voronoi pattern" }, Se = { name: "gradient", type: "src", inputs: [{ name: "speed", type: "float", default: 0 }], glsl: `
172
+ `, description: "Generate voronoi pattern" }, we = { name: "gradient", type: "src", inputs: [{ name: "speed", type: "float", default: 0 }], glsl: `
173
173
  return vec4(_st, sin(time * speed), 1.0);
174
- `, description: "Generate gradient pattern" }, we = { name: "shape", type: "src", inputs: [{ name: "sides", type: "float", default: 3 }, { name: "radius", type: "float", default: 0.3 }, { name: "smoothing", type: "float", default: 0.01 }], glsl: `
174
+ `, description: "Generate gradient pattern" }, $e = { name: "shape", type: "src", inputs: [{ name: "sides", type: "float", default: 3 }, { name: "radius", type: "float", default: 0.3 }, { name: "smoothing", type: "float", default: 0.01 }], glsl: `
175
175
  vec2 st = _st * 2.0 - 1.0;
176
176
  float a = atan(st.x, st.y) + 3.1416;
177
177
  float r = (2.0 * 3.1416) / sides;
178
178
  float d = cos(floor(0.5 + a/r) * r - a) * length(st);
179
179
  return vec4(vec3(1.0 - smoothstep(radius, radius + smoothing + 0.0000001, d)), 1.0);
180
- `, description: "Generate polygon shape" }, $e = { name: "solid", type: "src", inputs: [{ name: "r", type: "float", default: 0 }, { name: "g", type: "float", default: 0 }, { name: "b", type: "float", default: 0 }, { name: "a", type: "float", default: 1 }], glsl: `
180
+ `, description: "Generate polygon shape" }, Me = { name: "solid", type: "src", inputs: [{ name: "r", type: "float", default: 0 }, { name: "g", type: "float", default: 0 }, { name: "b", type: "float", default: 0 }, { name: "a", type: "float", default: 1 }], glsl: `
181
181
  return vec4(r, g, b, a);
182
- `, description: "Generate solid color" }, Me = { name: "src", type: "src", inputs: [], glsl: `
182
+ `, description: "Generate solid color" }, Te = { name: "src", type: "src", inputs: [], glsl: `
183
183
  return texture(${$.charColor}, fract(_st));
184
- `, description: "Sample the previous frame for feedback effects. Context-aware: automatically samples the appropriate texture based on where it is used (char, charColor, or cellColor context)." }, Te = { name: "srcTexture", type: "src", inputs: [], glsl: `
184
+ `, description: "Sample the previous frame for feedback effects. Context-aware: automatically samples the appropriate texture based on where it is used (char, charColor, or cellColor context)." }, Fe = { name: "srcTexture", type: "src", inputs: [], glsl: `
185
185
  // Placeholder - actual texture sampling is handled dynamically per TextmodeSource
186
186
  return texture(u_textmodeSource0, fract(_st));
187
- `, description: "Sample from a TextmodeSource (image/video). Context-aware: the actual sampler uniform is determined at compile time based on the source reference." }, Fe = [_e, ve, xe, Ce, be, Se, we, $e, Me, Te];
187
+ `, description: "Sample from a TextmodeSource (image/video). Context-aware: the actual sampler uniform is determined at compile time based on the source reference." }, Ie = [ve, xe, Ce, be, Se, we, $e, Me, Te, Fe];
188
188
  function te(t) {
189
189
  const e = t === "x" ? "scrollX" : "scrollY";
190
190
  return { name: e, type: "coord", inputs: [{ name: e, type: "float", default: 0.5 }, { name: "speed", type: "float", default: 0 }], glsl: `
@@ -200,31 +200,31 @@ function ne(t) {
200
200
  return fract(st);
201
201
  `, description: "Repeat pattern " + (t === "x" ? "horizontally" : "vertically") };
202
202
  }
203
- const Ie = { name: "rotate", type: "coord", inputs: [{ name: "angle", type: "float", default: 10 }, { name: "speed", type: "float", default: 0 }], glsl: `
203
+ const Pe = { name: "rotate", type: "coord", inputs: [{ name: "angle", type: "float", default: 10 }, { name: "speed", type: "float", default: 0 }], glsl: `
204
204
  vec2 xy = _st - vec2(0.5);
205
205
  float ang = angle + speed * time;
206
206
  xy = mat2(cos(ang), -sin(ang), sin(ang), cos(ang)) * xy;
207
207
  xy += 0.5;
208
208
  return xy;
209
- `, description: "Rotate coordinates" }, Pe = { name: "scale", type: "coord", inputs: [{ name: "amount", type: "float", default: 1.5 }, { name: "xMult", type: "float", default: 1 }, { name: "yMult", type: "float", default: 1 }, { name: "offsetX", type: "float", default: 0.5 }, { name: "offsetY", type: "float", default: 0.5 }], glsl: `
209
+ `, description: "Rotate coordinates" }, Re = { name: "scale", type: "coord", inputs: [{ name: "amount", type: "float", default: 1.5 }, { name: "xMult", type: "float", default: 1 }, { name: "yMult", type: "float", default: 1 }, { name: "offsetX", type: "float", default: 0.5 }, { name: "offsetY", type: "float", default: 0.5 }], glsl: `
210
210
  vec2 xy = _st - vec2(offsetX, offsetY);
211
211
  xy *= (1.0 / vec2(amount * xMult, amount * yMult));
212
212
  xy += vec2(offsetX, offsetY);
213
213
  return xy;
214
- `, description: "Scale coordinates" }, Re = { name: "scroll", type: "coord", inputs: [{ name: "scrollX", type: "float", default: 0.5 }, { name: "scrollY", type: "float", default: 0.5 }, { name: "speedX", type: "float", default: 0 }, { name: "speedY", type: "float", default: 0 }], glsl: `
214
+ `, description: "Scale coordinates" }, ke = { name: "scroll", type: "coord", inputs: [{ name: "scrollX", type: "float", default: 0.5 }, { name: "scrollY", type: "float", default: 0.5 }, { name: "speedX", type: "float", default: 0 }, { name: "speedY", type: "float", default: 0 }], glsl: `
215
215
  vec2 st = _st;
216
216
  st.x += scrollX + time * speedX;
217
217
  st.y += scrollY + time * speedY;
218
218
  return fract(st);
219
- `, description: "Scroll coordinates" }, ke = te("x"), Ae = te("y"), Le = { name: "pixelate", type: "coord", inputs: [{ name: "pixelX", type: "float", default: 20 }, { name: "pixelY", type: "float", default: 20 }], glsl: `
219
+ `, description: "Scroll coordinates" }, Ae = te("x"), Le = te("y"), Ue = { name: "pixelate", type: "coord", inputs: [{ name: "pixelX", type: "float", default: 20 }, { name: "pixelY", type: "float", default: 20 }], glsl: `
220
220
  vec2 xy = vec2(pixelX, pixelY);
221
221
  return (floor(_st * xy) + 0.5) / xy;
222
- `, description: "Pixelate coordinates" }, Ue = { name: "repeat", type: "coord", inputs: [{ name: "repeatX", type: "float", default: 3 }, { name: "repeatY", type: "float", default: 3 }, { name: "offsetX", type: "float", default: 0 }, { name: "offsetY", type: "float", default: 0 }], glsl: `
222
+ `, description: "Pixelate coordinates" }, Oe = { name: "repeat", type: "coord", inputs: [{ name: "repeatX", type: "float", default: 3 }, { name: "repeatY", type: "float", default: 3 }, { name: "offsetX", type: "float", default: 0 }, { name: "offsetY", type: "float", default: 0 }], glsl: `
223
223
  vec2 st = _st * vec2(repeatX, repeatY);
224
224
  st.x += step(1.0, mod(st.y, 2.0)) * offsetX;
225
225
  st.y += step(1.0, mod(st.x, 2.0)) * offsetY;
226
226
  return fract(st);
227
- `, description: "Repeat pattern" }, Oe = ne("x"), Ne = ne("y"), De = { name: "kaleid", type: "coord", inputs: [{ name: "nSides", type: "float", default: 4 }], glsl: `
227
+ `, description: "Repeat pattern" }, Ne = ne("x"), De = ne("y"), Ee = { name: "kaleid", type: "coord", inputs: [{ name: "nSides", type: "float", default: 4 }], glsl: `
228
228
  vec2 st = _st;
229
229
  st -= 0.5;
230
230
  float r = length(st);
@@ -239,7 +239,7 @@ const Ie = { name: "rotate", type: "coord", inputs: [{ name: "angle", type: "flo
239
239
  float a = atan(st.y, st.x) + angle;
240
240
  a = a / (2.0 * 3.1416);
241
241
  return vec2(fract(a), r);
242
- `, description: "Convert to polar coordinates" }, Ee = { name: "twirl", type: "coord", inputs: [{ name: "amount", type: "float", default: 2 }, { name: "radius", type: "float", default: 0.5 }, { name: "centerX", type: "float", default: 0.5 }, { name: "centerY", type: "float", default: 0.5 }], glsl: `
242
+ `, description: "Convert to polar coordinates" }, Ye = { name: "twirl", type: "coord", inputs: [{ name: "amount", type: "float", default: 2 }, { name: "radius", type: "float", default: 0.5 }, { name: "centerX", type: "float", default: 0.5 }, { name: "centerY", type: "float", default: 0.5 }], glsl: `
243
243
  vec2 center = vec2(centerX, centerY);
244
244
  vec2 p = _st - center;
245
245
  float r = length(p);
@@ -250,7 +250,7 @@ const Ie = { name: "rotate", type: "coord", inputs: [{ name: "angle", type: "flo
250
250
  float c = cos(angle);
251
251
  p = vec2(c * p.x - s * p.y, s * p.x + c * p.y);
252
252
  return p + center;
253
- `, description: "Twirl distortion with radial falloff" }, Ye = { name: "swirl", type: "coord", inputs: [{ name: "amount", type: "float", default: 4 }, { name: "centerX", type: "float", default: 0.5 }, { name: "centerY", type: "float", default: 0.5 }], glsl: `
253
+ `, description: "Twirl distortion with radial falloff" }, Be = { name: "swirl", type: "coord", inputs: [{ name: "amount", type: "float", default: 4 }, { name: "centerX", type: "float", default: 0.5 }, { name: "centerY", type: "float", default: 0.5 }], glsl: `
254
254
  vec2 center = vec2(centerX, centerY);
255
255
  vec2 p = _st - center;
256
256
  float r = length(p);
@@ -259,28 +259,28 @@ const Ie = { name: "rotate", type: "coord", inputs: [{ name: "angle", type: "flo
259
259
  float c = cos(angle);
260
260
  p = vec2(c * p.x - s * p.y, s * p.x + c * p.y);
261
261
  return p + center;
262
- `, description: "Swirl distortion around a center" }, Be = { name: "mirror", type: "coord", inputs: [{ name: "mirrorX", type: "float", default: 1 }, { name: "mirrorY", type: "float", default: 1 }], glsl: `
262
+ `, description: "Swirl distortion around a center" }, Xe = { name: "mirror", type: "coord", inputs: [{ name: "mirrorX", type: "float", default: 1 }, { name: "mirrorY", type: "float", default: 1 }], glsl: `
263
263
  vec2 m = abs(fract(_st * 2.0) - 1.0);
264
264
  vec2 mixAmt = clamp(vec2(mirrorX, mirrorY), 0.0, 1.0);
265
265
  return mix(_st, m, mixAmt);
266
- `, description: "Mirror coordinates across X and/or Y axes" }, Xe = { name: "shear", type: "coord", inputs: [{ name: "x", type: "float", default: 0 }, { name: "y", type: "float", default: 0 }, { name: "centerX", type: "float", default: 0.5 }, { name: "centerY", type: "float", default: 0.5 }], glsl: `
266
+ `, description: "Mirror coordinates across X and/or Y axes" }, Ve = { name: "shear", type: "coord", inputs: [{ name: "x", type: "float", default: 0 }, { name: "y", type: "float", default: 0 }, { name: "centerX", type: "float", default: 0.5 }, { name: "centerY", type: "float", default: 0.5 }], glsl: `
267
267
  vec2 center = vec2(centerX, centerY);
268
268
  vec2 p = _st - center;
269
269
  p = vec2(p.x + y * p.y, p.y + x * p.x);
270
270
  return p + center;
271
- `, description: "Shear coordinates along X and Y" }, Ve = { name: "barrel", type: "coord", inputs: [{ name: "amount", type: "float", default: 0.5 }, { name: "centerX", type: "float", default: 0.5 }, { name: "centerY", type: "float", default: 0.5 }], glsl: `
271
+ `, description: "Shear coordinates along X and Y" }, je = { name: "barrel", type: "coord", inputs: [{ name: "amount", type: "float", default: 0.5 }, { name: "centerX", type: "float", default: 0.5 }, { name: "centerY", type: "float", default: 0.5 }], glsl: `
272
272
  vec2 center = vec2(centerX, centerY);
273
273
  vec2 p = _st - center;
274
274
  float r2 = dot(p, p);
275
275
  p *= 1.0 + amount * r2;
276
276
  return p + center;
277
- `, description: "Barrel distortion (bulge outward)" }, je = { name: "pinch", type: "coord", inputs: [{ name: "amount", type: "float", default: 0.5 }, { name: "centerX", type: "float", default: 0.5 }, { name: "centerY", type: "float", default: 0.5 }], glsl: `
277
+ `, description: "Barrel distortion (bulge outward)" }, qe = { name: "pinch", type: "coord", inputs: [{ name: "amount", type: "float", default: 0.5 }, { name: "centerX", type: "float", default: 0.5 }, { name: "centerY", type: "float", default: 0.5 }], glsl: `
278
278
  vec2 center = vec2(centerX, centerY);
279
279
  vec2 p = _st - center;
280
280
  float r2 = dot(p, p);
281
281
  p *= 1.0 / (1.0 + amount * r2);
282
282
  return p + center;
283
- `, description: "Pinch distortion (pull inward)" }, qe = { name: "fisheye", type: "coord", inputs: [{ name: "amount", type: "float", default: 1 }, { name: "centerX", type: "float", default: 0.5 }, { name: "centerY", type: "float", default: 0.5 }], glsl: `
283
+ `, description: "Pinch distortion (pull inward)" }, Ge = { name: "fisheye", type: "coord", inputs: [{ name: "amount", type: "float", default: 1 }, { name: "centerX", type: "float", default: 0.5 }, { name: "centerY", type: "float", default: 0.5 }], glsl: `
284
284
  vec2 center = vec2(centerX, centerY);
285
285
  vec2 p = _st - center;
286
286
  float r = length(p);
@@ -290,118 +290,118 @@ const Ie = { name: "rotate", type: "coord", inputs: [{ name: "angle", type: "flo
290
290
  p = p / r * r2;
291
291
  }
292
292
  return p + center;
293
- `, description: "Fisheye lens distortion" }, Ge = [Ie, Pe, Re, ke, Ae, Le, Ue, Oe, Ne, De, ze, Ee, Ye, Be, Xe, Ve, je, qe], He = [{ name: "scale", type: "float", default: 1 }, { name: "offset", type: "float", default: 0 }];
293
+ `, description: "Fisheye lens distortion" }, He = [Pe, Re, ke, Ae, Le, Ue, Oe, Ne, De, Ee, ze, Ye, Be, Xe, Ve, je, qe, Ge], Ke = [{ name: "scale", type: "float", default: 1 }, { name: "offset", type: "float", default: 0 }];
294
294
  function G(t) {
295
- return { name: t, type: "color", inputs: He, glsl: `
295
+ return { name: t, type: "color", inputs: Ke, glsl: `
296
296
  return vec4(_c0.${t} * scale + offset);
297
297
  `, description: `Extract ${t === "r" ? "red" : t === "g" ? "green" : "blue"} channel` };
298
298
  }
299
- const Ke = { name: "brightness", type: "color", inputs: [{ name: "amount", type: "float", default: 0.4 }], glsl: `
299
+ const Qe = { name: "brightness", type: "color", inputs: [{ name: "amount", type: "float", default: 0.4 }], glsl: `
300
300
  return vec4(_c0.rgb + vec3(amount), _c0.a);
301
- `, description: "Adjust brightness" }, Qe = { name: "contrast", type: "color", inputs: [{ name: "amount", type: "float", default: 1.6 }], glsl: `
301
+ `, description: "Adjust brightness" }, We = { name: "contrast", type: "color", inputs: [{ name: "amount", type: "float", default: 1.6 }], glsl: `
302
302
  vec4 c = (_c0 - vec4(0.5)) * vec4(amount) + vec4(0.5);
303
303
  return vec4(c.rgb, _c0.a);
304
- `, description: "Adjust contrast" }, We = { name: "invert", type: "color", inputs: [{ name: "amount", type: "float", default: 1 }], glsl: `
304
+ `, description: "Adjust contrast" }, Je = { name: "invert", type: "color", inputs: [{ name: "amount", type: "float", default: 1 }], glsl: `
305
305
  return vec4((1.0 - _c0.rgb) * amount + _c0.rgb * (1.0 - amount), _c0.a);
306
- `, description: "Invert colors" }, Je = { name: "saturate", type: "color", inputs: [{ name: "amount", type: "float", default: 2 }], glsl: `
306
+ `, description: "Invert colors" }, Ze = { name: "saturate", type: "color", inputs: [{ name: "amount", type: "float", default: 2 }], glsl: `
307
307
  vec3 intensity = vec3(_luminance(_c0.rgb));
308
308
  return vec4(mix(intensity, _c0.rgb, amount), _c0.a);
309
- `, description: "Adjust saturation" }, Ze = { name: "hue", type: "color", inputs: [{ name: "hue", type: "float", default: 0.4 }], glsl: `
309
+ `, description: "Adjust saturation" }, et = { name: "hue", type: "color", inputs: [{ name: "hue", type: "float", default: 0.4 }], glsl: `
310
310
  vec3 c = _rgbToHsv(_c0.rgb);
311
311
  c.r += hue;
312
312
  return vec4(_hsvToRgb(c), _c0.a);
313
- `, description: "Shift hue" }, et = { name: "colorama", type: "color", inputs: [{ name: "amount", type: "float", default: 5e-3 }], glsl: `
313
+ `, description: "Shift hue" }, tt = { name: "colorama", type: "color", inputs: [{ name: "amount", type: "float", default: 5e-3 }], glsl: `
314
314
  vec3 c = _rgbToHsv(_c0.rgb);
315
315
  c += vec3(amount);
316
316
  c = _hsvToRgb(c);
317
317
  c = fract(c);
318
318
  return vec4(c, _c0.a);
319
- `, description: "Color cycle effect" }, tt = { name: "posterize", type: "color", inputs: [{ name: "bins", type: "float", default: 3 }, { name: "gamma", type: "float", default: 0.6 }], glsl: `
319
+ `, description: "Color cycle effect" }, nt = { name: "posterize", type: "color", inputs: [{ name: "bins", type: "float", default: 3 }, { name: "gamma", type: "float", default: 0.6 }], glsl: `
320
320
  vec4 c2 = pow(_c0, vec4(gamma));
321
321
  c2 *= vec4(bins);
322
322
  c2 = floor(c2);
323
323
  c2 /= vec4(bins);
324
324
  c2 = pow(c2, vec4(1.0 / gamma));
325
325
  return vec4(c2.xyz, _c0.a);
326
- `, description: "Posterize colors" }, nt = { name: "luma", type: "color", inputs: [{ name: "threshold", type: "float", default: 0.5 }, { name: "tolerance", type: "float", default: 0.1 }], glsl: `
326
+ `, description: "Posterize colors" }, rt = { name: "luma", type: "color", inputs: [{ name: "threshold", type: "float", default: 0.5 }, { name: "tolerance", type: "float", default: 0.1 }], glsl: `
327
327
  float a = _smoothThreshold(_luminance(_c0.rgb), threshold, tolerance);
328
328
  return vec4(_c0.rgb * a, a);
329
- `, description: "Luma key" }, rt = { name: "thresh", type: "color", inputs: [{ name: "threshold", type: "float", default: 0.5 }, { name: "tolerance", type: "float", default: 0.04 }], glsl: `
329
+ `, description: "Luma key" }, ot = { name: "thresh", type: "color", inputs: [{ name: "threshold", type: "float", default: 0.5 }, { name: "tolerance", type: "float", default: 0.04 }], glsl: `
330
330
  return vec4(vec3(_smoothThreshold(_luminance(_c0.rgb), threshold, tolerance)), _c0.a);
331
- `, description: "Threshold" }, ot = { name: "color", type: "color", inputs: [{ name: "r", type: "float", default: 1 }, { name: "g", type: "float", default: 1 }, { name: "b", type: "float", default: 1 }, { name: "a", type: "float", default: 1 }], glsl: `
331
+ `, description: "Threshold" }, at = { name: "color", type: "color", inputs: [{ name: "r", type: "float", default: 1 }, { name: "g", type: "float", default: 1 }, { name: "b", type: "float", default: 1 }, { name: "a", type: "float", default: 1 }], glsl: `
332
332
  vec4 c = vec4(r, g, b, a);
333
333
  vec4 pos = step(0.0, c);
334
334
  return vec4(mix((1.0 - _c0.rgb) * abs(c.rgb), c.rgb * _c0.rgb, pos.rgb), c.a * _c0.a);
335
- `, description: "Multiply by color" }, at = G("r"), st = G("g"), ct = G("b"), it = { name: "shift", type: "color", inputs: [{ name: "r", type: "float", default: 0.5 }, { name: "g", type: "float", default: 0 }, { name: "b", type: "float", default: 0 }, { name: "a", type: "float", default: 0 }], glsl: `
335
+ `, description: "Multiply by color" }, st = G("r"), ct = G("g"), it = G("b"), lt = { name: "shift", type: "color", inputs: [{ name: "r", type: "float", default: 0.5 }, { name: "g", type: "float", default: 0 }, { name: "b", type: "float", default: 0 }, { name: "a", type: "float", default: 0 }], glsl: `
336
336
  vec4 c2 = vec4(_c0);
337
337
  c2.r += fract(r);
338
338
  c2.g += fract(g);
339
339
  c2.b += fract(b);
340
340
  c2.a += fract(a);
341
341
  return vec4(c2.rgba);
342
- `, description: "Shift color channels by adding offset values" }, lt = { name: "gamma", type: "color", inputs: [{ name: "amount", type: "float", default: 1 }], glsl: `
342
+ `, description: "Shift color channels by adding offset values" }, ut = { name: "gamma", type: "color", inputs: [{ name: "amount", type: "float", default: 1 }], glsl: `
343
343
  return vec4(pow(max(vec3(0.0), _c0.rgb), vec3(1.0 / amount)), _c0.a);
344
- `, description: "Apply gamma correction" }, ut = { name: "levels", type: "color", inputs: [{ name: "inMin", type: "float", default: 0 }, { name: "inMax", type: "float", default: 1 }, { name: "outMin", type: "float", default: 0 }, { name: "outMax", type: "float", default: 1 }, { name: "gamma", type: "float", default: 1 }], glsl: `
344
+ `, description: "Apply gamma correction" }, ft = { name: "levels", type: "color", inputs: [{ name: "inMin", type: "float", default: 0 }, { name: "inMax", type: "float", default: 1 }, { name: "outMin", type: "float", default: 0 }, { name: "outMax", type: "float", default: 1 }, { name: "gamma", type: "float", default: 1 }], glsl: `
345
345
  vec3 v = clamp((_c0.rgb - vec3(inMin)) / (vec3(inMax - inMin) + 0.0000001), 0.0, 1.0);
346
346
  v = pow(v, vec3(1.0 / gamma));
347
347
  v = mix(vec3(outMin), vec3(outMax), v);
348
348
  return vec4(v, _c0.a);
349
- `, description: "Adjust input/output levels and gamma" }, ft = { name: "clamp", type: "color", inputs: [{ name: "min", type: "float", default: 0 }, { name: "max", type: "float", default: 1 }], glsl: `
349
+ `, description: "Adjust input/output levels and gamma" }, dt = { name: "clamp", type: "color", inputs: [{ name: "min", type: "float", default: 0 }, { name: "max", type: "float", default: 1 }], glsl: `
350
350
  return vec4(clamp(_c0.rgb, vec3(min), vec3(max)), _c0.a);
351
351
  `, description: "Clamp color values to a range" }, pt = { name: "seed", type: "color", inputs: [{ name: "value", type: "float", default: 0 }], glsl: `
352
352
  // Set seed for subsequent noise/voronoi calls in this chain
353
353
  _seed = value;
354
354
  return _c0;
355
- `, description: "Set seed for deterministic randomness in subsequent noise operations" }, dt = [Ke, Qe, We, Je, Ze, et, tt, nt, rt, ot, at, st, ct, it, lt, ut, ft, pt], M = `
355
+ `, description: "Set seed for deterministic randomness in subsequent noise operations" }, mt = [Qe, We, Je, Ze, et, tt, nt, rt, ot, at, st, ct, it, lt, ut, ft, dt, pt], M = `
356
356
  vec3 outRgb = mix(_c0.rgb, result, amount);
357
357
  float outA = mix(_c0.a, _c1.a, amount);
358
358
  return vec4(outRgb, outA);
359
- `, mt = { name: "add", type: "combine", inputs: [{ name: "amount", type: "float", default: 1 }], glsl: `
359
+ `, ht = { name: "add", type: "combine", inputs: [{ name: "amount", type: "float", default: 1 }], glsl: `
360
360
  return (_c0 + _c1) * amount + _c0 * (1.0 - amount);
361
- `, description: "Add another source" }, ht = { name: "sub", type: "combine", inputs: [{ name: "amount", type: "float", default: 1 }], glsl: `
361
+ `, description: "Add another source" }, yt = { name: "sub", type: "combine", inputs: [{ name: "amount", type: "float", default: 1 }], glsl: `
362
362
  return (_c0 - _c1) * amount + _c0 * (1.0 - amount);
363
- `, description: "Subtract another source" }, yt = { name: "mult", type: "combine", inputs: [{ name: "amount", type: "float", default: 1 }], glsl: `
363
+ `, description: "Subtract another source" }, gt = { name: "mult", type: "combine", inputs: [{ name: "amount", type: "float", default: 1 }], glsl: `
364
364
  return _c0 * (1.0 - amount) + (_c0 * _c1) * amount;
365
- `, description: "Multiply with another source" }, gt = { name: "blend", type: "combine", inputs: [{ name: "amount", type: "float", default: 0.5 }], glsl: `
365
+ `, description: "Multiply with another source" }, _t = { name: "blend", type: "combine", inputs: [{ name: "amount", type: "float", default: 0.5 }], glsl: `
366
366
  return _c0 * (1.0 - amount) + _c1 * amount;
367
- `, description: "Blend with another source" }, _t = { name: "diff", type: "combine", inputs: [], glsl: `
367
+ `, description: "Blend with another source" }, vt = { name: "diff", type: "combine", inputs: [], glsl: `
368
368
  return vec4(abs(_c0.rgb - _c1.rgb), max(_c0.a, _c1.a));
369
- `, description: "Difference with another source" }, vt = { name: "layer", type: "combine", inputs: [], glsl: `
369
+ `, description: "Difference with another source" }, xt = { name: "layer", type: "combine", inputs: [], glsl: `
370
370
  return vec4(mix(_c0.rgb, _c1.rgb, _c1.a), clamp(_c0.a + _c1.a, 0.0, 1.0));
371
- `, description: "Layer another source on top" }, xt = { name: "mask", type: "combine", inputs: [], glsl: `
371
+ `, description: "Layer another source on top" }, Ct = { name: "mask", type: "combine", inputs: [], glsl: `
372
372
  float a = _luminance(_c1.rgb);
373
373
  return vec4(_c0.rgb * a, a * _c0.a);
374
- `, description: "Mask with another source" }, Ct = { name: "screen", type: "combine", inputs: [{ name: "amount", type: "float", default: 1 }], glsl: `
374
+ `, description: "Mask with another source" }, bt = { name: "screen", type: "combine", inputs: [{ name: "amount", type: "float", default: 1 }], glsl: `
375
375
  vec3 result = 1.0 - (1.0 - _c0.rgb) * (1.0 - _c1.rgb);
376
376
  ${M}
377
- `, description: "Screen blend with another source" }, bt = { name: "overlay", type: "combine", inputs: [{ name: "amount", type: "float", default: 1 }], glsl: `
377
+ `, description: "Screen blend with another source" }, St = { name: "overlay", type: "combine", inputs: [{ name: "amount", type: "float", default: 1 }], glsl: `
378
378
  vec3 mult = 2.0 * _c0.rgb * _c1.rgb;
379
379
  vec3 screen = 1.0 - 2.0 * (1.0 - _c0.rgb) * (1.0 - _c1.rgb);
380
380
  vec3 result = mix(mult, screen, step(0.5, _c0.rgb));
381
381
  ${M}
382
- `, description: "Overlay blend with another source" }, St = { name: "softlight", type: "combine", inputs: [{ name: "amount", type: "float", default: 1 }], glsl: `
382
+ `, description: "Overlay blend with another source" }, wt = { name: "softlight", type: "combine", inputs: [{ name: "amount", type: "float", default: 1 }], glsl: `
383
383
  vec3 result = (1.0 - 2.0 * _c1.rgb) * _c0.rgb * _c0.rgb + 2.0 * _c1.rgb * _c0.rgb;
384
384
  ${M}
385
- `, description: "Soft light blend with another source" }, wt = { name: "hardlight", type: "combine", inputs: [{ name: "amount", type: "float", default: 1 }], glsl: `
385
+ `, description: "Soft light blend with another source" }, $t = { name: "hardlight", type: "combine", inputs: [{ name: "amount", type: "float", default: 1 }], glsl: `
386
386
  vec3 mult = 2.0 * _c0.rgb * _c1.rgb;
387
387
  vec3 screen = 1.0 - 2.0 * (1.0 - _c0.rgb) * (1.0 - _c1.rgb);
388
388
  vec3 result = mix(mult, screen, step(0.5, _c1.rgb));
389
389
  ${M}
390
- `, description: "Hard light blend with another source" }, $t = { name: "dodge", type: "combine", inputs: [{ name: "amount", type: "float", default: 1 }], glsl: `
390
+ `, description: "Hard light blend with another source" }, Mt = { name: "dodge", type: "combine", inputs: [{ name: "amount", type: "float", default: 1 }], glsl: `
391
391
  vec3 result = _c0.rgb / max(vec3(0.00001), 1.0 - _c1.rgb);
392
392
  result = clamp(result, 0.0, 1.0);
393
393
  ${M}
394
- `, description: "Color dodge blend with another source" }, Mt = { name: "burn", type: "combine", inputs: [{ name: "amount", type: "float", default: 1 }], glsl: `
394
+ `, description: "Color dodge blend with another source" }, Tt = { name: "burn", type: "combine", inputs: [{ name: "amount", type: "float", default: 1 }], glsl: `
395
395
  vec3 result = 1.0 - (1.0 - _c0.rgb) / max(vec3(0.00001), _c1.rgb);
396
396
  result = clamp(result, 0.0, 1.0);
397
397
  ${M}
398
- `, description: "Color burn blend with another source" }, Tt = { name: "lighten", type: "combine", inputs: [{ name: "amount", type: "float", default: 1 }], glsl: `
398
+ `, description: "Color burn blend with another source" }, Ft = { name: "lighten", type: "combine", inputs: [{ name: "amount", type: "float", default: 1 }], glsl: `
399
399
  vec3 result = max(_c0.rgb, _c1.rgb);
400
400
  ${M}
401
- `, description: "Lighten blend with another source" }, Ft = { name: "darken", type: "combine", inputs: [{ name: "amount", type: "float", default: 1 }], glsl: `
401
+ `, description: "Lighten blend with another source" }, It = { name: "darken", type: "combine", inputs: [{ name: "amount", type: "float", default: 1 }], glsl: `
402
402
  vec3 result = min(_c0.rgb, _c1.rgb);
403
403
  ${M}
404
- `, description: "Darken blend with another source" }, It = [mt, ht, yt, gt, _t, vt, xt, Ct, bt, St, wt, $t, Mt, Tt, Ft];
404
+ `, description: "Darken blend with another source" }, Pt = [ht, yt, gt, _t, vt, xt, Ct, bt, St, wt, $t, Mt, Tt, Ft, It];
405
405
  function re(t) {
406
406
  const e = t === "x" ? "scrollX" : "scrollY";
407
407
  return { name: t === "x" ? "modulateScrollX" : "modulateScrollY", type: "combineCoord", inputs: [{ name: e, type: "float", default: 0.5 }, { name: "speed", type: "float", default: 0 }], glsl: `
@@ -417,23 +417,23 @@ function oe(t) {
417
417
  return fract(st);
418
418
  `, description: `Modulate ${t.toUpperCase()} repeat with another source` };
419
419
  }
420
- const Pt = { name: "modulate", type: "combineCoord", inputs: [{ name: "amount", type: "float", default: 0.1 }], glsl: `
420
+ const Rt = { name: "modulate", type: "combineCoord", inputs: [{ name: "amount", type: "float", default: 0.1 }], glsl: `
421
421
  return _st + _c0.xy * amount;
422
- `, description: "Modulate coordinates with another source" }, Rt = { name: "modulateScale", type: "combineCoord", inputs: [{ name: "multiple", type: "float", default: 1 }, { name: "offset", type: "float", default: 1 }], glsl: `
422
+ `, description: "Modulate coordinates with another source" }, kt = { name: "modulateScale", type: "combineCoord", inputs: [{ name: "multiple", type: "float", default: 1 }, { name: "offset", type: "float", default: 1 }], glsl: `
423
423
  vec2 xy = _st - vec2(0.5);
424
424
  xy *= (1.0 / vec2(offset + multiple * _c0.r, offset + multiple * _c0.g));
425
425
  xy += vec2(0.5);
426
426
  return xy;
427
- `, description: "Modulate scale with another source" }, kt = { name: "modulateRotate", type: "combineCoord", inputs: [{ name: "multiple", type: "float", default: 1 }, { name: "offset", type: "float", default: 0 }], glsl: `
427
+ `, description: "Modulate scale with another source" }, At = { name: "modulateRotate", type: "combineCoord", inputs: [{ name: "multiple", type: "float", default: 1 }, { name: "offset", type: "float", default: 0 }], glsl: `
428
428
  vec2 xy = _st - vec2(0.5);
429
429
  float angle = offset + _c0.x * multiple;
430
430
  xy = mat2(cos(angle), -sin(angle), sin(angle), cos(angle)) * xy;
431
431
  xy += 0.5;
432
432
  return xy;
433
- `, description: "Modulate rotation with another source" }, At = { name: "modulatePixelate", type: "combineCoord", inputs: [{ name: "multiple", type: "float", default: 10 }, { name: "offset", type: "float", default: 3 }], glsl: `
433
+ `, description: "Modulate rotation with another source" }, Lt = { name: "modulatePixelate", type: "combineCoord", inputs: [{ name: "multiple", type: "float", default: 10 }, { name: "offset", type: "float", default: 3 }], glsl: `
434
434
  vec2 xy = vec2(offset + _c0.x * multiple, offset + _c0.y * multiple);
435
435
  return (floor(_st * xy) + 0.5) / xy;
436
- `, description: "Modulate pixelation with another source" }, Lt = { name: "modulateKaleid", type: "combineCoord", inputs: [{ name: "nSides", type: "float", default: 4 }], glsl: `
436
+ `, description: "Modulate pixelation with another source" }, Ut = { name: "modulateKaleid", type: "combineCoord", inputs: [{ name: "nSides", type: "float", default: 4 }], glsl: `
437
437
  vec2 st = _st - 0.5;
438
438
  float r = length(st);
439
439
  float a = atan(st.y, st.x);
@@ -441,14 +441,14 @@ const Pt = { name: "modulate", type: "combineCoord", inputs: [{ name: "amount",
441
441
  a = mod(a, pi / nSides);
442
442
  a = abs(a - pi / nSides / 2.0);
443
443
  return (_c0.r + r) * vec2(cos(a), sin(a));
444
- `, description: "Modulate kaleidoscope with another source" }, Ut = re("x"), Ot = re("y"), Nt = { name: "modulateRepeat", type: "combineCoord", inputs: [{ name: "repeatX", type: "float", default: 3 }, { name: "repeatY", type: "float", default: 3 }, { name: "offsetX", type: "float", default: 0.5 }, { name: "offsetY", type: "float", default: 0.5 }], glsl: `
444
+ `, description: "Modulate kaleidoscope with another source" }, Ot = re("x"), Nt = re("y"), Dt = { name: "modulateRepeat", type: "combineCoord", inputs: [{ name: "repeatX", type: "float", default: 3 }, { name: "repeatY", type: "float", default: 3 }, { name: "offsetX", type: "float", default: 0.5 }, { name: "offsetY", type: "float", default: 0.5 }], glsl: `
445
445
  vec2 st = _st * vec2(repeatX, repeatY);
446
446
  st.x += step(1.0, mod(st.y, 2.0)) + _c0.r * offsetX;
447
447
  st.y += step(1.0, mod(st.x, 2.0)) + _c0.g * offsetY;
448
448
  return fract(st);
449
- `, description: "Modulate repeat pattern with another source" }, Dt = oe("x"), zt = oe("y"), Et = { name: "modulateHue", type: "combineCoord", inputs: [{ name: "amount", type: "float", default: 1 }], glsl: `
449
+ `, description: "Modulate repeat pattern with another source" }, Et = oe("x"), zt = oe("y"), Yt = { name: "modulateHue", type: "combineCoord", inputs: [{ name: "amount", type: "float", default: 1 }], glsl: `
450
450
  return _st + (vec2(_c0.g - _c0.r, _c0.b - _c0.g) * amount * 1.0 / u_resolution);
451
- `, description: "Modulate coordinates based on hue differences" }, Yt = [Pt, Rt, kt, At, Lt, Ut, Ot, Nt, Dt, zt, Et], Bt = [...Fe, ...Ge, ...dt, ...It, ...Yt];
451
+ `, description: "Modulate coordinates based on hue differences" }, Bt = [Rt, kt, At, Lt, Ut, Ot, Nt, Dt, Et, zt, Yt], Xt = [...Ie, ...He, ...mt, ...Pt, ...Bt];
452
452
  class A {
453
453
  _transforms;
454
454
  constructor(e) {
@@ -572,10 +572,10 @@ const j = { linear: (t) => t, easeInQuad: (t) => t * t, easeOutQuad: (t) => t *
572
572
  function J(t, e) {
573
573
  return (t % e + e) % e;
574
574
  }
575
- function Xt(t, e, n, r, o) {
575
+ function Vt(t, e, n, r, o) {
576
576
  return e === n ? (r + o) / 2 : (t - e) * (o - r) / (n - e) + r;
577
577
  }
578
- function Vt() {
578
+ function jt() {
579
579
  "fast" in Array.prototype || (Object.defineProperty(Array.prototype, "fast", { value: function(t = 1) {
580
580
  return this._speed = t, this;
581
581
  }, writable: !0, configurable: !0, enumerable: !1 }), Object.defineProperty(Array.prototype, "smooth", { value: function(t = 1) {
@@ -585,23 +585,23 @@ function Vt() {
585
585
  }, writable: !0, configurable: !0, enumerable: !1 }), Object.defineProperty(Array.prototype, "offset", { value: function(t = 0.5) {
586
586
  return this._offset = t % 1, this;
587
587
  }, writable: !0, configurable: !0, enumerable: !1 }), Object.defineProperty(Array.prototype, "fit", { value: function(t = 0, e = 1) {
588
- const n = Math.min(...this), r = Math.max(...this), o = this.map((a) => Xt(a, n, r, t, e));
588
+ const n = Math.min(...this), r = Math.max(...this), o = this.map((a) => Vt(a, n, r, t, e));
589
589
  return o._speed = this._speed, o._smooth = this._smooth, o._ease = this._ease, o._offset = this._offset, o;
590
590
  }, writable: !0, configurable: !0, enumerable: !1 }));
591
591
  }
592
- function jt(t, e) {
592
+ function qt(t, e) {
593
593
  const n = t._speed ?? 1, r = t._smooth ?? 0;
594
594
  let o = e.time * n * (e.bpm / 60) + (t._offset ?? 0);
595
595
  if (r !== 0) {
596
- const a = t._ease ?? j.linear, i = o - r / 2, u = Math.floor(i), p = J(u, t.length), d = (p + 1) % t.length, s = t[p], c = t[d];
596
+ const a = t._ease ?? j.linear, i = o - r / 2, u = Math.floor(i), d = J(u, t.length), p = (d + 1) % t.length, s = t[d], c = t[p];
597
597
  return a(Math.min((i - u) / r, 1)) * (c - s) + s;
598
598
  }
599
599
  return t[Math.floor(J(o, t.length))];
600
600
  }
601
- function qt(t) {
601
+ function Gt(t) {
602
602
  return Array.isArray(t) && t.length > 0 && typeof t[0] == "number";
603
603
  }
604
- Vt(), U.registerMany(Bt), V.setSynthSourceClass(v), V.injectMethods(v.prototype);
604
+ jt(), U.registerMany(Xt), V.setSynthSourceClass(v), V.injectMethods(v.prototype);
605
605
  const w = V.generateStandaloneFunctions(), b = "textmode.synth.js";
606
606
  function q(t) {
607
607
  return t === "char" || t === "cellColor" ? t : "charColor";
@@ -610,7 +610,7 @@ function ae(t, e) {
610
610
  const n = q(e);
611
611
  n === "char" ? t.usesChar = !0 : n === "cellColor" ? t.usesCellColor = !0 : t.usesCharColor = !0;
612
612
  }
613
- class Gt {
613
+ class Ht {
614
614
  _usage = { usesChar: !1, usesCharColor: !1, usesCellColor: !1 };
615
615
  trackUsage(e) {
616
616
  ae(this._usage, e);
@@ -634,7 +634,7 @@ class Gt {
634
634
  return this._usage.usesCellColor;
635
635
  }
636
636
  }
637
- class Ht {
637
+ class Kt {
638
638
  _externalLayers = /* @__PURE__ */ new Map();
639
639
  _counter = 0;
640
640
  _layerIdToPrefix = /* @__PURE__ */ new Map();
@@ -666,7 +666,7 @@ class Ht {
666
666
  this._externalLayers.clear(), this._counter = 0, this._layerIdToPrefix.clear();
667
667
  }
668
668
  }
669
- class Kt {
669
+ class Qt {
670
670
  _sources = /* @__PURE__ */ new Map();
671
671
  _counter = 0;
672
672
  reset() {
@@ -696,16 +696,16 @@ class Kt {
696
696
  return this._sources.size > 0;
697
697
  }
698
698
  }
699
- class Qt {
699
+ class Wt {
700
700
  getContextAwareGlslFunction(e, n, r, o, a, i, u) {
701
701
  return n === "srcTexture" && a && u ? this._generateTextmodeSourceFunction(a, r, u) : n !== "src" ? e.glslFunction : o && i ? this._generateExternalSrcFunction(o, r, i) : this._generateSelfFeedbackSrcFunction(r);
702
702
  }
703
703
  getFunctionName(e, n, r, o, a, i) {
704
704
  return e.name === "srcTexture" && o && i ? `srcTexture_${i(o.sourceId)}_${n}` : e.name !== "src" ? e.name : r && a ? `src_ext_${a(r.layerId)}_${n}` : `src_${n}`;
705
705
  }
706
- generateTransformCode(e, n, r, o, a, i, u, p, d, s, c, l, m, g, S) {
707
- const f = this.getFunctionName(n, s, l, m, g, S), y = (...h) => [...h, ...d].join(", ");
708
- let x = a, T = i, C = u, L = p;
706
+ generateTransformCode(e, n, r, o, a, i, u, d, p, s, c, l, m, g, S) {
707
+ const f = this.getFunctionName(n, s, l, m, g, S), y = (...h) => [...h, ...p].join(", ");
708
+ let x = a, T = i, C = u, L = d;
709
709
  switch (n.type) {
710
710
  case "src": {
711
711
  const h = `c${r}`;
@@ -783,7 +783,7 @@ vec4 ${`srcTexture_${o}_${n}`}(vec2 _st) {
783
783
  }
784
784
  }
785
785
  let se = null;
786
- function vn(t) {
786
+ function Jt(t) {
787
787
  se = t;
788
788
  }
789
789
  function Z(t, e, n) {
@@ -806,10 +806,10 @@ function ce(t) {
806
806
  }
807
807
  return String(t);
808
808
  }
809
- function Wt(t) {
809
+ function Zt(t) {
810
810
  return t != null && (typeof t == "number" ? Number.isFinite(t) : !!Array.isArray(t) && t.length > 0 && t.every((e) => typeof e == "number" && Number.isFinite(e)));
811
811
  }
812
- function Jt(t, e, n) {
812
+ function en(t, e, n) {
813
813
  return (r) => {
814
814
  let o;
815
815
  try {
@@ -817,17 +817,17 @@ function Jt(t, e, n) {
817
817
  } catch (a) {
818
818
  return Z(a, e, r.onError), n;
819
819
  }
820
- return Wt(o) ? o : (Z(new Error(`[textmode.synth.js] Invalid dynamic parameter value for "${e}": ${ce(o)}`), e, r.onError), n);
820
+ return Zt(o) ? o : (Z(new Error(`[textmode.synth.js] Invalid dynamic parameter value for "${e}": ${ce(o)}`), e, r.onError), n);
821
821
  };
822
822
  }
823
- class Zt {
823
+ class tn {
824
824
  _uniforms = /* @__PURE__ */ new Map();
825
825
  _dynamicUpdaters = /* @__PURE__ */ new Map();
826
826
  processArgument(e, n, r) {
827
- return qt(e) ? this._createDynamicUniform(n, r, (o) => jt(e, o)) : typeof e == "function" ? this._createDynamicUniform(n, r, e) : typeof e == "number" ? { glslValue: Y(e) } : this.processDefault(n);
827
+ return Gt(e) ? this._createDynamicUniform(n, r, (o) => qt(e, o)) : typeof e == "function" ? this._createDynamicUniform(n, r, e) : typeof e == "number" ? { glslValue: Y(e) } : this.processDefault(n);
828
828
  }
829
829
  _createDynamicUniform(e, n, r) {
830
- const o = `${n}_${e.name}`, a = { name: o, type: e.type, value: e.default ?? 0, isDynamic: !0 }, i = Jt(r, o, a.value);
830
+ const o = `${n}_${e.name}`, a = { name: o, type: e.type, value: e.default ?? 0, isDynamic: !0 }, i = en(r, o, a.value);
831
831
  return this._uniforms.set(o, a), this._dynamicUpdaters.set(o, i), { glslValue: o, uniform: a, updater: i };
832
832
  }
833
833
  processDefault(e) {
@@ -847,7 +847,7 @@ class Zt {
847
847
  function Y(t) {
848
848
  return Number.isInteger(t) ? t.toString() + ".0" : t.toString();
849
849
  }
850
- const en = `
850
+ const nn = `
851
851
  // Global mutable seed variable - can be modified by seed() transform
852
852
  // Initialized from u_seed uniform in main()
853
853
  float _seed = 0.0;
@@ -969,8 +969,8 @@ int _unpackChar(vec4 c) {
969
969
  return int(c.r * 255.0 + c.g * 255.0 * 256.0);
970
970
  }
971
971
  `;
972
- function tn(t) {
973
- const { uniforms: e, glslFunctions: n, mainCode: r, charOutputCode: o, primaryColorVar: a, cellColorVar: i, charMapping: u, usesFeedback: p, usesCharFeedback: d, usesCellColorFeedback: s, usesCharSource: c, externalLayers: l, textmodeSources: m } = t, g = Array.from(e.values()).map((_) => `uniform ${_.type} ${_.name};`).join(`
972
+ function rn(t) {
973
+ const { uniforms: e, glslFunctions: n, mainCode: r, charOutputCode: o, primaryColorVar: a, cellColorVar: i, charMapping: u, usesFeedback: d, usesCharFeedback: p, usesCellColorFeedback: s, usesCharSource: c, externalLayers: l, textmodeSources: m } = t, g = Array.from(e.values()).map((_) => `uniform ${_.type} ${_.name};`).join(`
974
974
  `);
975
975
  let S = "", f = "";
976
976
  u && (S = `uniform int u_charMap[${u.indices.length}];
@@ -980,7 +980,7 @@ uniform int u_charMapSize;`, f = `
980
980
  int mappedCharIdx = u_charMap[int(mod(float(rawCharIdx), float(u_charMapSize)))];
981
981
  charOutput = _packChar(mappedCharIdx);`);
982
982
  const y = [];
983
- p && y.push(`uniform sampler2D ${$.charColor};`), d && y.push(`uniform sampler2D ${$.char};`), s && y.push(`uniform sampler2D ${$.cellColor};`);
983
+ d && y.push(`uniform sampler2D ${$.charColor};`), p && y.push(`uniform sampler2D ${$.char};`), s && y.push(`uniform sampler2D ${$.cellColor};`);
984
984
  const x = y.join(`
985
985
  `), T = c ? "uniform float u_charSourceCount;" : "", C = [];
986
986
  if (l) for (const [, _] of l) _.usesChar && C.push(`uniform sampler2D ${_.uniformPrefix}${P.char};`), _.usesCharColor && C.push(`uniform sampler2D ${_.uniformPrefix}${P.charColor};`), _.usesCellColor && C.push(`uniform sampler2D ${_.uniformPrefix}${P.cellColor};`);
@@ -1014,7 +1014,7 @@ ${T}
1014
1014
  // Dynamic uniforms
1015
1015
  ${g}
1016
1016
 
1017
- ${en}
1017
+ ${nn}
1018
1018
 
1019
1019
  // Transform functions
1020
1020
  ${Array.from(n).join(`
@@ -1038,7 +1038,7 @@ ${f}
1038
1038
  }
1039
1039
  `;
1040
1040
  }
1041
- function nn(t, e, n) {
1041
+ function on(t, e, n) {
1042
1042
  return t ? `
1043
1043
  // Character output from generator
1044
1044
  vec4 charOutput = ${e};` : `
@@ -1048,14 +1048,14 @@ function nn(t, e, n) {
1048
1048
  vec4 charOutput = _packChar(charIdx);`;
1049
1049
  }
1050
1050
  function D(t) {
1051
- return new rn().compile(t);
1052
- }
1053
- class rn {
1054
- _uniformManager = new Zt();
1055
- _feedbackTracker = new Gt();
1056
- _externalLayerManager = new Ht();
1057
- _textmodeSourceManager = new Kt();
1058
- _codeGenerator = new Qt();
1051
+ return new an().compile(t);
1052
+ }
1053
+ class an {
1054
+ _uniformManager = new tn();
1055
+ _feedbackTracker = new Ht();
1056
+ _externalLayerManager = new Kt();
1057
+ _textmodeSourceManager = new Qt();
1058
+ _codeGenerator = new Wt();
1059
1059
  _glslFunctions = /* @__PURE__ */ new Set();
1060
1060
  _mainCode = [];
1061
1061
  _varCounter = 0;
@@ -1070,8 +1070,8 @@ class rn {
1070
1070
  e.charColorSource && (o = this._compileChain(e.charColorSource, "charColor", "vec4(1.0, 1.0, 1.0, 1.0)", "v_uv", "charColor").colorVar);
1071
1071
  let a = "vec4(0.0, 0.0, 0.0, 0.0)";
1072
1072
  e.cellColorSource && (a = this._compileChain(e.cellColorSource, "cellColor", "vec4(0.0, 0.0, 0.0, 0.0)", "v_uv", "cellColor").colorVar);
1073
- const i = nn(!!r, r ?? "vec4(0.0)", n.colorVar), u = this._feedbackTracker.getUsage();
1074
- return { fragmentSource: tn({ uniforms: this._uniformManager.getUniforms(), glslFunctions: this._glslFunctions, mainCode: this._mainCode, charOutputCode: i, primaryColorVar: o, cellColorVar: a, charMapping: e.charMapping, usesFeedback: u.usesCharColorFeedback, usesCharFeedback: u.usesCharFeedback, usesCellColorFeedback: u.usesCellColorFeedback, usesCharSource: this._usesCharSource, externalLayers: this._externalLayerManager.getExternalLayers(), textmodeSources: this._textmodeSourceManager.getSources() }), uniforms: this._uniformManager.getUniforms(), dynamicUpdaters: this._uniformManager.getDynamicUpdaters(), charMapping: e.charMapping, usesCharColorFeedback: u.usesCharColorFeedback, usesCharFeedback: u.usesCharFeedback, usesCellColorFeedback: u.usesCellColorFeedback, usesCharSource: this._usesCharSource, externalLayers: this._externalLayerManager.getExternalLayers(), textmodeSources: this._textmodeSourceManager.getSources() };
1073
+ const i = on(!!r, r ?? "vec4(0.0)", n.colorVar), u = this._feedbackTracker.getUsage();
1074
+ return { fragmentSource: rn({ uniforms: this._uniformManager.getUniforms(), glslFunctions: this._glslFunctions, mainCode: this._mainCode, charOutputCode: i, primaryColorVar: o, cellColorVar: a, charMapping: e.charMapping, usesFeedback: u.usesCharColorFeedback, usesCharFeedback: u.usesCharFeedback, usesCellColorFeedback: u.usesCellColorFeedback, usesCharSource: this._usesCharSource, externalLayers: this._externalLayerManager.getExternalLayers(), textmodeSources: this._textmodeSourceManager.getSources() }), uniforms: this._uniformManager.getUniforms(), dynamicUpdaters: this._uniformManager.getDynamicUpdaters(), charMapping: e.charMapping, usesCharColorFeedback: u.usesCharColorFeedback, usesCharFeedback: u.usesCharFeedback, usesCellColorFeedback: u.usesCellColorFeedback, usesCharSource: this._usesCharSource, externalLayers: this._externalLayerManager.getExternalLayers(), textmodeSources: this._textmodeSourceManager.getSources() };
1075
1075
  }
1076
1076
  _reset() {
1077
1077
  this._varCounter = 0, this._uniformManager.clear(), this._feedbackTracker.reset(), this._externalLayerManager.reset(), this._textmodeSourceManager.reset(), this._glslFunctions.clear(), this._mainCode.length = 0, this._currentTarget = "main", this._usesCharSource = !1;
@@ -1085,7 +1085,7 @@ class rn {
1085
1085
  const i = this._currentTarget;
1086
1086
  this._currentTarget = a;
1087
1087
  const u = `${n}_st`;
1088
- let p, d, s, c = `${n}_c`;
1088
+ let d, p, s, c = `${n}_c`;
1089
1089
  this._mainCode.push(` vec2 ${u} = ${o};`), this._mainCode.push(` vec4 ${c} = ${r};`);
1090
1090
  const l = e.transforms, m = l.map((f) => this._getProcessedTransform(f.name)), g = this._identifyCoordTransforms(m), S = (f) => {
1091
1091
  const y = l[f], x = m[f];
@@ -1097,8 +1097,8 @@ class rn {
1097
1097
  const h = this._processArguments(y.userArgs, x.inputs, `${n}_${f}_${y.name}`), _ = e.nestedSources.get(f);
1098
1098
  let K;
1099
1099
  _ && ee.has(x.type) && (K = this._compileChain(_, `${n}_nested_${f}`, r, u, a).colorVar);
1100
- const F = this._codeGenerator.generateTransformCode(this._mainCode, x, this._varCounter++, u, c, p, d, s, h, this._currentTarget, K, T, C, (I) => this._externalLayerManager.getPrefix(I), (I) => this._textmodeSourceManager.getUniformName(I));
1101
- c = F.colorVar, F.charVar && (p = F.charVar), F.flagsVar && (d = F.flagsVar), F.rotationVar && (s = F.rotationVar);
1100
+ const F = this._codeGenerator.generateTransformCode(this._mainCode, x, this._varCounter++, u, c, d, p, s, h, this._currentTarget, K, T, C, (I) => this._externalLayerManager.getPrefix(I), (I) => this._textmodeSourceManager.getUniformName(I));
1101
+ c = F.colorVar, F.charVar && (d = F.charVar), F.flagsVar && (p = F.flagsVar), F.rotationVar && (s = F.rotationVar);
1102
1102
  };
1103
1103
  for (let f = 0; f < l.length; f++)
1104
1104
  m[f] && l[f].name === "seed" && S(f);
@@ -1107,7 +1107,7 @@ class rn {
1107
1107
  const y = m[f];
1108
1108
  y && Q.has(y.type) || l[f].name !== "seed" && S(f);
1109
1109
  }
1110
- return this._currentTarget = i, { coordVar: u, colorVar: c, charVar: p, flagsVar: d, rotationVar: s };
1110
+ return this._currentTarget = i, { coordVar: u, colorVar: c, charVar: d, flagsVar: p, rotationVar: s };
1111
1111
  }
1112
1112
  _identifyCoordTransforms(e) {
1113
1113
  const n = [];
@@ -1126,33 +1126,33 @@ class rn {
1126
1126
  _processArguments(e, n, r) {
1127
1127
  const o = [];
1128
1128
  for (let a = 0; a < n.length; a++) {
1129
- const i = n[a], u = e[a] ?? i.default, p = this._uniformManager.processArgument(u, i, r);
1130
- o.push(p.glslValue);
1129
+ const i = n[a], u = e[a] ?? i.default, d = this._uniformManager.processArgument(u, i, r);
1130
+ o.push(d.glslValue);
1131
1131
  }
1132
1132
  return o;
1133
1133
  }
1134
1134
  }
1135
- class z {
1135
+ class E {
1136
1136
  static _fontIndexCache = /* @__PURE__ */ new WeakMap();
1137
1137
  _resolvedIndices;
1138
1138
  _lastFont;
1139
1139
  _lastChars = "";
1140
1140
  resolve(e, n) {
1141
1141
  if (this._resolvedIndices && this._lastFont === n && this._lastChars === e) return this._resolvedIndices;
1142
- let r = z._fontIndexCache.get(n);
1142
+ let r = E._fontIndexCache.get(n);
1143
1143
  if (!r) {
1144
1144
  r = /* @__PURE__ */ new Map();
1145
- const d = n.characters;
1146
- for (let s = 0; s < d.length; s++) r.set(d[s], s);
1147
- z._fontIndexCache.set(n, r);
1145
+ const p = n.characters;
1146
+ for (let s = 0; s < p.length; s++) r.set(p[s], s);
1147
+ E._fontIndexCache.set(n, r);
1148
1148
  }
1149
- const o = Array.from(e), a = new Int32Array(o.length), i = n.characterMap, u = i.get(" "), p = u && r.has(u) ? r.get(u) : 0;
1150
- for (let d = 0; d < o.length; d++) {
1151
- const s = o[d], c = i.get(s);
1149
+ const o = Array.from(e), a = new Int32Array(o.length), i = n.characterMap, u = i.get(" "), d = u && r.has(u) ? r.get(u) : 0;
1150
+ for (let p = 0; p < o.length; p++) {
1151
+ const s = o[p], c = i.get(s);
1152
1152
  if (c) {
1153
1153
  const l = r.get(c);
1154
- a[d] = l !== void 0 ? l : p;
1155
- } else a[d] = p;
1154
+ a[p] = l !== void 0 ? l : d;
1155
+ } else a[p] = d;
1156
1156
  }
1157
1157
  return this._resolvedIndices = a, this._lastFont = n, this._lastChars = e, a;
1158
1158
  }
@@ -1161,9 +1161,9 @@ class z {
1161
1161
  }
1162
1162
  }
1163
1163
  function ie(t = {}) {
1164
- return { source: t.source ?? new v(), sourceFactory: t.sourceFactory, compiled: t.compiled, shader: t.shader, characterResolver: t.characterResolver ?? new z(), needsCompile: t.needsCompile ?? !1, isCompiling: t.isCompiling ?? !1, pingPongBuffers: t.pingPongBuffers, pingPongDimensions: t.pingPongDimensions, pingPongIndex: t.pingPongIndex ?? 0, externalLayerMap: t.externalLayerMap, bpm: t.bpm, dynamicValues: t.dynamicValues ?? /* @__PURE__ */ new Map(), synthContext: t.synthContext ?? { time: 0, frameCount: 0, width: 0, height: 0, cols: 0, rows: 0, bpm: 0 }, isDisposed: !1 };
1164
+ return { source: t.source ?? new v(), sourceFactory: t.sourceFactory, compiled: t.compiled, shader: t.shader, characterResolver: t.characterResolver ?? new E(), needsCompile: t.needsCompile ?? !1, isCompiling: t.isCompiling ?? !1, pingPongBuffers: t.pingPongBuffers, pingPongDimensions: t.pingPongDimensions, pingPongIndex: t.pingPongIndex ?? 0, externalLayerMap: t.externalLayerMap, bpm: t.bpm, dynamicValues: t.dynamicValues ?? /* @__PURE__ */ new Map(), synthContext: t.synthContext ?? { time: 0, frameCount: 0, width: 0, height: 0, cols: 0, rows: 0, bpm: 0 }, isDisposed: !1 };
1165
1165
  }
1166
- function on(t) {
1166
+ function sn(t) {
1167
1167
  t.extendLayer("synth", function(e) {
1168
1168
  const n = this.grid !== void 0 && this.drawFramebuffer !== void 0;
1169
1169
  let r, o;
@@ -1172,37 +1172,37 @@ function on(t) {
1172
1172
  a ? (a.source = r, a.sourceFactory = o, a.needsCompile = !0, a.characterResolver.invalidate(), n && !o && (a.compiled = D(r))) : a = ie({ source: r, sourceFactory: o, compiled: n && !o ? D(r) : void 0, needsCompile: !0 }), this.setPluginState(b, a);
1173
1173
  });
1174
1174
  }
1175
- function an(t) {
1175
+ function cn(t) {
1176
1176
  t.extendLayer("clearSynth", function() {
1177
1177
  const e = this.getPluginState(b);
1178
1178
  e && (e.shader?.dispose && e.shader.dispose(), e.pingPongBuffers && (e.pingPongBuffers[0].dispose?.(), e.pingPongBuffers[1].dispose?.()), this.setPluginState(b, void 0));
1179
1179
  });
1180
1180
  }
1181
- function sn(t) {
1181
+ function ln(t) {
1182
1182
  t.extendLayer("bpm", function(e) {
1183
1183
  let n = this.getPluginState(b);
1184
1184
  n ? n.bpm = e : n = ie({ bpm: e }), this.setPluginState(b, n);
1185
1185
  });
1186
1186
  }
1187
1187
  const B = /* @__PURE__ */ Symbol.for("textmode.synth.state");
1188
- function E(t) {
1188
+ function z(t) {
1189
1189
  const e = t;
1190
1190
  return e[B] || (e[B] = { bpm: 60, seed: null }), e[B];
1191
1191
  }
1192
- function cn(t) {
1193
- return E(t).bpm;
1192
+ function un(t) {
1193
+ return z(t).bpm;
1194
1194
  }
1195
- function ln(t) {
1196
- return E(t).seed;
1195
+ function fn(t) {
1196
+ return z(t).seed;
1197
1197
  }
1198
- function un(t) {
1198
+ function dn(t) {
1199
1199
  t.bpm = function(e) {
1200
- return E(t).bpm = e, e;
1200
+ return z(t).bpm = e, e;
1201
1201
  };
1202
1202
  }
1203
- function fn(t) {
1203
+ function pn(t) {
1204
1204
  t.seed = function(e) {
1205
- return E(t).seed = e, e;
1205
+ return z(t).seed = e, e;
1206
1206
  };
1207
1207
  }
1208
1208
  function R(t) {
@@ -1253,7 +1253,7 @@ function k(t) {
1253
1253
  }
1254
1254
  return e;
1255
1255
  }
1256
- const pn = `#version 300 es
1256
+ const mn = `#version 300 es
1257
1257
  precision highp float;
1258
1258
 
1259
1259
  in vec2 v_uv;
@@ -1272,7 +1272,7 @@ void main() {
1272
1272
  o_secondaryColor = texture(u_cellColorTex, v_uv);
1273
1273
  }
1274
1274
  `;
1275
- class dn {
1275
+ class hn {
1276
1276
  _shader = null;
1277
1277
  _isCompiling = !1;
1278
1278
  _isDisposed = !1;
@@ -1280,7 +1280,7 @@ class dn {
1280
1280
  if (!(this._shader || this._isCompiling || this._isDisposed)) {
1281
1281
  this._isCompiling = !0;
1282
1282
  try {
1283
- this._shader = await e.createFilterShader(pn);
1283
+ this._shader = await e.createFilterShader(mn);
1284
1284
  } catch (n) {
1285
1285
  console.warn("[textmode.synth.js] Failed to compile copy shader:", n);
1286
1286
  } finally {
@@ -1301,8 +1301,8 @@ class dn {
1301
1301
  this._isDisposed = !1;
1302
1302
  }
1303
1303
  }
1304
- const N = new dn();
1305
- async function mn(t, e) {
1304
+ const N = new hn();
1305
+ async function yn(t, e) {
1306
1306
  const n = t.getPluginState(b);
1307
1307
  if (!n) return;
1308
1308
  const r = t.grid, o = t.drawFramebuffer;
@@ -1331,19 +1331,19 @@ async function mn(t, e) {
1331
1331
  }
1332
1332
  }
1333
1333
  if (!n.shader || !n.compiled || n.isDisposed) return;
1334
- const i = n.compiled.usesCharColorFeedback, u = n.compiled.usesCharFeedback, p = n.compiled.usesCellColorFeedback, d = i || u || p;
1334
+ const i = n.compiled.usesCharColorFeedback, u = n.compiled.usesCharFeedback, d = n.compiled.usesCellColorFeedback, p = i || u || d;
1335
1335
  if (n.pingPongBuffers) {
1336
1336
  const c = n.pingPongDimensions, l = !c || c.cols !== r.cols || c.rows !== r.rows;
1337
- d && !l || (n.pingPongBuffers[0].dispose(), n.pingPongBuffers[1].dispose(), n.pingPongBuffers = void 0, n.pingPongDimensions = void 0);
1337
+ p && !l || (n.pingPongBuffers[0].dispose(), n.pingPongBuffers[1].dispose(), n.pingPongBuffers = void 0, n.pingPongDimensions = void 0);
1338
1338
  }
1339
- d && !n.pingPongBuffers && (n.pingPongBuffers = [e.createFramebuffer({ width: r.cols, height: r.rows, attachments: 3 }), e.createFramebuffer({ width: r.cols, height: r.rows, attachments: 3 })], n.pingPongDimensions = { cols: r.cols, rows: r.rows }, n.pingPongIndex = 0), n.synthContext || (n.synthContext = { time: 0, frameCount: 0, width: 0, height: 0, cols: 0, rows: 0, bpm: 0 });
1339
+ p && !n.pingPongBuffers && (n.pingPongBuffers = [e.createFramebuffer({ width: r.cols, height: r.rows, attachments: 3 }), e.createFramebuffer({ width: r.cols, height: r.rows, attachments: 3 })], n.pingPongDimensions = { cols: r.cols, rows: r.rows }, n.pingPongIndex = 0), n.synthContext || (n.synthContext = { time: 0, frameCount: 0, width: 0, height: 0, cols: 0, rows: 0, bpm: 0 });
1340
1340
  const s = n.synthContext;
1341
- s.time = e.secs, s.frameCount = e.frameCount, s.width = r.width, s.height = r.height, s.cols = r.cols, s.rows = r.rows, s.bpm = n.bpm ?? cn(e), s.onError = n.onDynamicError, n.dynamicValues.clear();
1341
+ s.time = e.secs, s.frameCount = e.frameCount, s.width = r.width, s.height = r.height, s.cols = r.cols, s.rows = r.rows, s.bpm = n.bpm ?? un(e), s.onError = n.onDynamicError, n.dynamicValues.clear();
1342
1342
  for (const [c, l] of n.compiled.dynamicUpdaters) {
1343
1343
  const m = l(s);
1344
1344
  n.dynamicValues.set(c, m);
1345
1345
  }
1346
- if (d && n.pingPongBuffers) {
1346
+ if (p && n.pingPongBuffers) {
1347
1347
  const c = n.pingPongBuffers[n.pingPongIndex], l = n.pingPongBuffers[1 - n.pingPongIndex];
1348
1348
  l.begin(), e.clear(), e.shader(n.shader), X(t, e, n, s, c), e.rect(r.cols, r.rows), l.end(), o.begin(), e.clear();
1349
1349
  const m = N.getShader();
@@ -1353,7 +1353,7 @@ async function mn(t, e) {
1353
1353
  }
1354
1354
  function X(t, e, n, r, o) {
1355
1355
  e.setUniform("time", r.time), e.setUniform("u_resolution", [r.cols, r.rows]);
1356
- const a = ln(e);
1356
+ const a = fn(e);
1357
1357
  e.setUniform("u_seed", a ?? 0);
1358
1358
  for (const [s, c] of n.dynamicValues) e.setUniform(s, c);
1359
1359
  const i = n.compiled, u = n.staticUniformsAppliedTo !== n.shader;
@@ -1370,8 +1370,8 @@ function X(t, e, n, r, o) {
1370
1370
  e.setUniform("u_charSourceCount", s);
1371
1371
  }
1372
1372
  o && (i.usesCharColorFeedback && e.setUniform($.charColor, o.textures[1]), i.usesCharFeedback && e.setUniform($.char, o.textures[0]), i.usesCellColorFeedback && e.setUniform($.cellColor, o.textures[2]));
1373
- const p = i.externalLayers;
1374
- if (p && p.size > 0 && n.externalLayerMap) for (const [s, c] of p) {
1373
+ const d = i.externalLayers;
1374
+ if (d && d.size > 0 && n.externalLayerMap) for (const [s, c] of d) {
1375
1375
  const l = n.externalLayerMap.get(s);
1376
1376
  if (!l) {
1377
1377
  console.warn(`[textmode.synth.js] External layer not found: ${s}`);
@@ -1381,8 +1381,8 @@ function X(t, e, n, r, o) {
1381
1381
  let g;
1382
1382
  m?.pingPongBuffers ? g = m.pingPongBuffers[m.pingPongIndex].textures : l.drawFramebuffer && (g = l.drawFramebuffer.textures), g && (c.usesChar && e.setUniform(`${c.uniformPrefix}${P.char}`, g[0]), c.usesCharColor && e.setUniform(`${c.uniformPrefix}${P.charColor}`, g[1]), c.usesCellColor && e.setUniform(`${c.uniformPrefix}${P.cellColor}`, g[2]));
1383
1383
  }
1384
- const d = i.textmodeSources;
1385
- if (d && d.size > 0 && n.textmodeSourceMap) for (const [s, c] of d) {
1384
+ const p = i.textmodeSources;
1385
+ if (p && p.size > 0 && n.textmodeSourceMap) for (const [s, c] of p) {
1386
1386
  const l = n.textmodeSourceMap.get(s);
1387
1387
  if (!l) {
1388
1388
  console.warn(`[textmode.synth.js] TextmodeSource not found: ${s}`);
@@ -1393,14 +1393,14 @@ function X(t, e, n, r, o) {
1393
1393
  e.setUniform(`${c.uniformName}_dim`, [S, f]), l.texture ? e.setUniform(c.uniformName, l.texture) : console.warn(`[textmode.synth.js] TextmodeSource texture not loaded: ${s}`);
1394
1394
  }
1395
1395
  }
1396
- function hn(t) {
1396
+ function gn(t) {
1397
1397
  const e = t.getPluginState(b);
1398
1398
  e && (e.isDisposed = !0, e.shader?.dispose && e.shader.dispose(), e.pingPongBuffers && (e.pingPongBuffers[0].dispose?.(), e.pingPongBuffers[1].dispose?.()));
1399
1399
  }
1400
- const xn = { name: b, version: "1.5.0", install(t, e) {
1401
- N.reset(), un(t), fn(t), on(e), sn(e), an(e), e.registerPreSetupHook(async () => {
1400
+ const _n = { name: b, version: "1.5.1", install(t, e) {
1401
+ N.reset(), dn(t), pn(t), sn(e), ln(e), cn(e), e.registerPreSetupHook(async () => {
1402
1402
  await N.initialize(t);
1403
- }), e.registerLayerPreRenderHook((n) => mn(n, t)), e.registerLayerDisposedHook(hn);
1403
+ }), e.registerLayerPreRenderHook((n) => yn(n, t)), e.registerLayerDisposedHook(gn);
1404
1404
  }, uninstall(t, e) {
1405
1405
  const n = [e.layerManager.base, ...e.layerManager.all];
1406
1406
  for (const r of n) {
@@ -1409,52 +1409,52 @@ const xn = { name: b, version: "1.5.0", install(t, e) {
1409
1409
  }
1410
1410
  delete t.bpm, delete t.seed, e.removeLayerExtension("synth"), e.removeLayerExtension("bpm"), e.removeLayerExtension("clearSynth"), N.dispose();
1411
1411
  } };
1412
- function Cn(t, e, n, r) {
1412
+ function vn(t, e, n, r) {
1413
1413
  return new v({ cellColorSource: H(t, e, n, r) });
1414
1414
  }
1415
- const bn = (t) => new v({ charSource: t });
1416
- function Sn(t, e, n, r) {
1415
+ const xn = (t) => new v({ charSource: t });
1416
+ function Cn(t, e, n, r) {
1417
1417
  return new v({ charColorSource: H(t, e, n, r) });
1418
1418
  }
1419
- function wn(t) {
1419
+ function bn(t) {
1420
1420
  return w.gradient(t ?? null);
1421
1421
  }
1422
- function $n(t, e) {
1422
+ function Sn(t, e) {
1423
1423
  return w.noise(t ?? null, e ?? null);
1424
1424
  }
1425
- function Mn(t, e, n, r) {
1425
+ function wn(t, e, n, r) {
1426
1426
  return w.plasma(t ?? null, e ?? null, n ?? null, r ?? null);
1427
1427
  }
1428
- function Tn(t, e, n, r, o, a) {
1428
+ function $n(t, e, n, r, o, a) {
1429
1429
  return w.moire(t ?? null, e ?? null, n ?? null, r ?? null, o ?? null, a ?? null);
1430
1430
  }
1431
- function Fn(t, e, n) {
1431
+ function Mn(t, e, n) {
1432
1432
  return w.osc(t ?? null, e ?? null, n ?? null);
1433
1433
  }
1434
- function In(t, e, n, r) {
1434
+ function Tn(t, e, n, r) {
1435
1435
  const o = H(t, e, n, r);
1436
1436
  return new v({ charColorSource: o, cellColorSource: o });
1437
1437
  }
1438
- function Pn(t, e, n) {
1438
+ function Fn(t, e, n) {
1439
1439
  return w.shape(t ?? null, e ?? null, n ?? null);
1440
1440
  }
1441
- function yn(t, e, n, r) {
1441
+ function le(t, e, n, r) {
1442
1442
  return t !== void 0 && e === void 0 && n === void 0 && r === void 0 && typeof t == "number" ? w.solid(t) : w.solid(t ?? null, e ?? null, n ?? null, r ?? null);
1443
1443
  }
1444
- const Rn = (t) => {
1444
+ const In = (t) => {
1445
1445
  const e = w.src;
1446
1446
  if (!t) return e();
1447
1447
  const n = new v();
1448
1448
  if (typeof t == "function") {
1449
1449
  const r = t();
1450
- if (r && _n(r)) {
1450
+ if (r && Rn(r)) {
1451
1451
  const o = r.id ?? `layer_${Date.now()}_${Math.random().toString(36).slice(2, 9)}`;
1452
1452
  n.addExternalLayerRef({ layerId: o, layer: t });
1453
1453
  } else {
1454
1454
  const o = `tms_${Date.now()}_${Math.random().toString(36).slice(2, 9)}`;
1455
1455
  n.addTextmodeSourceRef({ sourceId: o, source: t });
1456
1456
  }
1457
- } else if (gn(t)) {
1457
+ } else if (Pn(t)) {
1458
1458
  const r = `tms_${Date.now()}_${Math.random().toString(36).slice(2, 9)}`;
1459
1459
  n.addTextmodeSourceRef({ sourceId: r, source: t });
1460
1460
  } else {
@@ -1463,33 +1463,34 @@ const Rn = (t) => {
1463
1463
  }
1464
1464
  return n;
1465
1465
  };
1466
- function gn(t) {
1466
+ function Pn(t) {
1467
1467
  return t !== null && typeof t == "object" && "texture" in t && "originalWidth" in t && "originalHeight" in t;
1468
1468
  }
1469
- function _n(t) {
1469
+ function Rn(t) {
1470
1470
  return t !== null && typeof t == "object" && "grid" in t && "drawFramebuffer" in t;
1471
1471
  }
1472
1472
  function kn(t, e, n) {
1473
1473
  return w.voronoi(t ?? null, e ?? null, n ?? null);
1474
1474
  }
1475
1475
  function H(t, e, n, r) {
1476
- return t instanceof v ? t : yn(t, e, n, r);
1476
+ return t instanceof v ? t : le(t, e, n, r);
1477
1477
  }
1478
+ typeof window < "u" && (window.SynthPlugin = _n, window.SynthSource = v, window.cellColor = vn, window.char = xn, window.charColor = Cn, window.gradient = bn, window.moire = $n, window.noise = Sn, window.osc = Mn, window.paint = Tn, window.plasma = wn, window.shape = Fn, window.solid = le, window.src = In, window.voronoi = kn, window.setGlobalErrorCallback = Jt);
1478
1479
  export {
1479
- xn as SynthPlugin,
1480
+ _n as SynthPlugin,
1480
1481
  v as SynthSource,
1481
- Cn as cellColor,
1482
- bn as char,
1483
- Sn as charColor,
1484
- wn as gradient,
1485
- Tn as moire,
1486
- $n as noise,
1487
- Fn as osc,
1488
- In as paint,
1489
- Mn as plasma,
1490
- vn as setGlobalErrorCallback,
1491
- Pn as shape,
1492
- yn as solid,
1493
- Rn as src,
1482
+ vn as cellColor,
1483
+ xn as char,
1484
+ Cn as charColor,
1485
+ bn as gradient,
1486
+ $n as moire,
1487
+ Sn as noise,
1488
+ Mn as osc,
1489
+ Tn as paint,
1490
+ wn as plasma,
1491
+ Jt as setGlobalErrorCallback,
1492
+ Fn as shape,
1493
+ le as solid,
1494
+ In as src,
1494
1495
  kn as voronoi
1495
1496
  };