@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
@@ -35,3 +35,5 @@ export declare const validateUnitInterval: (value: number, name: string) => void
35
35
  export declare const validateNonNegative: (value: number, name: string) => void;
36
36
  export declare const validateSignedUnitInterval: (value: number, name: string) => void;
37
37
  export declare const clampColorChannel: (value: number) => number;
38
+ export type ParsedColorRgba = readonly [number, number, number, number];
39
+ export declare const parseColorRgba: (ctx: CanvasRenderingContext2D, color: string) => ParsedColorRgba;
@@ -0,0 +1,31 @@
1
+ export declare const dotGridSchema: {
2
+ readonly dotSize: {
3
+ readonly type: "number";
4
+ readonly min: 0;
5
+ readonly max: 400;
6
+ readonly step: 1;
7
+ readonly default: 16;
8
+ readonly description: "Dot size";
9
+ };
10
+ readonly gridSize: {
11
+ readonly type: "number";
12
+ readonly min: 1;
13
+ readonly max: 400;
14
+ readonly step: 1;
15
+ readonly default: 20;
16
+ readonly description: "Grid size";
17
+ };
18
+ readonly invert: {
19
+ readonly type: "boolean";
20
+ readonly default: false;
21
+ readonly description: "Invert";
22
+ };
23
+ };
24
+ export type DotGridParams = {
25
+ readonly dotSize?: number;
26
+ readonly gridSize?: number;
27
+ readonly invert?: boolean;
28
+ };
29
+ export declare const dotGrid: (params?: (DotGridParams & {
30
+ readonly disabled?: boolean | undefined;
31
+ }) | undefined) => import("remotion").EffectDescriptor<unknown>;
@@ -0,0 +1,54 @@
1
+ import type { ParsedColorRgba } from '../color-utils.js';
2
+ export type DropShadowState = {
3
+ readonly gl: WebGL2RenderingContext;
4
+ readonly programExtract: WebGLProgram;
5
+ readonly programHorizontal: WebGLProgram;
6
+ readonly programVertical: WebGLProgram;
7
+ readonly programComposite: WebGLProgram;
8
+ readonly vao: WebGLVertexArrayObject;
9
+ readonly vbo: WebGLBuffer;
10
+ readonly textureSource: WebGLTexture;
11
+ readonly textureShadowA: WebGLTexture;
12
+ readonly textureShadowB: WebGLTexture;
13
+ readonly framebuffer: WebGLFramebuffer;
14
+ readonly extract: {
15
+ readonly uSource: WebGLUniformLocation | null;
16
+ readonly uColor: WebGLUniformLocation | null;
17
+ readonly uOpacity: WebGLUniformLocation | null;
18
+ };
19
+ readonly horizontal: {
20
+ readonly uRadius: WebGLUniformLocation | null;
21
+ readonly uTexelSize: WebGLUniformLocation | null;
22
+ readonly uSource: WebGLUniformLocation | null;
23
+ };
24
+ readonly vertical: {
25
+ readonly uRadius: WebGLUniformLocation | null;
26
+ readonly uTexelSize: WebGLUniformLocation | null;
27
+ readonly uSource: WebGLUniformLocation | null;
28
+ };
29
+ readonly composite: {
30
+ readonly uSource: WebGLUniformLocation | null;
31
+ readonly uShadow: WebGLUniformLocation | null;
32
+ readonly uOffset: WebGLUniformLocation | null;
33
+ readonly uTexelSize: WebGLUniformLocation | null;
34
+ };
35
+ readonly colorCtx: CanvasRenderingContext2D;
36
+ cachedColorStr: string;
37
+ cachedColorRgba: ParsedColorRgba;
38
+ };
39
+ export declare const setupDropShadow: (target: HTMLCanvasElement) => DropShadowState;
40
+ export declare const cleanupDropShadow: ({ gl, programExtract, programHorizontal, programVertical, programComposite, vao, vbo, textureSource, textureShadowA, textureShadowB, framebuffer, }: DropShadowState) => void;
41
+ type ApplyDropShadowParams = {
42
+ readonly state: DropShadowState;
43
+ readonly source: CanvasImageSource;
44
+ readonly width: number;
45
+ readonly height: number;
46
+ readonly radius: number;
47
+ readonly offsetX: number;
48
+ readonly offsetY: number;
49
+ readonly opacity: number;
50
+ readonly color: ParsedColorRgba;
51
+ readonly flipSourceY: boolean;
52
+ };
53
+ export declare const applyDropShadow: ({ state, source, width, height, radius, offsetX, offsetY, opacity, color, flipSourceY, }: ApplyDropShadowParams) => void;
54
+ export {};
@@ -0,0 +1,5 @@
1
+ export declare const DROP_SHADOW_VS = "#version 300 es\nlayout(location = 0) in vec2 aPos;\nlayout(location = 1) in vec2 aUv;\nout vec2 vUv;\n\nvoid main() {\n\tvUv = aUv;\n\tgl_Position = vec4(aPos, 0.0, 1.0);\n}\n";
2
+ export declare const DROP_SHADOW_EXTRACT_FS = "#version 300 es\nprecision highp float;\n\nin vec2 vUv;\nout vec4 fragColor;\n\nuniform sampler2D uSource;\nuniform vec4 uColor;\nuniform float uOpacity;\n\nvoid main() {\n\tvec4 source = texture(uSource, vUv);\n\tfloat shadowAlpha = source.a * uColor.a * clamp(uOpacity, 0.0, 1.0);\n\n\tfragColor = vec4(uColor.rgb * shadowAlpha, shadowAlpha);\n}\n";
3
+ export declare const DROP_SHADOW_BLUR_FS_HORIZONTAL: string;
4
+ export declare const DROP_SHADOW_BLUR_FS_VERTICAL: string;
5
+ export declare const DROP_SHADOW_COMPOSITE_FS = "#version 300 es\nprecision highp float;\n\nin vec2 vUv;\nout vec4 fragColor;\n\nuniform sampler2D uSource;\nuniform sampler2D uShadow;\nuniform vec2 uOffset;\nuniform vec2 uTexelSize;\n\nvoid main() {\n\tvec4 source = texture(uSource, vUv);\n\tvec2 shadowUv = vUv - vec2(uOffset.x, -uOffset.y) * uTexelSize;\n\tvec4 shadow = vec4(0.0);\n\n\tif (\n\t\tshadowUv.x >= 0.0 &&\n\t\tshadowUv.x <= 1.0 &&\n\t\tshadowUv.y >= 0.0 &&\n\t\tshadowUv.y <= 1.0\n\t) {\n\t\tshadow = texture(uShadow, shadowUv);\n\t}\n\n\tfragColor = source + shadow * (1.0 - source.a);\n}\n";
@@ -0,0 +1,15 @@
1
+ export type DropShadowParams = {
2
+ /** Blur radius of the shadow in pixels. Defaults to `12`. */
3
+ readonly radius?: number;
4
+ /** Horizontal shadow offset in pixels. Defaults to `8`. */
5
+ readonly offsetX?: number;
6
+ /** Vertical shadow offset in pixels. Defaults to `8`. */
7
+ readonly offsetY?: number;
8
+ /** Shadow opacity from `0` to `1`. Defaults to `0.5`. */
9
+ readonly opacity?: number;
10
+ /** Color of the shadow. Defaults to black. */
11
+ readonly color?: string;
12
+ };
13
+ export declare const dropShadow: (params?: (DropShadowParams & {
14
+ readonly disabled?: boolean | undefined;
15
+ }) | undefined) => import("remotion").EffectDescriptor<unknown>;
@@ -0,0 +1 @@
1
+ export { dropShadow, type DropShadowParams } from './drop-shadow/index.js';
@@ -0,0 +1,31 @@
1
+ export declare const duotoneSchema: {
2
+ readonly darkColor: {
3
+ readonly type: "color";
4
+ readonly default: "#000000";
5
+ readonly description: "Dark color";
6
+ };
7
+ readonly lightColor: {
8
+ readonly type: "color";
9
+ readonly default: "#ffffff";
10
+ readonly description: "Light color";
11
+ };
12
+ readonly threshold: {
13
+ readonly type: "number";
14
+ readonly min: 0;
15
+ readonly max: 1;
16
+ readonly step: 0.01;
17
+ readonly default: 0.5;
18
+ readonly description: "Luminance threshold";
19
+ };
20
+ };
21
+ export type DuotoneParams = {
22
+ /** Color used for pixels below the luminance threshold. Defaults to black. */
23
+ readonly darkColor?: string;
24
+ /** Color used for pixels at or above the luminance threshold. Defaults to white. */
25
+ readonly lightColor?: string;
26
+ /** Luminance threshold from `0` to `1`. Defaults to `0.5`. */
27
+ readonly threshold?: number;
28
+ };
29
+ export declare const duotone: (params?: (DuotoneParams & {
30
+ readonly disabled?: boolean | undefined;
31
+ }) | undefined) => import("remotion").EffectDescriptor<unknown>;
@@ -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/barrel-distortion/barrel-distortion-runtime.ts
86
99
  import { Internals } from "remotion";
@@ -301,7 +314,7 @@ var validateBarrelDistortionParams = (params) => {
301
314
  };
302
315
  var barrelDistortion = createEffect({
303
316
  type: "remotion/barrel-distortion",
304
- label: "Barrel Distortion",
317
+ label: "barrelDistortion()",
305
318
  documentationLink: "https://www.remotion.dev/docs/effects/barrel-distortion",
306
319
  backend: "webgl2",
307
320
  calculateKey: (params) => {
package/dist/esm/blur.mjs CHANGED
@@ -17,24 +17,22 @@ 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/blur/blur-runtime.ts
22
28
  import { Internals } from "remotion";
23
29
 
24
- // src/blur/blur-shaders.ts
25
- var BLUR_VS = `#version 300 es
26
- layout(location = 0) in vec2 aPos;
27
- layout(location = 1) in vec2 aUv;
28
- out vec2 vUv;
29
- void main() {
30
- vUv = aUv;
31
- gl_Position = vec4(aPos, 0.0, 1.0);
32
- }
33
- `;
34
- var buildFs = (direction) => {
30
+ // src/gaussian-blur-shader.ts
31
+ var buildGaussianBlurFs = (direction) => {
35
32
  const dirVec = direction === "horizontal" ? "vec2(1.0, 0.0)" : "vec2(0.0, 1.0)";
36
33
  return `#version 300 es
37
34
  precision highp float;
35
+
38
36
  in vec2 vUv;
39
37
  out vec4 fragColor;
40
38
 
@@ -42,7 +40,9 @@ uniform sampler2D uSource;
42
40
  uniform float uRadius;
43
41
  uniform vec2 uTexelSize;
44
42
 
45
- const int KERNEL_HALF = 4;
43
+ const int MIN_KERNEL_HALF = 4;
44
+ const int MAX_KERNEL_HALF = 32;
45
+ const float TARGET_SAMPLE_DISTANCE_PX = 2.0;
46
46
  const vec2 DIRECTION = ${dirVec};
47
47
 
48
48
  void main() {
@@ -51,14 +51,24 @@ void main() {
51
51
  return;
52
52
  }
53
53
 
54
- float pixelStride = uRadius / float(KERNEL_HALF);
54
+ int kernelHalf = int(
55
+ min(
56
+ float(MAX_KERNEL_HALF),
57
+ max(float(MIN_KERNEL_HALF), ceil(uRadius / TARGET_SAMPLE_DISTANCE_PX))
58
+ )
59
+ );
60
+ float pixelStride = uRadius / float(kernelHalf);
55
61
  float sigma = uRadius / 3.0;
56
62
  float twoSigmaSq = 2.0 * sigma * sigma;
57
63
 
58
64
  vec4 sum = vec4(0.0);
59
65
  float weightSum = 0.0;
60
66
 
61
- for (int i = -KERNEL_HALF; i <= KERNEL_HALF; ++i) {
67
+ for (int i = -MAX_KERNEL_HALF; i <= MAX_KERNEL_HALF; ++i) {
68
+ if (abs(i) > kernelHalf) {
69
+ continue;
70
+ }
71
+
62
72
  float offsetPx = float(i) * pixelStride;
63
73
  float w = exp(-(offsetPx * offsetPx) / twoSigmaSq);
64
74
  vec2 uv = vUv + DIRECTION * uTexelSize * offsetPx;
@@ -70,8 +80,19 @@ void main() {
70
80
  }
71
81
  `;
72
82
  };
73
- var BLUR_FS_HORIZONTAL = buildFs("horizontal");
74
- var BLUR_FS_VERTICAL = buildFs("vertical");
83
+
84
+ // src/blur/blur-shaders.ts
85
+ var BLUR_VS = `#version 300 es
86
+ layout(location = 0) in vec2 aPos;
87
+ layout(location = 1) in vec2 aUv;
88
+ out vec2 vUv;
89
+ void main() {
90
+ vUv = aUv;
91
+ gl_Position = vec4(aPos, 0.0, 1.0);
92
+ }
93
+ `;
94
+ var BLUR_FS_HORIZONTAL = buildGaussianBlurFs("horizontal");
95
+ var BLUR_FS_VERTICAL = buildGaussianBlurFs("vertical");
75
96
 
76
97
  // src/blur/blur-runtime.ts
77
98
  var { createWebGL2ContextError } = Internals;
@@ -389,7 +410,7 @@ var validateBlurParams = (params) => {
389
410
  };
390
411
  var blur = createEffect({
391
412
  type: "remotion/blur",
392
- label: "Blur",
413
+ label: "blur()",
393
414
  documentationLink: "https://www.remotion.dev/docs/effects/blur",
394
415
  backend: "webgl2",
395
416
  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/brightness.ts
86
99
  var { createEffect } = Internals;
@@ -98,7 +111,7 @@ var validateBrightnessParams = (params) => {
98
111
  };
99
112
  var brightness = createEffect({
100
113
  type: "remotion/brightness",
101
- label: "Brightness",
114
+ label: "brightness()",
102
115
  documentationLink: "https://www.remotion.dev/docs/effects/brightness",
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/chromatic-aberration/chromatic-aberration-runtime.ts
86
99
  import { Internals } from "remotion";
@@ -301,7 +314,7 @@ var validateChromaticAberrationParams = (params) => {
301
314
  };
302
315
  var chromaticAberration = createEffect({
303
316
  type: "remotion/chromatic-aberration",
304
- label: "Chromatic Aberration",
317
+ label: "chromaticAberration()",
305
318
  documentationLink: "https://www.remotion.dev/docs/effects/chromatic-aberration",
306
319
  backend: "webgl2",
307
320
  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/contrast.ts
86
99
  var { createEffect } = Internals;
@@ -98,7 +111,7 @@ var validateContrastParams = (params) => {
98
111
  };
99
112
  var contrast = createEffect({
100
113
  type: "remotion/contrast",
101
- label: "Contrast",
114
+ label: "contrast()",
102
115
  documentationLink: "https://www.remotion.dev/docs/effects/contrast",
103
116
  backend: "2d",
104
117
  calculateKey: (params) => {