@remotion/effects 4.0.467 → 4.0.469

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.
Files changed (43) hide show
  1. package/dist/color-utils.d.ts +2 -0
  2. package/dist/dot-grid.d.ts +31 -0
  3. package/dist/drop-shadow/drop-shadow-runtime.d.ts +54 -0
  4. package/dist/drop-shadow/drop-shadow-shaders.d.ts +5 -0
  5. package/dist/drop-shadow/index.d.ts +15 -0
  6. package/dist/drop-shadow.d.ts +1 -0
  7. package/dist/duotone.d.ts +31 -0
  8. package/dist/esm/barrel-distortion.mjs +14 -1
  9. package/dist/esm/blur.mjs +38 -17
  10. package/dist/esm/brightness.mjs +14 -1
  11. package/dist/esm/chromatic-aberration.mjs +14 -1
  12. package/dist/esm/contrast.mjs +14 -1
  13. package/dist/esm/dot-grid.mjs +349 -0
  14. package/dist/esm/drop-shadow.mjs +610 -0
  15. package/dist/esm/duotone.mjs +365 -0
  16. package/dist/esm/glow.mjs +599 -0
  17. package/dist/esm/grayscale.mjs +14 -1
  18. package/dist/esm/halftone-linear-gradient.mjs +480 -0
  19. package/dist/esm/halftone.mjs +17 -18
  20. package/dist/esm/hue.mjs +14 -1
  21. package/dist/esm/invert.mjs +14 -1
  22. package/dist/esm/mirror.mjs +14 -1
  23. package/dist/esm/noise.mjs +341 -0
  24. package/dist/esm/saturation.mjs +14 -1
  25. package/dist/esm/scale.mjs +7 -1
  26. package/dist/esm/shine.mjs +389 -0
  27. package/dist/esm/speckle.mjs +360 -0
  28. package/dist/esm/tint.mjs +14 -1
  29. package/dist/esm/translate.mjs +15 -2
  30. package/dist/esm/vignette.mjs +439 -0
  31. package/dist/esm/wave.mjs +7 -1
  32. package/dist/gaussian-blur-shader.d.ts +1 -0
  33. package/dist/glow/glow-runtime.d.ts +52 -0
  34. package/dist/glow/glow-shaders.d.ts +5 -0
  35. package/dist/glow/index.d.ts +13 -0
  36. package/dist/glow.d.ts +1 -0
  37. package/dist/halftone-linear-gradient.d.ts +93 -0
  38. package/dist/noise.d.ts +11 -0
  39. package/dist/shine.d.ts +17 -0
  40. package/dist/speckle.d.ts +11 -0
  41. package/dist/validate-effect-param.d.ts +1 -0
  42. package/dist/vignette.d.ts +68 -0
  43. package/package.json +75 -3
@@ -0,0 +1,480 @@
1
+ // src/halftone-linear-gradient.ts
2
+ import { Internals } from "remotion";
3
+
4
+ // src/validate-effect-param.ts
5
+ var assertEffectParamsObject = (params, effectLabel) => {
6
+ if (params === null || typeof params !== "object") {
7
+ throw new TypeError(`${effectLabel} effect requires a parameters object, but got ${JSON.stringify(params)}`);
8
+ }
9
+ };
10
+ var assertRequiredFiniteNumber = (value, name) => {
11
+ if (typeof value !== "number" || !Number.isFinite(value)) {
12
+ throw new TypeError(`"${name}" must be a finite number, but got ${JSON.stringify(value)}`);
13
+ }
14
+ };
15
+ var assertRequiredColor = (value, name) => {
16
+ if (typeof value !== "string" || value.length === 0) {
17
+ throw new TypeError(`"${name}" must be a non-empty string, but got ${JSON.stringify(value)}`);
18
+ }
19
+ };
20
+ var assertOptionalColor = (value, name) => {
21
+ if (value === undefined) {
22
+ return;
23
+ }
24
+ assertRequiredColor(value, name);
25
+ };
26
+
27
+ // src/color-utils.ts
28
+ var DEFAULT_AMOUNT = 1;
29
+ var DEFAULT_BRIGHTNESS_AMOUNT = 0;
30
+ var DEFAULT_HUE_DEGREES = 0;
31
+ var colorAmountSchema = {
32
+ type: "number",
33
+ min: 0,
34
+ max: 1,
35
+ step: 0.01,
36
+ default: DEFAULT_AMOUNT,
37
+ description: "Amount"
38
+ };
39
+ var colorMultiplierSchema = {
40
+ type: "number",
41
+ min: 0,
42
+ step: 0.01,
43
+ default: DEFAULT_AMOUNT,
44
+ description: "Amount"
45
+ };
46
+ var brightnessAmountSchema = {
47
+ type: "number",
48
+ min: -1,
49
+ max: 1,
50
+ step: 0.01,
51
+ default: DEFAULT_BRIGHTNESS_AMOUNT,
52
+ description: "Amount"
53
+ };
54
+ var hueDegreesSchema = {
55
+ type: "number",
56
+ step: 1,
57
+ default: DEFAULT_HUE_DEGREES,
58
+ description: "Degrees"
59
+ };
60
+ var assertOptionalFiniteNumber = (value, name) => {
61
+ if (value === undefined) {
62
+ return;
63
+ }
64
+ assertRequiredFiniteNumber(value, name);
65
+ };
66
+ var validateUnitInterval = (value, name) => {
67
+ if (value < 0) {
68
+ throw new TypeError(`"${name}" must be >= 0, but got ${JSON.stringify(value)}`);
69
+ }
70
+ if (value > 1) {
71
+ throw new TypeError(`"${name}" must be <= 1, but got ${JSON.stringify(value)}`);
72
+ }
73
+ };
74
+ var validateNonNegative = (value, name) => {
75
+ if (value < 0) {
76
+ throw new TypeError(`"${name}" must be >= 0, but got ${JSON.stringify(value)}`);
77
+ }
78
+ };
79
+ var validateSignedUnitInterval = (value, name) => {
80
+ if (value < -1) {
81
+ throw new TypeError(`"${name}" must be >= -1, but got ${JSON.stringify(value)}`);
82
+ }
83
+ if (value > 1) {
84
+ throw new TypeError(`"${name}" must be <= 1, but got ${JSON.stringify(value)}`);
85
+ }
86
+ };
87
+ var clampColorChannel = (value) => {
88
+ return Math.max(0, Math.min(255, value));
89
+ };
90
+ var parseColorRgba = (ctx, color) => {
91
+ ctx.clearRect(0, 0, 1, 1);
92
+ ctx.fillStyle = color;
93
+ ctx.fillRect(0, 0, 1, 1);
94
+ const { data } = ctx.getImageData(0, 0, 1, 1);
95
+ return [data[0], data[1], data[2], data[3]];
96
+ };
97
+
98
+ // src/halftone-linear-gradient.ts
99
+ var { createEffect, createWebGL2ContextError } = Internals;
100
+ var HALFTONE_LINEAR_GRADIENT_COLOR_MODES = ["solid", "source"];
101
+ var DEFAULT_FIRST_STOP_DOT_SIZE = 0;
102
+ var DEFAULT_SECOND_STOP_DOT_SIZE = 40;
103
+ var DEFAULT_FIRST_STOP_POSITION = [0, 0.5];
104
+ var DEFAULT_SECOND_STOP_POSITION = [1, 0.5];
105
+ var DEFAULT_GRID_SIZE = 24;
106
+ var DEFAULT_DOT_COLOR = "black";
107
+ var halftoneLinearGradientSchema = {
108
+ firstStopDotSize: {
109
+ type: "number",
110
+ min: 0,
111
+ max: 400,
112
+ step: 1,
113
+ default: DEFAULT_FIRST_STOP_DOT_SIZE,
114
+ description: "First stop dot size"
115
+ },
116
+ secondStopDotSize: {
117
+ type: "number",
118
+ min: 0,
119
+ max: 400,
120
+ step: 1,
121
+ default: DEFAULT_SECOND_STOP_DOT_SIZE,
122
+ description: "Second stop dot size"
123
+ },
124
+ firstStopPosition: {
125
+ type: "uv-coordinate",
126
+ min: -1,
127
+ max: 2,
128
+ step: 0.01,
129
+ default: DEFAULT_FIRST_STOP_POSITION,
130
+ description: "First stop position"
131
+ },
132
+ secondStopPosition: {
133
+ type: "uv-coordinate",
134
+ min: -1,
135
+ max: 2,
136
+ step: 0.01,
137
+ default: DEFAULT_SECOND_STOP_POSITION,
138
+ description: "Second stop position"
139
+ },
140
+ gridSize: {
141
+ type: "number",
142
+ min: 1,
143
+ max: 400,
144
+ step: 1,
145
+ default: DEFAULT_GRID_SIZE,
146
+ description: "Grid size"
147
+ },
148
+ colorMode: {
149
+ type: "enum",
150
+ default: "solid",
151
+ description: "Color mode",
152
+ variants: {
153
+ solid: {
154
+ dotColor: {
155
+ type: "color",
156
+ default: DEFAULT_DOT_COLOR,
157
+ description: "Dot color"
158
+ }
159
+ },
160
+ source: {}
161
+ }
162
+ }
163
+ };
164
+ var formatEnum = (variants) => {
165
+ if (variants.length === 2) {
166
+ return `"${variants[0]}" or "${variants[1]}"`;
167
+ }
168
+ return `${variants.slice(0, -1).map((variant) => `"${variant}"`).join(", ")} or "${variants[variants.length - 1]}"`;
169
+ };
170
+ var assertOptionalEnum = (value, name, variants) => {
171
+ if (value === undefined) {
172
+ return;
173
+ }
174
+ if (typeof value !== "string" || !variants.includes(value)) {
175
+ throw new TypeError(`"${name}" must be ${formatEnum(variants)}`);
176
+ }
177
+ };
178
+ var resolve = (p) => ({
179
+ firstStopDotSize: p.firstStopDotSize ?? DEFAULT_FIRST_STOP_DOT_SIZE,
180
+ secondStopDotSize: p.secondStopDotSize ?? DEFAULT_SECOND_STOP_DOT_SIZE,
181
+ firstStopPosition: [
182
+ ...p.firstStopPosition ?? DEFAULT_FIRST_STOP_POSITION
183
+ ],
184
+ secondStopPosition: [
185
+ ...p.secondStopPosition ?? DEFAULT_SECOND_STOP_POSITION
186
+ ],
187
+ gridSize: p.gridSize ?? DEFAULT_GRID_SIZE,
188
+ colorMode: p.colorMode ?? "solid",
189
+ dotColor: "dotColor" in p ? p.dotColor ?? DEFAULT_DOT_COLOR : DEFAULT_DOT_COLOR
190
+ });
191
+ var validateNonNegative2 = (value, name) => {
192
+ if (value < 0) {
193
+ throw new TypeError(`"${name}" must be >= 0, but got ${JSON.stringify(value)}`);
194
+ }
195
+ };
196
+ var validatePositive = (value, name) => {
197
+ if (value <= 0) {
198
+ throw new TypeError(`"${name}" must be greater than 0, but got ${JSON.stringify(value)}`);
199
+ }
200
+ };
201
+ var assertOptionalUvCoordinate = (value, name) => {
202
+ if (value === undefined) {
203
+ return;
204
+ }
205
+ if (!Array.isArray(value) || value.length !== 2 || value.some((item) => typeof item !== "number" || !Number.isFinite(item))) {
206
+ throw new TypeError(`"${name}" must be a [number, number] tuple`);
207
+ }
208
+ };
209
+ var validateHalftoneLinearGradientParams = (params) => {
210
+ assertEffectParamsObject(params, "Halftone linear gradient");
211
+ assertOptionalFiniteNumber(params.firstStopDotSize, "firstStopDotSize");
212
+ assertOptionalFiniteNumber(params.secondStopDotSize, "secondStopDotSize");
213
+ assertOptionalUvCoordinate(params.firstStopPosition, "firstStopPosition");
214
+ assertOptionalUvCoordinate(params.secondStopPosition, "secondStopPosition");
215
+ assertOptionalFiniteNumber(params.gridSize, "gridSize");
216
+ assertOptionalEnum(params.colorMode, "colorMode", HALFTONE_LINEAR_GRADIENT_COLOR_MODES);
217
+ if (params.colorMode === "source" && "dotColor" in params) {
218
+ throw new TypeError('"dotColor" can only be set when "colorMode" is "solid"');
219
+ }
220
+ assertOptionalColor("dotColor" in params ? params.dotColor : undefined, "dotColor");
221
+ if (params.firstStopDotSize !== undefined) {
222
+ validateNonNegative2(params.firstStopDotSize, "firstStopDotSize");
223
+ }
224
+ if (params.secondStopDotSize !== undefined) {
225
+ validateNonNegative2(params.secondStopDotSize, "secondStopDotSize");
226
+ }
227
+ if (params.gridSize !== undefined) {
228
+ validatePositive(params.gridSize, "gridSize");
229
+ }
230
+ };
231
+ var HALFTONE_LINEAR_GRADIENT_VS = `#version 300 es
232
+ in vec2 aPos;
233
+ in vec2 aUv;
234
+ out vec2 vUv;
235
+ void main() {
236
+ vUv = aUv;
237
+ gl_Position = vec4(aPos, 0.0, 1.0);
238
+ }
239
+ `;
240
+ var HALFTONE_LINEAR_GRADIENT_FS = `#version 300 es
241
+ precision highp float;
242
+
243
+ in vec2 vUv;
244
+ out vec4 fragColor;
245
+
246
+ uniform sampler2D uSource;
247
+ uniform vec2 uResolution;
248
+ uniform float uFirstStopDotSize;
249
+ uniform float uSecondStopDotSize;
250
+ uniform vec2 uFirstStopPosition;
251
+ uniform vec2 uSecondStopPosition;
252
+ uniform float uGridSize;
253
+ uniform vec4 uColor;
254
+ uniform bool uUseSourceColor;
255
+
256
+ float gradientProgress(vec2 uv) {
257
+ vec2 stopVector = uSecondStopPosition - uFirstStopPosition;
258
+ float stopDistance = dot(stopVector, stopVector);
259
+ if (stopDistance <= 0.0) {
260
+ return 0.0;
261
+ }
262
+
263
+ return clamp(dot(uv - uFirstStopPosition, stopVector) / stopDistance, 0.0, 1.0);
264
+ }
265
+
266
+ vec4 sourceOver(vec4 backdrop, vec4 overlay) {
267
+ return overlay + backdrop * (1.0 - overlay.a);
268
+ }
269
+
270
+ void main() {
271
+ vec2 fragPos = vUv * uResolution;
272
+ vec2 center = uResolution * 0.5;
273
+ vec2 gridPos = fragPos - center;
274
+
275
+ float gridSize = max(uGridSize, 0.001);
276
+ vec2 cellIndex = floor(gridPos / gridSize + 0.5);
277
+ vec2 gridCenter = cellIndex * gridSize;
278
+ vec2 canvasCenter = center + gridCenter;
279
+
280
+ vec2 centerUv = canvasCenter / uResolution;
281
+ // Flip Y so that (0,0) is top-left, matching CSS/canvas coordinate conventions.
282
+ vec2 gradientUv = vec2(centerUv.x, 1.0 - centerUv.y);
283
+ float progress = gradientProgress(gradientUv);
284
+ float dotSize = mix(uFirstStopDotSize, uSecondStopDotSize, progress);
285
+
286
+ if (dotSize <= 0.01) {
287
+ fragColor = vec4(0.0);
288
+ return;
289
+ }
290
+
291
+ vec2 diff = gridPos - gridCenter;
292
+ float radius = dotSize * 0.5;
293
+ float coverage = 1.0 - smoothstep(radius - 0.75, radius + 0.75, length(diff));
294
+
295
+ vec2 sampleUv = clamp(centerUv, vec2(0.0), vec2(1.0));
296
+ vec4 texColor = texture(uSource, sampleUv);
297
+ vec4 dotColor = (uUseSourceColor ? texColor : uColor) * coverage;
298
+ fragColor = uUseSourceColor ? dotColor : sourceOver(texColor, dotColor);
299
+ }
300
+ `;
301
+ var compileShader = (gl, type, source) => {
302
+ const shader = gl.createShader(type);
303
+ if (!shader) {
304
+ throw new Error("Failed to create WebGL shader");
305
+ }
306
+ gl.shaderSource(shader, source);
307
+ gl.compileShader(shader);
308
+ if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
309
+ const log = gl.getShaderInfoLog(shader);
310
+ gl.deleteShader(shader);
311
+ throw new Error(`Halftone linear gradient shader compile failed: ${log ?? "(no log)"}`);
312
+ }
313
+ return shader;
314
+ };
315
+ var linkProgram = (gl, vs, fs) => {
316
+ const program = gl.createProgram();
317
+ if (!program) {
318
+ throw new Error("Failed to create WebGL program");
319
+ }
320
+ gl.attachShader(program, vs);
321
+ gl.attachShader(program, fs);
322
+ gl.linkProgram(program);
323
+ if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
324
+ const log = gl.getProgramInfoLog(program);
325
+ gl.deleteProgram(program);
326
+ throw new Error(`Halftone linear gradient program link failed: ${log ?? "(no log)"}`);
327
+ }
328
+ return program;
329
+ };
330
+ var halftoneLinearGradient = createEffect({
331
+ type: "remotion/halftone-linear-gradient",
332
+ label: "halftoneLinearGradient()",
333
+ documentationLink: "https://www.remotion.dev/docs/effects/halftone-linear-gradient",
334
+ backend: "webgl2",
335
+ calculateKey: (params) => {
336
+ const r = resolve(params);
337
+ return `halftone-linear-gradient-${r.firstStopDotSize}-${r.secondStopDotSize}-${r.firstStopPosition.join(":")}-${r.secondStopPosition.join(":")}-${r.gridSize}-${r.colorMode}-${r.dotColor}`;
338
+ },
339
+ setup: (target) => {
340
+ const gl = target.getContext("webgl2", {
341
+ premultipliedAlpha: true,
342
+ alpha: true,
343
+ preserveDrawingBuffer: true
344
+ });
345
+ if (!gl) {
346
+ throw createWebGL2ContextError("halftone linear gradient effect");
347
+ }
348
+ gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true);
349
+ const vs = compileShader(gl, gl.VERTEX_SHADER, HALFTONE_LINEAR_GRADIENT_VS);
350
+ const fs = compileShader(gl, gl.FRAGMENT_SHADER, HALFTONE_LINEAR_GRADIENT_FS);
351
+ const program = linkProgram(gl, vs, fs);
352
+ gl.deleteShader(vs);
353
+ gl.deleteShader(fs);
354
+ const vao = gl.createVertexArray();
355
+ if (!vao) {
356
+ throw new Error("Failed to create WebGL vertex array");
357
+ }
358
+ gl.bindVertexArray(vao);
359
+ const data = new Float32Array([
360
+ -1,
361
+ -1,
362
+ 0,
363
+ 0,
364
+ 1,
365
+ -1,
366
+ 1,
367
+ 0,
368
+ -1,
369
+ 1,
370
+ 0,
371
+ 1,
372
+ 1,
373
+ 1,
374
+ 1,
375
+ 1
376
+ ]);
377
+ const vbo = gl.createBuffer();
378
+ if (!vbo) {
379
+ throw new Error("Failed to create WebGL buffer");
380
+ }
381
+ gl.bindBuffer(gl.ARRAY_BUFFER, vbo);
382
+ gl.bufferData(gl.ARRAY_BUFFER, data, gl.STATIC_DRAW);
383
+ const aPos = gl.getAttribLocation(program, "aPos");
384
+ const aUv = gl.getAttribLocation(program, "aUv");
385
+ gl.enableVertexAttribArray(aPos);
386
+ gl.vertexAttribPointer(aPos, 2, gl.FLOAT, false, 16, 0);
387
+ gl.enableVertexAttribArray(aUv);
388
+ gl.vertexAttribPointer(aUv, 2, gl.FLOAT, false, 16, 8);
389
+ gl.bindVertexArray(null);
390
+ const texture = gl.createTexture();
391
+ if (!texture) {
392
+ throw new Error("Failed to create WebGL texture");
393
+ }
394
+ gl.bindTexture(gl.TEXTURE_2D, texture);
395
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
396
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
397
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
398
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
399
+ gl.bindTexture(gl.TEXTURE_2D, null);
400
+ const colorCanvas = document.createElement("canvas");
401
+ colorCanvas.width = 1;
402
+ colorCanvas.height = 1;
403
+ const colorCtx = colorCanvas.getContext("2d", { willReadFrequently: true });
404
+ if (!colorCtx) {
405
+ throw new Error("Failed to acquire 2D context for color parsing");
406
+ }
407
+ return {
408
+ gl,
409
+ program,
410
+ vao,
411
+ vbo,
412
+ texture,
413
+ uSource: gl.getUniformLocation(program, "uSource"),
414
+ uResolution: gl.getUniformLocation(program, "uResolution"),
415
+ uFirstStopDotSize: gl.getUniformLocation(program, "uFirstStopDotSize"),
416
+ uSecondStopDotSize: gl.getUniformLocation(program, "uSecondStopDotSize"),
417
+ uFirstStopPosition: gl.getUniformLocation(program, "uFirstStopPosition"),
418
+ uSecondStopPosition: gl.getUniformLocation(program, "uSecondStopPosition"),
419
+ uGridSize: gl.getUniformLocation(program, "uGridSize"),
420
+ uColor: gl.getUniformLocation(program, "uColor"),
421
+ uUseSourceColor: gl.getUniformLocation(program, "uUseSourceColor"),
422
+ colorCtx,
423
+ cachedColorStr: "",
424
+ cachedColorRgba: [0, 0, 0, 255]
425
+ };
426
+ },
427
+ apply: ({ source, width, height, params, state, flipSourceY }) => {
428
+ const r = resolve(params);
429
+ const { gl, program, vao, texture } = state;
430
+ if (state.cachedColorStr !== r.dotColor) {
431
+ state.cachedColorStr = r.dotColor;
432
+ state.cachedColorRgba = parseColorRgba(state.colorCtx, r.dotColor);
433
+ }
434
+ const [cr, cg, cb, ca] = state.cachedColorRgba;
435
+ const caNormalized = ca / 255;
436
+ gl.viewport(0, 0, width, height);
437
+ gl.clearColor(0, 0, 0, 0);
438
+ gl.clear(gl.COLOR_BUFFER_BIT);
439
+ gl.useProgram(program);
440
+ gl.bindVertexArray(vao);
441
+ gl.activeTexture(gl.TEXTURE0);
442
+ gl.bindTexture(gl.TEXTURE_2D, texture);
443
+ gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, flipSourceY);
444
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, source);
445
+ if (state.uSource)
446
+ gl.uniform1i(state.uSource, 0);
447
+ if (state.uResolution)
448
+ gl.uniform2f(state.uResolution, width, height);
449
+ if (state.uFirstStopDotSize)
450
+ gl.uniform1f(state.uFirstStopDotSize, r.firstStopDotSize);
451
+ if (state.uSecondStopDotSize)
452
+ gl.uniform1f(state.uSecondStopDotSize, r.secondStopDotSize);
453
+ if (state.uFirstStopPosition)
454
+ gl.uniform2f(state.uFirstStopPosition, r.firstStopPosition[0], r.firstStopPosition[1]);
455
+ if (state.uSecondStopPosition)
456
+ gl.uniform2f(state.uSecondStopPosition, r.secondStopPosition[0], r.secondStopPosition[1]);
457
+ if (state.uGridSize)
458
+ gl.uniform1f(state.uGridSize, r.gridSize);
459
+ if (state.uColor)
460
+ gl.uniform4f(state.uColor, cr / 255 * caNormalized, cg / 255 * caNormalized, cb / 255 * caNormalized, caNormalized);
461
+ if (state.uUseSourceColor)
462
+ gl.uniform1i(state.uUseSourceColor, r.colorMode === "source" ? 1 : 0);
463
+ gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
464
+ gl.bindVertexArray(null);
465
+ gl.bindTexture(gl.TEXTURE_2D, null);
466
+ gl.useProgram(null);
467
+ },
468
+ cleanup: ({ gl, program, vao, vbo, texture }) => {
469
+ gl.deleteBuffer(vbo);
470
+ gl.deleteProgram(program);
471
+ gl.deleteVertexArray(vao);
472
+ gl.deleteTexture(texture);
473
+ },
474
+ schema: halftoneLinearGradientSchema,
475
+ validateParams: validateHalftoneLinearGradientParams
476
+ });
477
+ export {
478
+ halftoneLinearGradientSchema,
479
+ halftoneLinearGradient
480
+ };
@@ -17,6 +17,12 @@ var assertRequiredColor = (value, name) => {
17
17
  throw new TypeError(`"${name}" must be a non-empty string, but got ${JSON.stringify(value)}`);
18
18
  }
19
19
  };
20
+ var assertOptionalColor = (value, name) => {
21
+ if (value === undefined) {
22
+ return;
23
+ }
24
+ assertRequiredColor(value, name);
25
+ };
20
26
 
21
27
  // src/color-utils.ts
22
28
  var DEFAULT_AMOUNT = 1;
@@ -81,6 +87,13 @@ var validateSignedUnitInterval = (value, name) => {
81
87
  var clampColorChannel = (value) => {
82
88
  return Math.max(0, Math.min(255, value));
83
89
  };
90
+ var parseColorRgba = (ctx, color) => {
91
+ ctx.clearRect(0, 0, 1, 1);
92
+ ctx.fillStyle = color;
93
+ ctx.fillRect(0, 0, 1, 1);
94
+ const { data } = ctx.getImageData(0, 0, 1, 1);
95
+ return [data[0], data[1], data[2], data[3]];
96
+ };
84
97
 
85
98
  // src/halftone.ts
86
99
  var { createEffect, createWebGL2ContextError } = Internals;
@@ -177,14 +190,6 @@ var assertOptionalBoolean = (value, name) => {
177
190
  throw new TypeError(`"${name}" must be a boolean, but got ${JSON.stringify(value)}`);
178
191
  }
179
192
  };
180
- var assertOptionalColor = (value, name) => {
181
- if (value === undefined) {
182
- return;
183
- }
184
- if (typeof value !== "string" || value.length === 0) {
185
- throw new TypeError(`"${name}" must be a non-empty string, but got ${JSON.stringify(value)}`);
186
- }
187
- };
188
193
  var resolve = (p) => ({
189
194
  shape: p.shape ?? "circle",
190
195
  dotSize: p.dotSize ?? 20,
@@ -342,16 +347,9 @@ var linkProgram = (gl, vs, fs) => {
342
347
  }
343
348
  return program;
344
349
  };
345
- var parseColorRgba = (ctx, color) => {
346
- ctx.clearRect(0, 0, 1, 1);
347
- ctx.fillStyle = color;
348
- ctx.fillRect(0, 0, 1, 1);
349
- const { data } = ctx.getImageData(0, 0, 1, 1);
350
- return [data[0] / 255, data[1] / 255, data[2] / 255, data[3] / 255];
351
- };
352
350
  var halftone = createEffect({
353
351
  type: "remotion/halftone",
354
- label: "Halftone",
352
+ label: "halftone()",
355
353
  documentationLink: "https://www.remotion.dev/docs/effects/halftone",
356
354
  backend: "webgl2",
357
355
  calculateKey: (params) => {
@@ -442,7 +440,7 @@ var halftone = createEffect({
442
440
  uUseSourceColor: gl.getUniformLocation(program, "uUseSourceColor"),
443
441
  colorCtx,
444
442
  cachedColorStr: "",
445
- cachedColorRgba: [0, 0, 0, 1]
443
+ cachedColorRgba: [0, 0, 0, 255]
446
444
  };
447
445
  },
448
446
  apply: ({ source, width, height, params, state, flipSourceY }) => {
@@ -453,6 +451,7 @@ var halftone = createEffect({
453
451
  state.cachedColorRgba = parseColorRgba(state.colorCtx, r.dotColor);
454
452
  }
455
453
  const [cr, cg, cb, ca] = state.cachedColorRgba;
454
+ const caNormalized = ca / 255;
456
455
  const filter = r.sampling === "nearest" ? gl.NEAREST : gl.LINEAR;
457
456
  gl.viewport(0, 0, width, height);
458
457
  gl.clearColor(0, 0, 0, 0);
@@ -478,7 +477,7 @@ var halftone = createEffect({
478
477
  if (state.uOffset)
479
478
  gl.uniform2f(state.uOffset, r.offsetX, r.offsetY);
480
479
  if (state.uColor)
481
- gl.uniform4f(state.uColor, cr * ca, cg * ca, cb * ca, ca);
480
+ gl.uniform4f(state.uColor, cr / 255 * caNormalized, cg / 255 * caNormalized, cb / 255 * caNormalized, caNormalized);
482
481
  if (state.uShape)
483
482
  gl.uniform1i(state.uShape, SHAPE_INDEX[r.shape]);
484
483
  if (state.uShadeOutside)
package/dist/esm/hue.mjs CHANGED
@@ -17,6 +17,12 @@ var assertRequiredColor = (value, name) => {
17
17
  throw new TypeError(`"${name}" must be a non-empty string, but got ${JSON.stringify(value)}`);
18
18
  }
19
19
  };
20
+ var assertOptionalColor = (value, name) => {
21
+ if (value === undefined) {
22
+ return;
23
+ }
24
+ assertRequiredColor(value, name);
25
+ };
20
26
 
21
27
  // src/color-utils.ts
22
28
  var DEFAULT_AMOUNT = 1;
@@ -81,6 +87,13 @@ var validateSignedUnitInterval = (value, name) => {
81
87
  var clampColorChannel = (value) => {
82
88
  return Math.max(0, Math.min(255, value));
83
89
  };
90
+ var parseColorRgba = (ctx, color) => {
91
+ ctx.clearRect(0, 0, 1, 1);
92
+ ctx.fillStyle = color;
93
+ ctx.fillRect(0, 0, 1, 1);
94
+ const { data } = ctx.getImageData(0, 0, 1, 1);
95
+ return [data[0], data[1], data[2], data[3]];
96
+ };
84
97
 
85
98
  // src/hue.ts
86
99
  var { createEffect } = Internals;
@@ -96,7 +109,7 @@ var validateHueParams = (params) => {
96
109
  };
97
110
  var hue = createEffect({
98
111
  type: "remotion/hue",
99
- label: "Hue",
112
+ label: "hue()",
100
113
  documentationLink: "https://www.remotion.dev/docs/effects/hue",
101
114
  backend: "2d",
102
115
  calculateKey: (params) => {
@@ -17,6 +17,12 @@ var assertRequiredColor = (value, name) => {
17
17
  throw new TypeError(`"${name}" must be a non-empty string, but got ${JSON.stringify(value)}`);
18
18
  }
19
19
  };
20
+ var assertOptionalColor = (value, name) => {
21
+ if (value === undefined) {
22
+ return;
23
+ }
24
+ assertRequiredColor(value, name);
25
+ };
20
26
 
21
27
  // src/color-utils.ts
22
28
  var DEFAULT_AMOUNT = 1;
@@ -81,6 +87,13 @@ var validateSignedUnitInterval = (value, name) => {
81
87
  var clampColorChannel = (value) => {
82
88
  return Math.max(0, Math.min(255, value));
83
89
  };
90
+ var parseColorRgba = (ctx, color) => {
91
+ ctx.clearRect(0, 0, 1, 1);
92
+ ctx.fillStyle = color;
93
+ ctx.fillRect(0, 0, 1, 1);
94
+ const { data } = ctx.getImageData(0, 0, 1, 1);
95
+ return [data[0], data[1], data[2], data[3]];
96
+ };
84
97
 
85
98
  // src/invert.ts
86
99
  var { createEffect } = Internals;
@@ -98,7 +111,7 @@ var validateInvertParams = (params) => {
98
111
  };
99
112
  var invert = createEffect({
100
113
  type: "remotion/invert",
101
- label: "Invert",
114
+ label: "invert()",
102
115
  documentationLink: "https://www.remotion.dev/docs/effects/invert",
103
116
  backend: "2d",
104
117
  calculateKey: (params) => {
@@ -17,6 +17,12 @@ var assertRequiredColor = (value, name) => {
17
17
  throw new TypeError(`"${name}" must be a non-empty string, but got ${JSON.stringify(value)}`);
18
18
  }
19
19
  };
20
+ var assertOptionalColor = (value, name) => {
21
+ if (value === undefined) {
22
+ return;
23
+ }
24
+ assertRequiredColor(value, name);
25
+ };
20
26
 
21
27
  // src/color-utils.ts
22
28
  var DEFAULT_AMOUNT = 1;
@@ -81,6 +87,13 @@ var validateSignedUnitInterval = (value, name) => {
81
87
  var clampColorChannel = (value) => {
82
88
  return Math.max(0, Math.min(255, value));
83
89
  };
90
+ var parseColorRgba = (ctx, color) => {
91
+ ctx.clearRect(0, 0, 1, 1);
92
+ ctx.fillStyle = color;
93
+ ctx.fillRect(0, 0, 1, 1);
94
+ const { data } = ctx.getImageData(0, 0, 1, 1);
95
+ return [data[0], data[1], data[2], data[3]];
96
+ };
84
97
 
85
98
  // src/mirror/mirror-runtime.ts
86
99
  import { Internals } from "remotion";
@@ -328,7 +341,7 @@ var validateMirrorParams = (params) => {
328
341
  };
329
342
  var mirror = createEffect({
330
343
  type: "remotion/mirror",
331
- label: "Mirror",
344
+ label: "mirror()",
332
345
  documentationLink: "https://www.remotion.dev/docs/effects/mirror",
333
346
  backend: "webgl2",
334
347
  calculateKey: (params) => {