@remotion/effects 4.0.481 → 4.0.483

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.
@@ -0,0 +1,604 @@
1
+ // src/radial-progressive-blur/index.ts
2
+ import { Internals as Internals2 } 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
+ var assertOptionalBoolean = (value, name) => {
27
+ if (value === undefined) {
28
+ return;
29
+ }
30
+ if (typeof value !== "boolean") {
31
+ throw new TypeError(`"${name}" must be a boolean, but got ${JSON.stringify(value)}`);
32
+ }
33
+ };
34
+
35
+ // src/color-utils.ts
36
+ var DEFAULT_AMOUNT = 1;
37
+ var DEFAULT_BRIGHTNESS_AMOUNT = 0;
38
+ var DEFAULT_HUE_DEGREES = 0;
39
+ var colorAmountSchema = {
40
+ type: "number",
41
+ min: 0,
42
+ max: 1,
43
+ step: 0.01,
44
+ default: DEFAULT_AMOUNT,
45
+ description: "Amount",
46
+ hiddenFromList: false
47
+ };
48
+ var colorMultiplierSchema = {
49
+ type: "number",
50
+ min: 0,
51
+ step: 0.01,
52
+ default: DEFAULT_AMOUNT,
53
+ description: "Amount",
54
+ hiddenFromList: false
55
+ };
56
+ var brightnessAmountSchema = {
57
+ type: "number",
58
+ min: -1,
59
+ max: 1,
60
+ step: 0.01,
61
+ default: DEFAULT_BRIGHTNESS_AMOUNT,
62
+ description: "Amount",
63
+ hiddenFromList: false
64
+ };
65
+ var hueDegreesSchema = {
66
+ type: "rotation-degrees",
67
+ step: 1,
68
+ default: DEFAULT_HUE_DEGREES,
69
+ description: "Degrees"
70
+ };
71
+ var assertOptionalFiniteNumber = (value, name) => {
72
+ if (value === undefined) {
73
+ return;
74
+ }
75
+ assertRequiredFiniteNumber(value, name);
76
+ };
77
+ var validateUnitInterval = (value, name) => {
78
+ if (value < 0) {
79
+ throw new TypeError(`"${name}" must be >= 0, but got ${JSON.stringify(value)}`);
80
+ }
81
+ if (value > 1) {
82
+ throw new TypeError(`"${name}" must be <= 1, but got ${JSON.stringify(value)}`);
83
+ }
84
+ };
85
+ var validateNonNegative = (value, name) => {
86
+ if (value < 0) {
87
+ throw new TypeError(`"${name}" must be >= 0, but got ${JSON.stringify(value)}`);
88
+ }
89
+ };
90
+ var validateSignedUnitInterval = (value, name) => {
91
+ if (value < -1) {
92
+ throw new TypeError(`"${name}" must be >= -1, but got ${JSON.stringify(value)}`);
93
+ }
94
+ if (value > 1) {
95
+ throw new TypeError(`"${name}" must be <= 1, but got ${JSON.stringify(value)}`);
96
+ }
97
+ };
98
+ var clampColorChannel = (value) => {
99
+ return Math.max(0, Math.min(255, value));
100
+ };
101
+ var parseColorRgba = (ctx, color) => {
102
+ ctx.clearRect(0, 0, 1, 1);
103
+ ctx.fillStyle = color;
104
+ ctx.fillRect(0, 0, 1, 1);
105
+ const { data } = ctx.getImageData(0, 0, 1, 1);
106
+ return [data[0], data[1], data[2], data[3]];
107
+ };
108
+
109
+ // src/radial-progressive-blur/radial-progressive-blur-runtime.ts
110
+ import { Internals } from "remotion";
111
+
112
+ // src/radial-progressive-blur/radial-progressive-blur-shaders.ts
113
+ var RADIAL_PROGRESSIVE_BLUR_VS = `#version 300 es
114
+ layout(location = 0) in vec2 aPos;
115
+ layout(location = 1) in vec2 aUv;
116
+ out vec2 vUv;
117
+ void main() {
118
+ vUv = aUv;
119
+ gl_Position = vec4(aPos, 0.0, 1.0);
120
+ }
121
+ `;
122
+ var buildRadialProgressiveBlurFs = (direction) => {
123
+ const dirVec = direction === "horizontal" ? "vec2(1.0, 0.0)" : "vec2(0.0, 1.0)";
124
+ return `#version 300 es
125
+ precision highp float;
126
+
127
+ in vec2 vUv;
128
+ out vec4 fragColor;
129
+
130
+ uniform sampler2D uSource;
131
+ uniform vec2 uTexelSize;
132
+ uniform vec2 uCenter;
133
+ uniform float uWidth;
134
+ uniform float uHeight;
135
+ uniform float uRotation;
136
+ uniform float uStart;
137
+ uniform float uStartBlur;
138
+ uniform float uEndBlur;
139
+
140
+ const int MIN_KERNEL_HALF = 4;
141
+ const int MAX_KERNEL_HALF = 32;
142
+ const float TARGET_SAMPLE_DISTANCE_PX = 2.0;
143
+ const vec2 DIRECTION = ${dirVec};
144
+
145
+ float progressiveRadius(vec2 uv) {
146
+ vec2 radii = vec2(uWidth / uTexelSize.x, uHeight / uTexelSize.y) * 0.5;
147
+
148
+ if (radii.x <= 0.0000001 || radii.y <= 0.0000001) {
149
+ return max(0.0, uStartBlur);
150
+ }
151
+
152
+ vec2 delta = (uv - uCenter) / uTexelSize;
153
+ float angle = radians(uRotation);
154
+ float c = cos(angle);
155
+ float s = sin(angle);
156
+ vec2 local = vec2(
157
+ c * delta.x + s * delta.y,
158
+ -s * delta.x + c * delta.y
159
+ );
160
+ float ellipseProgress = clamp(length(local / radii), 0.0, 1.0);
161
+ float distance = 1.0 - uStart;
162
+ float progress = abs(distance) <= 0.0000001
163
+ ? step(uStart, ellipseProgress)
164
+ : clamp((ellipseProgress - uStart) / distance, 0.0, 1.0);
165
+ return max(0.0, mix(uStartBlur, uEndBlur, progress));
166
+ }
167
+
168
+ void main() {
169
+ // Public UV coordinates use top-left origin, matching canvas/CSS coordinates.
170
+ float radius = progressiveRadius(vec2(vUv.x, 1.0 - vUv.y));
171
+ if (radius <= 0.0) {
172
+ fragColor = texture(uSource, vUv);
173
+ return;
174
+ }
175
+
176
+ int kernelHalf = int(
177
+ min(
178
+ float(MAX_KERNEL_HALF),
179
+ max(float(MIN_KERNEL_HALF), ceil(radius / TARGET_SAMPLE_DISTANCE_PX))
180
+ )
181
+ );
182
+ float pixelStride = radius / float(kernelHalf);
183
+ float sigma = max(radius / 3.0, 0.0001);
184
+ float twoSigmaSq = 2.0 * sigma * sigma;
185
+
186
+ vec4 sum = vec4(0.0);
187
+ float weightSum = 0.0;
188
+
189
+ for (int i = -MAX_KERNEL_HALF; i <= MAX_KERNEL_HALF; ++i) {
190
+ if (abs(i) > kernelHalf) {
191
+ continue;
192
+ }
193
+
194
+ float offsetPx = float(i) * pixelStride;
195
+ float w = exp(-(offsetPx * offsetPx) / twoSigmaSq);
196
+ vec2 uv = vUv + DIRECTION * uTexelSize * offsetPx;
197
+ sum += texture(uSource, uv) * w;
198
+ weightSum += w;
199
+ }
200
+
201
+ fragColor = sum / weightSum;
202
+ }
203
+ `;
204
+ };
205
+
206
+ // src/radial-progressive-blur/radial-progressive-blur-runtime.ts
207
+ var { createWebGL2ContextError } = Internals;
208
+ var compileShader = (gl, type, source) => {
209
+ const shader = gl.createShader(type);
210
+ if (!shader) {
211
+ throw new Error("Failed to create WebGL shader");
212
+ }
213
+ gl.shaderSource(shader, source);
214
+ gl.compileShader(shader);
215
+ if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
216
+ const log = gl.getShaderInfoLog(shader);
217
+ gl.deleteShader(shader);
218
+ throw new Error(`Radial progressive blur shader compile failed: ${log ?? "(no log)"}`);
219
+ }
220
+ return shader;
221
+ };
222
+ var linkProgram = (gl, vs, fs) => {
223
+ const program = gl.createProgram();
224
+ if (!program) {
225
+ throw new Error("Failed to create WebGL program");
226
+ }
227
+ gl.attachShader(program, vs);
228
+ gl.attachShader(program, fs);
229
+ gl.linkProgram(program);
230
+ if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
231
+ const log = gl.getProgramInfoLog(program);
232
+ gl.deleteProgram(program);
233
+ throw new Error(`Radial progressive blur program link failed: ${log ?? "(no log)"}`);
234
+ }
235
+ return program;
236
+ };
237
+ var createProgram = (gl, vertexSource, fragmentSource) => {
238
+ const vs = compileShader(gl, gl.VERTEX_SHADER, vertexSource);
239
+ const fs = compileShader(gl, gl.FRAGMENT_SHADER, fragmentSource);
240
+ const program = linkProgram(gl, vs, fs);
241
+ gl.deleteShader(vs);
242
+ gl.deleteShader(fs);
243
+ return program;
244
+ };
245
+ var getUniforms = (gl, program) => ({
246
+ uSource: gl.getUniformLocation(program, "uSource"),
247
+ uTexelSize: gl.getUniformLocation(program, "uTexelSize"),
248
+ uCenter: gl.getUniformLocation(program, "uCenter"),
249
+ uWidth: gl.getUniformLocation(program, "uWidth"),
250
+ uHeight: gl.getUniformLocation(program, "uHeight"),
251
+ uRotation: gl.getUniformLocation(program, "uRotation"),
252
+ uStart: gl.getUniformLocation(program, "uStart"),
253
+ uStartBlur: gl.getUniformLocation(program, "uStartBlur"),
254
+ uEndBlur: gl.getUniformLocation(program, "uEndBlur")
255
+ });
256
+ var createRgbaTexture = (gl) => {
257
+ const texture = gl.createTexture();
258
+ if (!texture) {
259
+ throw new Error("Failed to create WebGL texture");
260
+ }
261
+ gl.bindTexture(gl.TEXTURE_2D, texture);
262
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
263
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
264
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
265
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
266
+ gl.bindTexture(gl.TEXTURE_2D, null);
267
+ return texture;
268
+ };
269
+ var setupRadialProgressiveBlur = (target) => {
270
+ const gl = target.getContext("webgl2", {
271
+ premultipliedAlpha: true,
272
+ alpha: true,
273
+ preserveDrawingBuffer: true
274
+ });
275
+ if (!gl) {
276
+ throw createWebGL2ContextError("radial progressive blur effect");
277
+ }
278
+ gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true);
279
+ const programHorizontal = createProgram(gl, RADIAL_PROGRESSIVE_BLUR_VS, buildRadialProgressiveBlurFs("horizontal"));
280
+ const programVertical = createProgram(gl, RADIAL_PROGRESSIVE_BLUR_VS, buildRadialProgressiveBlurFs("vertical"));
281
+ const vao = gl.createVertexArray();
282
+ if (!vao) {
283
+ throw new Error("Failed to create WebGL vertex array");
284
+ }
285
+ gl.bindVertexArray(vao);
286
+ const data = new Float32Array([
287
+ -1,
288
+ -1,
289
+ 0,
290
+ 0,
291
+ 1,
292
+ -1,
293
+ 1,
294
+ 0,
295
+ -1,
296
+ 1,
297
+ 0,
298
+ 1,
299
+ 1,
300
+ 1,
301
+ 1,
302
+ 1
303
+ ]);
304
+ const vbo = gl.createBuffer();
305
+ if (!vbo) {
306
+ throw new Error("Failed to create WebGL buffer");
307
+ }
308
+ gl.bindBuffer(gl.ARRAY_BUFFER, vbo);
309
+ gl.bufferData(gl.ARRAY_BUFFER, data, gl.STATIC_DRAW);
310
+ gl.enableVertexAttribArray(0);
311
+ gl.vertexAttribPointer(0, 2, gl.FLOAT, false, 16, 0);
312
+ gl.enableVertexAttribArray(1);
313
+ gl.vertexAttribPointer(1, 2, gl.FLOAT, false, 16, 8);
314
+ gl.bindVertexArray(null);
315
+ const textureSource = createRgbaTexture(gl);
316
+ const textureIntermediate = createRgbaTexture(gl);
317
+ const framebuffer = gl.createFramebuffer();
318
+ if (!framebuffer) {
319
+ throw new Error("Failed to create WebGL framebuffer");
320
+ }
321
+ const w = Math.max(1, target.width);
322
+ const h = Math.max(1, target.height);
323
+ gl.bindTexture(gl.TEXTURE_2D, textureIntermediate);
324
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, w, h, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
325
+ gl.bindTexture(gl.TEXTURE_2D, null);
326
+ gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);
327
+ gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, textureIntermediate, 0);
328
+ const status = gl.checkFramebufferStatus(gl.FRAMEBUFFER);
329
+ gl.bindFramebuffer(gl.FRAMEBUFFER, null);
330
+ if (status !== gl.FRAMEBUFFER_COMPLETE) {
331
+ throw new Error(`Radial progressive blur framebuffer incomplete: 0x${status.toString(16)}`);
332
+ }
333
+ return {
334
+ gl,
335
+ programHorizontal,
336
+ programVertical,
337
+ vao,
338
+ vbo,
339
+ textureSource,
340
+ textureIntermediate,
341
+ framebuffer,
342
+ horizontal: getUniforms(gl, programHorizontal),
343
+ vertical: getUniforms(gl, programVertical)
344
+ };
345
+ };
346
+ var cleanupRadialProgressiveBlur = (state) => {
347
+ const {
348
+ gl,
349
+ programHorizontal,
350
+ programVertical,
351
+ vao,
352
+ vbo,
353
+ textureSource,
354
+ textureIntermediate,
355
+ framebuffer
356
+ } = state;
357
+ gl.deleteFramebuffer(framebuffer);
358
+ gl.deleteTexture(textureSource);
359
+ gl.deleteTexture(textureIntermediate);
360
+ gl.deleteBuffer(vbo);
361
+ gl.deleteProgram(programHorizontal);
362
+ gl.deleteProgram(programVertical);
363
+ gl.deleteVertexArray(vao);
364
+ };
365
+ var uploadSource = ({
366
+ gl,
367
+ textureSource,
368
+ textureIntermediate,
369
+ source,
370
+ width,
371
+ height,
372
+ flipSourceY
373
+ }) => {
374
+ gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, flipSourceY);
375
+ gl.bindTexture(gl.TEXTURE_2D, textureSource);
376
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, source);
377
+ gl.bindTexture(gl.TEXTURE_2D, textureIntermediate);
378
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
379
+ gl.bindTexture(gl.TEXTURE_2D, null);
380
+ };
381
+ var setUniforms = ({
382
+ gl,
383
+ uniforms,
384
+ width,
385
+ height,
386
+ params
387
+ }) => {
388
+ if (uniforms.uSource)
389
+ gl.uniform1i(uniforms.uSource, 0);
390
+ if (uniforms.uTexelSize)
391
+ gl.uniform2f(uniforms.uTexelSize, 1 / width, 1 / height);
392
+ if (uniforms.uCenter)
393
+ gl.uniform2f(uniforms.uCenter, params.center[0], params.center[1]);
394
+ if (uniforms.uWidth)
395
+ gl.uniform1f(uniforms.uWidth, params.width);
396
+ if (uniforms.uHeight)
397
+ gl.uniform1f(uniforms.uHeight, params.height);
398
+ if (uniforms.uRotation)
399
+ gl.uniform1f(uniforms.uRotation, params.rotation);
400
+ if (uniforms.uStart)
401
+ gl.uniform1f(uniforms.uStart, params.start);
402
+ if (uniforms.uStartBlur)
403
+ gl.uniform1f(uniforms.uStartBlur, params.startBlur);
404
+ if (uniforms.uEndBlur)
405
+ gl.uniform1f(uniforms.uEndBlur, params.endBlur);
406
+ };
407
+ var drawFullscreenQuad = (state) => {
408
+ const { gl, vao } = state;
409
+ gl.bindVertexArray(vao);
410
+ gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
411
+ gl.bindVertexArray(null);
412
+ };
413
+ var applyRadialProgressiveBlur = ({
414
+ state,
415
+ source,
416
+ width,
417
+ height,
418
+ params,
419
+ flipSourceY
420
+ }) => {
421
+ const {
422
+ gl,
423
+ programHorizontal,
424
+ programVertical,
425
+ textureSource,
426
+ textureIntermediate,
427
+ framebuffer
428
+ } = state;
429
+ gl.viewport(0, 0, width, height);
430
+ uploadSource({
431
+ gl,
432
+ textureSource,
433
+ textureIntermediate,
434
+ source,
435
+ width,
436
+ height,
437
+ flipSourceY
438
+ });
439
+ gl.clearColor(0, 0, 0, 0);
440
+ gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);
441
+ gl.clear(gl.COLOR_BUFFER_BIT);
442
+ gl.activeTexture(gl.TEXTURE0);
443
+ gl.bindTexture(gl.TEXTURE_2D, textureSource);
444
+ gl.useProgram(programHorizontal);
445
+ setUniforms({
446
+ gl,
447
+ uniforms: state.horizontal,
448
+ width,
449
+ height,
450
+ params
451
+ });
452
+ drawFullscreenQuad(state);
453
+ gl.bindFramebuffer(gl.FRAMEBUFFER, null);
454
+ gl.clear(gl.COLOR_BUFFER_BIT);
455
+ gl.bindTexture(gl.TEXTURE_2D, textureIntermediate);
456
+ gl.useProgram(programVertical);
457
+ setUniforms({
458
+ gl,
459
+ uniforms: state.vertical,
460
+ width,
461
+ height,
462
+ params
463
+ });
464
+ drawFullscreenQuad(state);
465
+ gl.bindTexture(gl.TEXTURE_2D, null);
466
+ gl.useProgram(null);
467
+ };
468
+
469
+ // src/radial-progressive-blur/index.ts
470
+ var { createEffect } = Internals2;
471
+ var DEFAULT_CENTER = [0.5, 0.5];
472
+ var DEFAULT_WIDTH = 1;
473
+ var DEFAULT_HEIGHT = 1;
474
+ var DEFAULT_ROTATION = 0;
475
+ var DEFAULT_START = 0;
476
+ var DEFAULT_START_BLUR = 0;
477
+ var DEFAULT_END_BLUR = 50;
478
+ var radialProgressiveBlurSchema = {
479
+ center: {
480
+ type: "uv-coordinate",
481
+ min: -1,
482
+ max: 2,
483
+ step: 0.01,
484
+ default: DEFAULT_CENTER,
485
+ description: "Center",
486
+ visual: {
487
+ type: "ellipse",
488
+ width: "width",
489
+ height: "height",
490
+ rotation: "rotation",
491
+ innerScale: "start"
492
+ }
493
+ },
494
+ width: {
495
+ type: "number",
496
+ min: 0,
497
+ step: 0.01,
498
+ default: DEFAULT_WIDTH,
499
+ description: "Width",
500
+ hiddenFromList: false
501
+ },
502
+ height: {
503
+ type: "number",
504
+ min: 0,
505
+ step: 0.01,
506
+ default: DEFAULT_HEIGHT,
507
+ description: "Height",
508
+ hiddenFromList: false
509
+ },
510
+ rotation: {
511
+ type: "rotation-degrees",
512
+ step: 1,
513
+ default: DEFAULT_ROTATION,
514
+ description: "Rotation"
515
+ },
516
+ start: {
517
+ type: "number",
518
+ min: 0,
519
+ max: 1,
520
+ step: 0.01,
521
+ default: DEFAULT_START,
522
+ description: "Start",
523
+ hiddenFromList: false
524
+ },
525
+ startBlur: {
526
+ type: "number",
527
+ min: 0,
528
+ max: 200,
529
+ step: 1,
530
+ default: DEFAULT_START_BLUR,
531
+ description: "Start blur",
532
+ hiddenFromList: false
533
+ },
534
+ endBlur: {
535
+ type: "number",
536
+ min: 0,
537
+ max: 200,
538
+ step: 1,
539
+ default: DEFAULT_END_BLUR,
540
+ description: "End blur",
541
+ hiddenFromList: false
542
+ }
543
+ };
544
+ var clampBlur = (value) => Math.max(0, value);
545
+ var resolveRadialProgressiveBlurParams = (params) => ({
546
+ center: [
547
+ ...params.center ?? DEFAULT_CENTER
548
+ ],
549
+ width: params.width ?? DEFAULT_WIDTH,
550
+ height: params.height ?? DEFAULT_HEIGHT,
551
+ rotation: params.rotation ?? DEFAULT_ROTATION,
552
+ start: params.start ?? DEFAULT_START,
553
+ startBlur: clampBlur(params.startBlur ?? DEFAULT_START_BLUR),
554
+ endBlur: clampBlur(params.endBlur ?? DEFAULT_END_BLUR)
555
+ });
556
+ var assertOptionalUvCoordinate = (value, name) => {
557
+ if (value === undefined) {
558
+ return;
559
+ }
560
+ if (!Array.isArray(value) || value.length !== 2 || value.some((item) => typeof item !== "number" || !Number.isFinite(item))) {
561
+ throw new TypeError(`"${name}" must be a [number, number] tuple`);
562
+ }
563
+ };
564
+ var validateRadialProgressiveBlurParams = (params) => {
565
+ assertEffectParamsObject(params, "Radial progressive blur");
566
+ assertOptionalUvCoordinate(params.center, "center");
567
+ assertOptionalFiniteNumber(params.width, "width");
568
+ assertOptionalFiniteNumber(params.height, "height");
569
+ assertOptionalFiniteNumber(params.rotation, "rotation");
570
+ validateNonNegative(params.width ?? DEFAULT_WIDTH, "width");
571
+ validateNonNegative(params.height ?? DEFAULT_HEIGHT, "height");
572
+ assertOptionalFiniteNumber(params.start, "start");
573
+ validateUnitInterval(params.start ?? DEFAULT_START, "start");
574
+ assertOptionalFiniteNumber(params.startBlur, "startBlur");
575
+ assertOptionalFiniteNumber(params.endBlur, "endBlur");
576
+ };
577
+ var radialProgressiveBlur = createEffect({
578
+ type: "dev.remotion.effects.radialProgressiveBlur",
579
+ label: "radialProgressiveBlur()",
580
+ documentationLink: "https://www.remotion.dev/docs/effects/radial-progressive-blur",
581
+ backend: "webgl2",
582
+ calculateKey: (params) => {
583
+ const r = resolveRadialProgressiveBlurParams(params);
584
+ return `radial-progressive-blur-${r.center.join(":")}-${r.width}-${r.height}-${r.rotation}-${r.start}-${r.startBlur}-${r.endBlur}`;
585
+ },
586
+ setup: (target) => setupRadialProgressiveBlur(target),
587
+ apply: ({ source, width, height, params, state, flipSourceY }) => {
588
+ const r = resolveRadialProgressiveBlurParams(params);
589
+ applyRadialProgressiveBlur({
590
+ state,
591
+ source,
592
+ width,
593
+ height,
594
+ params: r,
595
+ flipSourceY
596
+ });
597
+ },
598
+ cleanup: (state) => cleanupRadialProgressiveBlur(state),
599
+ schema: radialProgressiveBlurSchema,
600
+ validateParams: validateRadialProgressiveBlurParams
601
+ });
602
+ export {
603
+ radialProgressiveBlur
604
+ };
@@ -39,7 +39,7 @@ export declare const gridlinesSchema: {
39
39
  readonly type: "rotation-degrees";
40
40
  readonly min: -180;
41
41
  readonly max: 180;
42
- readonly step: 1;
42
+ readonly step: 0.1;
43
43
  readonly default: 0;
44
44
  readonly description: "Rotation X";
45
45
  };
@@ -47,7 +47,7 @@ export declare const gridlinesSchema: {
47
47
  readonly type: "rotation-degrees";
48
48
  readonly min: -180;
49
49
  readonly max: 180;
50
- readonly step: 1;
50
+ readonly step: 0.1;
51
51
  readonly default: 0;
52
52
  readonly description: "Rotation Y";
53
53
  };
@@ -25,7 +25,10 @@ export declare const halftoneLinearGradientSchema: {
25
25
  readonly step: 0.01;
26
26
  readonly default: readonly [0, 0.5];
27
27
  readonly description: "First stop position";
28
- readonly lineTo: "secondStopPosition";
28
+ readonly visual: {
29
+ readonly type: "line";
30
+ readonly to: "secondStopPosition";
31
+ };
29
32
  };
30
33
  readonly secondStopPosition: {
31
34
  readonly type: "uv-coordinate";
package/dist/index.d.ts CHANGED
@@ -3,3 +3,4 @@ export { pattern, type PatternOrigin, type PatternParams } from './pattern.js';
3
3
  export { rings, type RingsCenter, type RingsParams } from './rings.js';
4
4
  export { gridlines, type GridlinesParams } from './gridlines.js';
5
5
  export { zigzag, type ZigzagDirection, type ZigzagParams } from './zigzag.js';
6
+ export { cornerPin, type CornerPinParams, type CornerPinUvCoordinate, } from './corner-pin/index.js';
@@ -0,0 +1,19 @@
1
+ export type LightTrailParams = {
2
+ /** Direction in which the trail extends, in degrees. Defaults to `180`. */
3
+ readonly direction?: number;
4
+ /** Length of the trail in pixels. Defaults to `80`. */
5
+ readonly distance?: number;
6
+ /** Brightness multiplier for the trail. Defaults to `1`. */
7
+ readonly intensity?: number;
8
+ /** Falloff from one sample to the next. Defaults to `0.9`. */
9
+ readonly decay?: number;
10
+ /** Luminance or alpha threshold from `0` to `1`. Defaults to `0`. */
11
+ readonly threshold?: number;
12
+ /** Number of samples used for the trail. Defaults to `32`. */
13
+ readonly samples?: number;
14
+ /** Color of the trail. Defaults to white. */
15
+ readonly color?: string;
16
+ };
17
+ export declare const lightTrail: (params?: (LightTrailParams & {
18
+ readonly disabled?: boolean | undefined;
19
+ }) | undefined) => import("remotion").EffectDescriptor<unknown>;
@@ -0,0 +1,38 @@
1
+ import type { ParsedColorRgba } from '../color-utils.js';
2
+ export type LightTrailState = {
3
+ readonly gl: WebGL2RenderingContext;
4
+ readonly program: WebGLProgram;
5
+ readonly vao: WebGLVertexArrayObject;
6
+ readonly vbo: WebGLBuffer;
7
+ readonly textureSource: WebGLTexture;
8
+ readonly uniforms: {
9
+ readonly uSource: WebGLUniformLocation | null;
10
+ readonly uDirection: WebGLUniformLocation | null;
11
+ readonly uTexelSize: WebGLUniformLocation | null;
12
+ readonly uColor: WebGLUniformLocation | null;
13
+ readonly uDistance: WebGLUniformLocation | null;
14
+ readonly uIntensity: WebGLUniformLocation | null;
15
+ readonly uDecay: WebGLUniformLocation | null;
16
+ readonly uThreshold: WebGLUniformLocation | null;
17
+ readonly uSamples: WebGLUniformLocation | null;
18
+ };
19
+ readonly colorCtx: CanvasRenderingContext2D;
20
+ cachedColorStr: string;
21
+ cachedColorRgba: ParsedColorRgba;
22
+ };
23
+ export declare const setupLightTrail: (target: HTMLCanvasElement) => LightTrailState;
24
+ export declare const cleanupLightTrail: (state: LightTrailState) => void;
25
+ export declare const applyLightTrail: ({ state, source, width, height, direction, distance, intensity, decay, threshold, samples, color, flipSourceY, }: {
26
+ readonly state: LightTrailState;
27
+ readonly source: CanvasImageSource;
28
+ readonly width: number;
29
+ readonly height: number;
30
+ readonly direction: number;
31
+ readonly distance: number;
32
+ readonly intensity: number;
33
+ readonly decay: number;
34
+ readonly threshold: number;
35
+ readonly samples: number;
36
+ readonly color: ParsedColorRgba;
37
+ readonly flipSourceY: boolean;
38
+ }) => void;
@@ -0,0 +1,2 @@
1
+ export declare const LIGHT_TRAIL_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 LIGHT_TRAIL_FS = "#version 300 es\nprecision highp float;\n\nin vec2 vUv;\nout vec4 fragColor;\n\nuniform sampler2D uSource;\nuniform vec2 uDirection;\nuniform vec2 uTexelSize;\nuniform vec4 uColor;\nuniform float uDistance;\nuniform float uIntensity;\nuniform float uDecay;\nuniform float uThreshold;\nuniform int uSamples;\n\nconst int MAX_SAMPLES = 64;\n\nfloat getContribution(vec4 color) {\n\tif (color.a <= 0.001) {\n\t\treturn 0.0;\n\t}\n\n\tvec3 rgb = color.rgb / color.a;\n\tfloat luminance = dot(rgb, vec3(0.299, 0.587, 0.114));\n\tfloat source = max(color.a, luminance);\n\tfloat threshold = clamp(uThreshold, 0.0, 1.0);\n\n\tif (threshold >= 1.0) {\n\t\treturn step(1.0, source);\n\t}\n\n\treturn clamp((source - threshold) / max(1.0 - threshold, 0.0001), 0.0, 1.0);\n}\n\nvoid main() {\n\tvec4 source = texture(uSource, vUv);\n\tvec4 trail = vec4(0.0);\n\tfloat sampleCount = float(max(uSamples, 1));\n\n\tfor (int i = 1; i <= MAX_SAMPLES; i++) {\n\t\tif (i > uSamples) {\n\t\t\tbreak;\n\t\t}\n\n\t\tfloat progress = float(i) / sampleCount;\n\t\tvec2 offset = uDirection * uTexelSize * uDistance * progress;\n\t\tvec4 sampleColor = texture(uSource, vUv - offset);\n\t\tfloat contribution = getContribution(sampleColor);\n\t\tfloat weight = pow(clamp(uDecay, 0.0, 1.0), float(i - 1)) * contribution;\n\t\tfloat alpha = sampleColor.a * uColor.a * weight;\n\n\t\ttrail += vec4(uColor.rgb * alpha, alpha);\n\t}\n\n\ttrail *= max(uIntensity, 0.0) / sampleCount;\n\n\tvec4 outColor = source + trail;\n\tfragColor = vec4(min(outColor.rgb, vec3(1.0)), min(outColor.a, 1.0));\n}\n";
@@ -0,0 +1 @@
1
+ export { lightTrail, type LightTrailParams } from './light-trail/index.js';