@remotion/effects 4.0.461 → 4.0.462

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,646 +1 @@
1
- // src/blur/blur-horizontal.ts
2
- import { Internals } from "remotion";
3
-
4
- // src/blur/blur-shaders.ts
5
- var BLUR_VS = `#version 300 es
6
- in vec2 aPos;
7
- in vec2 aUv;
8
- out vec2 vUv;
9
- void main() {
10
- vUv = aUv;
11
- gl_Position = vec4(aPos, 0.0, 1.0);
12
- }
13
- `;
14
- var buildFs = (direction) => {
15
- const dirVec = direction === "horizontal" ? "vec2(1.0, 0.0)" : "vec2(0.0, 1.0)";
16
- return `#version 300 es
17
- precision highp float;
18
- in vec2 vUv;
19
- out vec4 fragColor;
20
-
21
- uniform sampler2D uSource;
22
- uniform float uRadius;
23
- uniform vec2 uTexelSize;
24
-
25
- const int KERNEL_HALF = 4;
26
- const vec2 DIRECTION = ${dirVec};
27
-
28
- void main() {
29
- if (uRadius <= 0.0) {
30
- fragColor = texture(uSource, vUv);
31
- return;
32
- }
33
-
34
- float pixelStride = uRadius / float(KERNEL_HALF);
35
- float sigma = uRadius / 3.0;
36
- float twoSigmaSq = 2.0 * sigma * sigma;
37
-
38
- vec4 sum = vec4(0.0);
39
- float weightSum = 0.0;
40
-
41
- for (int i = -KERNEL_HALF; i <= KERNEL_HALF; ++i) {
42
- float offsetPx = float(i) * pixelStride;
43
- float w = exp(-(offsetPx * offsetPx) / twoSigmaSq);
44
- vec2 uv = vUv + DIRECTION * uTexelSize * offsetPx;
45
- sum += texture(uSource, uv) * w;
46
- weightSum += w;
47
- }
48
-
49
- fragColor = sum / weightSum;
50
- }
51
- `;
52
- };
53
- var BLUR_FS_HORIZONTAL = buildFs("horizontal");
54
- var BLUR_FS_VERTICAL = buildFs("vertical");
55
-
56
- // src/blur/blur-runtime.ts
57
- var compileShader = (gl, type, source) => {
58
- const shader = gl.createShader(type);
59
- if (!shader) {
60
- throw new Error("Failed to create WebGL shader");
61
- }
62
- gl.shaderSource(shader, source);
63
- gl.compileShader(shader);
64
- if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
65
- const log = gl.getShaderInfoLog(shader);
66
- gl.deleteShader(shader);
67
- throw new Error(`Shader compile failed: ${log ?? "(no log)"}`);
68
- }
69
- return shader;
70
- };
71
- var linkProgram = (gl, vs, fs) => {
72
- const program = gl.createProgram();
73
- if (!program) {
74
- throw new Error("Failed to create WebGL program");
75
- }
76
- gl.attachShader(program, vs);
77
- gl.attachShader(program, fs);
78
- gl.linkProgram(program);
79
- if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
80
- const log = gl.getProgramInfoLog(program);
81
- gl.deleteProgram(program);
82
- throw new Error(`Program link failed: ${log ?? "(no log)"}`);
83
- }
84
- return program;
85
- };
86
- var setupBlur = (target, fragmentSource) => {
87
- const gl = target.getContext("webgl2", {
88
- premultipliedAlpha: true,
89
- alpha: true,
90
- preserveDrawingBuffer: true
91
- });
92
- if (!gl) {
93
- throw new Error("Failed to acquire WebGL2 context for blur effect");
94
- }
95
- gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true);
96
- gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true);
97
- const vs = compileShader(gl, gl.VERTEX_SHADER, BLUR_VS);
98
- const fs = compileShader(gl, gl.FRAGMENT_SHADER, fragmentSource);
99
- const program = linkProgram(gl, vs, fs);
100
- gl.deleteShader(vs);
101
- gl.deleteShader(fs);
102
- const vao = gl.createVertexArray();
103
- if (!vao) {
104
- throw new Error("Failed to create WebGL vertex array");
105
- }
106
- gl.bindVertexArray(vao);
107
- const data = new Float32Array([
108
- -1,
109
- -1,
110
- 0,
111
- 0,
112
- 1,
113
- -1,
114
- 1,
115
- 0,
116
- -1,
117
- 1,
118
- 0,
119
- 1,
120
- 1,
121
- 1,
122
- 1,
123
- 1
124
- ]);
125
- const vbo = gl.createBuffer();
126
- if (!vbo) {
127
- throw new Error("Failed to create WebGL buffer");
128
- }
129
- gl.bindBuffer(gl.ARRAY_BUFFER, vbo);
130
- gl.bufferData(gl.ARRAY_BUFFER, data, gl.STATIC_DRAW);
131
- const aPos = gl.getAttribLocation(program, "aPos");
132
- const aUv = gl.getAttribLocation(program, "aUv");
133
- gl.enableVertexAttribArray(aPos);
134
- gl.vertexAttribPointer(aPos, 2, gl.FLOAT, false, 16, 0);
135
- gl.enableVertexAttribArray(aUv);
136
- gl.vertexAttribPointer(aUv, 2, gl.FLOAT, false, 16, 8);
137
- gl.bindVertexArray(null);
138
- const texture = gl.createTexture();
139
- if (!texture) {
140
- throw new Error("Failed to create WebGL texture");
141
- }
142
- gl.bindTexture(gl.TEXTURE_2D, texture);
143
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
144
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
145
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
146
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
147
- gl.bindTexture(gl.TEXTURE_2D, null);
148
- const uRadius = gl.getUniformLocation(program, "uRadius");
149
- const uTexelSize = gl.getUniformLocation(program, "uTexelSize");
150
- const uSource = gl.getUniformLocation(program, "uSource");
151
- return { gl, program, vao, vbo, texture, uRadius, uTexelSize, uSource };
152
- };
153
- var cleanupBlur = (state) => {
154
- const { gl, program, vao, vbo, texture } = state;
155
- gl.deleteBuffer(vbo);
156
- gl.deleteProgram(program);
157
- gl.deleteVertexArray(vao);
158
- gl.deleteTexture(texture);
159
- };
160
- var applyBlur = (state, source, width, height, radius) => {
161
- const { gl, program, vao, texture, uRadius, uTexelSize, uSource } = state;
162
- gl.viewport(0, 0, width, height);
163
- gl.clearColor(0, 0, 0, 0);
164
- gl.clear(gl.COLOR_BUFFER_BIT);
165
- gl.useProgram(program);
166
- gl.bindVertexArray(vao);
167
- gl.activeTexture(gl.TEXTURE0);
168
- gl.bindTexture(gl.TEXTURE_2D, texture);
169
- gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, source);
170
- if (uSource)
171
- gl.uniform1i(uSource, 0);
172
- if (uRadius)
173
- gl.uniform1f(uRadius, radius);
174
- if (uTexelSize)
175
- gl.uniform2f(uTexelSize, 1 / width, 1 / height);
176
- gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
177
- gl.bindVertexArray(null);
178
- gl.bindTexture(gl.TEXTURE_2D, null);
179
- gl.useProgram(null);
180
- };
181
-
182
- // src/blur/blur-horizontal.ts
183
- var { createDescriptor, defineEffect } = Internals;
184
- var blurHorizontalDef = defineEffect({
185
- type: "remotion/blur-horizontal",
186
- label: "Blur (horizontal)",
187
- backend: "webgl2",
188
- calculateKey: (params) => String(params.radius),
189
- setup: (target) => setupBlur(target, BLUR_FS_HORIZONTAL),
190
- apply: ({ source, width, height, params, state }) => {
191
- applyBlur(state, source, width, height, params.radius);
192
- },
193
- cleanup: (state) => cleanupBlur(state),
194
- schema: null
195
- });
196
- var blurHorizontal = (params) => createDescriptor(blurHorizontalDef, params);
197
-
198
- // src/blur/blur-vertical.ts
199
- import { Internals as Internals2 } from "remotion";
200
- var { createDescriptor: createDescriptor2, defineEffect: defineEffect2 } = Internals2;
201
- var blurVerticalDef = defineEffect2({
202
- type: "remotion/blur-vertical",
203
- label: "Blur (vertical)",
204
- backend: "webgl2",
205
- calculateKey: (params) => String(params.radius),
206
- setup: (target) => setupBlur(target, BLUR_FS_VERTICAL),
207
- apply: ({ source, width, height, params, state }) => {
208
- applyBlur(state, source, width, height, params.radius);
209
- },
210
- cleanup: (state) => cleanupBlur(state),
211
- schema: null
212
- });
213
- var blurVertical = (params) => createDescriptor2(blurVerticalDef, params);
214
-
215
- // src/blur/index.ts
216
- var blur = (params) => [
217
- blurHorizontal({ radius: params.radius }),
218
- blurVertical({ radius: params.radius })
219
- ];
220
- // src/halftone.ts
221
- import { Internals as Internals3 } from "remotion";
222
- var { createDescriptor: createDescriptor3, defineEffect: defineEffect3 } = Internals3;
223
- var SHADE_OUTSIDE_DOT_SCALE = 0.5;
224
- var halftoneSchema = {
225
- dotSize: {
226
- type: "number",
227
- min: 1,
228
- max: 200,
229
- step: 1,
230
- default: 20,
231
- description: "Dot size"
232
- },
233
- dotSpacing: {
234
- type: "number",
235
- min: 1,
236
- max: 200,
237
- step: 1,
238
- default: 20,
239
- description: "Dot spacing"
240
- },
241
- rotation: {
242
- type: "number",
243
- min: -180,
244
- max: 180,
245
- step: 1,
246
- default: 0,
247
- description: "Rotation"
248
- },
249
- offsetX: {
250
- type: "number",
251
- step: 1,
252
- default: 0,
253
- description: "Offset X"
254
- },
255
- offsetY: {
256
- type: "number",
257
- step: 1,
258
- default: 0,
259
- description: "Offset Y"
260
- }
261
- };
262
- var resolve = (p) => ({
263
- shape: p.shape ?? "circle",
264
- dotSize: p.dotSize ?? 20,
265
- dotSpacing: p.dotSpacing ?? p.dotSize ?? 20,
266
- rotation: p.rotation ?? 0,
267
- offsetX: p.offsetX ?? 0,
268
- offsetY: p.offsetY ?? 0,
269
- sampling: p.sampling ?? "bilinear",
270
- color: p.color ?? "black",
271
- shadeOutside: p.shadeOutside ?? false
272
- });
273
- var HALFTONE_VS = `#version 300 es
274
- in vec2 aPos;
275
- in vec2 aUv;
276
- out vec2 vUv;
277
- void main() {
278
- vUv = aUv;
279
- gl_Position = vec4(aPos, 0.0, 1.0);
280
- }
281
- `;
282
- var HALFTONE_FS = `#version 300 es
283
- precision highp float;
284
-
285
- in vec2 vUv;
286
- out vec4 fragColor;
287
-
288
- uniform sampler2D uSource;
289
- uniform vec2 uResolution;
290
- uniform float uDotSize;
291
- uniform float uDotSpacing;
292
- uniform float uRotation;
293
- uniform vec2 uOffset;
294
- uniform vec4 uColor;
295
- uniform int uShape;
296
- uniform bool uShadeOutside;
297
-
298
- const float SHADE_OUTSIDE_SCALE = ${SHADE_OUTSIDE_DOT_SCALE.toFixed(1)};
299
-
300
- void main() {
301
- vec2 fragPos = vUv * uResolution;
302
- vec2 center = uResolution * 0.5;
303
-
304
- vec2 d = fragPos - center;
305
- float cosR = cos(uRotation);
306
- float sinR = sin(uRotation);
307
-
308
- vec2 gridPos = vec2(
309
- d.x * cosR + d.y * sinR,
310
- -d.x * sinR + d.y * cosR
311
- );
312
-
313
- float spacing = max(uDotSpacing, 0.001);
314
- vec2 cellIndex = floor((gridPos + uOffset) / spacing + 0.5);
315
- vec2 gridCenter = cellIndex * spacing - uOffset;
316
-
317
- vec2 canvasPos = center + vec2(
318
- gridCenter.x * cosR - gridCenter.y * sinR,
319
- gridCenter.x * sinR + gridCenter.y * cosR
320
- );
321
-
322
- vec2 sampleUv = clamp(canvasPos / uResolution, vec2(0.0), vec2(1.0));
323
- vec4 texColor = texture(uSource, sampleUv);
324
-
325
- float alpha = texColor.a;
326
- vec3 rgb = alpha > 0.001 ? texColor.rgb / alpha : vec3(0.0);
327
- float lum = dot(rgb, vec3(0.299, 0.587, 0.114));
328
-
329
- float lumDefault = lum * alpha + (1.0 - alpha);
330
- float dotScale = uShadeOutside
331
- ? (1.0 - alpha) * SHADE_OUTSIDE_SCALE
332
- : 1.0 - lumDefault;
333
-
334
- if (dotScale <= 0.01) {
335
- fragColor = vec4(0.0);
336
- return;
337
- }
338
-
339
- vec2 diff = gridPos - gridCenter;
340
- float halfSize = uDotSize * 0.5;
341
- float coverage = 0.0;
342
-
343
- if (uShape == 0) {
344
- float radius = halfSize * dotScale;
345
- float dist = length(diff);
346
- coverage = 1.0 - smoothstep(radius - 0.75, radius + 0.75, dist);
347
- } else if (uShape == 1) {
348
- float s = uDotSize * dotScale * 0.5;
349
- coverage = (1.0 - smoothstep(s - 0.5, s + 0.5, abs(diff.x)))
350
- * (1.0 - smoothstep(s - 0.5, s + 0.5, abs(diff.y)));
351
- } else {
352
- float lineHalf = uDotSize * dotScale * 0.5;
353
- coverage = (1.0 - smoothstep(halfSize - 0.5, halfSize + 0.5, abs(diff.x)))
354
- * (1.0 - smoothstep(lineHalf - 0.5, lineHalf + 0.5, abs(diff.y)));
355
- }
356
-
357
- fragColor = uColor * coverage;
358
- }
359
- `;
360
- var SHAPE_INDEX = {
361
- circle: 0,
362
- square: 1,
363
- line: 2
364
- };
365
- var compileShader2 = (gl, type, source) => {
366
- const shader = gl.createShader(type);
367
- if (!shader) {
368
- throw new Error("Failed to create WebGL shader");
369
- }
370
- gl.shaderSource(shader, source);
371
- gl.compileShader(shader);
372
- if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
373
- const log = gl.getShaderInfoLog(shader);
374
- gl.deleteShader(shader);
375
- throw new Error(`Halftone shader compile failed: ${log ?? "(no log)"}`);
376
- }
377
- return shader;
378
- };
379
- var linkProgram2 = (gl, vs, fs) => {
380
- const program = gl.createProgram();
381
- if (!program) {
382
- throw new Error("Failed to create WebGL program");
383
- }
384
- gl.attachShader(program, vs);
385
- gl.attachShader(program, fs);
386
- gl.linkProgram(program);
387
- if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
388
- const log = gl.getProgramInfoLog(program);
389
- gl.deleteProgram(program);
390
- throw new Error(`Halftone program link failed: ${log ?? "(no log)"}`);
391
- }
392
- return program;
393
- };
394
- var parseColorRgba = (ctx, color) => {
395
- ctx.clearRect(0, 0, 1, 1);
396
- ctx.fillStyle = color;
397
- ctx.fillRect(0, 0, 1, 1);
398
- const { data } = ctx.getImageData(0, 0, 1, 1);
399
- return [data[0] / 255, data[1] / 255, data[2] / 255, data[3] / 255];
400
- };
401
- var halftoneDef = defineEffect3({
402
- type: "remotion/halftone",
403
- label: "Halftone",
404
- backend: "webgl2",
405
- calculateKey: (params) => {
406
- const r = resolve(params);
407
- return `halftone-${r.shape}-${r.dotSize}-${r.dotSpacing}-${r.rotation}-${r.offsetX}-${r.offsetY}-${r.sampling}-${r.color}-${r.shadeOutside ? 1 : 0}`;
408
- },
409
- setup: (target) => {
410
- const gl = target.getContext("webgl2", {
411
- premultipliedAlpha: true,
412
- alpha: true,
413
- preserveDrawingBuffer: true
414
- });
415
- if (!gl) {
416
- throw new Error("Failed to acquire WebGL2 context for halftone effect");
417
- }
418
- gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true);
419
- gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true);
420
- const vs = compileShader2(gl, gl.VERTEX_SHADER, HALFTONE_VS);
421
- const fs = compileShader2(gl, gl.FRAGMENT_SHADER, HALFTONE_FS);
422
- const program = linkProgram2(gl, vs, fs);
423
- gl.deleteShader(vs);
424
- gl.deleteShader(fs);
425
- const vao = gl.createVertexArray();
426
- if (!vao) {
427
- throw new Error("Failed to create WebGL vertex array");
428
- }
429
- gl.bindVertexArray(vao);
430
- const data = new Float32Array([
431
- -1,
432
- -1,
433
- 0,
434
- 0,
435
- 1,
436
- -1,
437
- 1,
438
- 0,
439
- -1,
440
- 1,
441
- 0,
442
- 1,
443
- 1,
444
- 1,
445
- 1,
446
- 1
447
- ]);
448
- const vbo = gl.createBuffer();
449
- if (!vbo) {
450
- throw new Error("Failed to create WebGL buffer");
451
- }
452
- gl.bindBuffer(gl.ARRAY_BUFFER, vbo);
453
- gl.bufferData(gl.ARRAY_BUFFER, data, gl.STATIC_DRAW);
454
- const aPos = gl.getAttribLocation(program, "aPos");
455
- const aUv = gl.getAttribLocation(program, "aUv");
456
- gl.enableVertexAttribArray(aPos);
457
- gl.vertexAttribPointer(aPos, 2, gl.FLOAT, false, 16, 0);
458
- gl.enableVertexAttribArray(aUv);
459
- gl.vertexAttribPointer(aUv, 2, gl.FLOAT, false, 16, 8);
460
- gl.bindVertexArray(null);
461
- const texture = gl.createTexture();
462
- if (!texture) {
463
- throw new Error("Failed to create WebGL texture");
464
- }
465
- gl.bindTexture(gl.TEXTURE_2D, texture);
466
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
467
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
468
- gl.bindTexture(gl.TEXTURE_2D, null);
469
- const colorCanvas = document.createElement("canvas");
470
- colorCanvas.width = 1;
471
- colorCanvas.height = 1;
472
- const colorCtx = colorCanvas.getContext("2d", { willReadFrequently: true });
473
- if (!colorCtx) {
474
- throw new Error("Failed to acquire 2D context for color parsing");
475
- }
476
- return {
477
- gl,
478
- program,
479
- vao,
480
- vbo,
481
- texture,
482
- uSource: gl.getUniformLocation(program, "uSource"),
483
- uResolution: gl.getUniformLocation(program, "uResolution"),
484
- uDotSize: gl.getUniformLocation(program, "uDotSize"),
485
- uDotSpacing: gl.getUniformLocation(program, "uDotSpacing"),
486
- uRotation: gl.getUniformLocation(program, "uRotation"),
487
- uOffset: gl.getUniformLocation(program, "uOffset"),
488
- uColor: gl.getUniformLocation(program, "uColor"),
489
- uShape: gl.getUniformLocation(program, "uShape"),
490
- uShadeOutside: gl.getUniformLocation(program, "uShadeOutside"),
491
- colorCtx,
492
- cachedColorStr: "",
493
- cachedColorRgba: [0, 0, 0, 1]
494
- };
495
- },
496
- apply: ({ source, width, height, params, state }) => {
497
- const r = resolve(params);
498
- const { gl, program, vao, texture } = state;
499
- if (state.cachedColorStr !== r.color) {
500
- state.cachedColorStr = r.color;
501
- state.cachedColorRgba = parseColorRgba(state.colorCtx, r.color);
502
- }
503
- const [cr, cg, cb, ca] = state.cachedColorRgba;
504
- const filter = r.sampling === "nearest" ? gl.NEAREST : gl.LINEAR;
505
- gl.viewport(0, 0, width, height);
506
- gl.clearColor(0, 0, 0, 0);
507
- gl.clear(gl.COLOR_BUFFER_BIT);
508
- gl.useProgram(program);
509
- gl.bindVertexArray(vao);
510
- gl.activeTexture(gl.TEXTURE0);
511
- gl.bindTexture(gl.TEXTURE_2D, texture);
512
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filter);
513
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filter);
514
- gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, source);
515
- if (state.uSource)
516
- gl.uniform1i(state.uSource, 0);
517
- if (state.uResolution)
518
- gl.uniform2f(state.uResolution, width, height);
519
- if (state.uDotSize)
520
- gl.uniform1f(state.uDotSize, r.dotSize);
521
- if (state.uDotSpacing)
522
- gl.uniform1f(state.uDotSpacing, r.dotSpacing);
523
- if (state.uRotation)
524
- gl.uniform1f(state.uRotation, r.rotation * Math.PI / 180);
525
- if (state.uOffset)
526
- gl.uniform2f(state.uOffset, r.offsetX, r.offsetY);
527
- if (state.uColor)
528
- gl.uniform4f(state.uColor, cr * ca, cg * ca, cb * ca, ca);
529
- if (state.uShape)
530
- gl.uniform1i(state.uShape, SHAPE_INDEX[r.shape]);
531
- if (state.uShadeOutside)
532
- gl.uniform1i(state.uShadeOutside, r.shadeOutside ? 1 : 0);
533
- gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
534
- gl.bindVertexArray(null);
535
- gl.bindTexture(gl.TEXTURE_2D, null);
536
- gl.useProgram(null);
537
- },
538
- cleanup: ({ gl, program, vao, vbo, texture }) => {
539
- gl.deleteBuffer(vbo);
540
- gl.deleteProgram(program);
541
- gl.deleteVertexArray(vao);
542
- gl.deleteTexture(texture);
543
- },
544
- schema: halftoneSchema
545
- });
546
- var halftone = (params = {}) => createDescriptor3(halftoneDef, params);
547
- // src/tint.ts
548
- import { Internals as Internals4 } from "remotion";
549
- var { createDescriptor: createDescriptor4, defineEffect: defineEffect4 } = Internals4;
550
- var DEFAULT_AMOUNT = 0.5;
551
- var tintSchema = {
552
- amount: {
553
- type: "number",
554
- min: 0,
555
- max: 1,
556
- step: 0.01,
557
- default: DEFAULT_AMOUNT,
558
- description: "Amount"
559
- }
560
- };
561
- var resolve2 = (p) => ({
562
- color: p.color,
563
- amount: p.amount ?? DEFAULT_AMOUNT
564
- });
565
- var tintDef = defineEffect4({
566
- type: "remotion/tint",
567
- label: "Tint",
568
- backend: "2d",
569
- calculateKey: (params) => {
570
- const r = resolve2(params);
571
- return `tint-${r.color}-${r.amount}`;
572
- },
573
- setup: () => null,
574
- apply: ({ source, target, width, height, params }) => {
575
- const ctx = target.getContext("2d");
576
- if (!ctx) {
577
- throw new Error("Failed to acquire 2D context for tint effect. The canvas may have been assigned a different context type.");
578
- }
579
- const r = resolve2(params);
580
- const amount = Math.max(0, Math.min(1, r.amount));
581
- ctx.clearRect(0, 0, width, height);
582
- ctx.globalAlpha = 1;
583
- ctx.globalCompositeOperation = "source-over";
584
- ctx.drawImage(source, 0, 0, width, height);
585
- ctx.globalAlpha = amount;
586
- ctx.globalCompositeOperation = "source-atop";
587
- ctx.fillStyle = r.color;
588
- ctx.fillRect(0, 0, width, height);
589
- ctx.globalAlpha = 1;
590
- ctx.globalCompositeOperation = "source-over";
591
- },
592
- cleanup: () => {
593
- return;
594
- },
595
- schema: tintSchema
596
- });
597
- var tint = (params) => createDescriptor4(tintDef, params);
598
- // src/wave.ts
599
- import { Internals as Internals5 } from "remotion";
600
- var { createDescriptor: createDescriptor5, defineEffect: defineEffect5 } = Internals5;
601
- var resolve3 = (p) => ({
602
- amplitude: p.amplitude ?? 60,
603
- wavelength: p.wavelength ?? 240,
604
- speed: p.speed ?? 1 / 6,
605
- sliceWidth: p.sliceWidth ?? 4,
606
- background: p.background ?? "transparent"
607
- });
608
- var waveDef = defineEffect5({
609
- type: "remotion/wave",
610
- label: "Wave",
611
- backend: "2d",
612
- calculateKey: (params) => {
613
- const r = resolve3(params);
614
- return `wave-${r.amplitude}-${r.wavelength}-${r.speed}-${r.sliceWidth}-${r.background}`;
615
- },
616
- setup: () => null,
617
- apply: ({ source, target, frame, width, height, params }) => {
618
- const ctx = target.getContext("2d");
619
- if (!ctx) {
620
- throw new Error("Failed to acquire 2D context for wave effect. The canvas may have been assigned a different context type.");
621
- }
622
- const r = resolve3(params);
623
- ctx.clearRect(0, 0, width, height);
624
- if (r.background !== "transparent") {
625
- ctx.fillStyle = r.background;
626
- ctx.fillRect(0, 0, width, height);
627
- }
628
- for (let x = 0;x < width; x += r.sliceWidth) {
629
- const offset = Math.sin(x / r.wavelength * Math.PI * 2 + frame * r.speed) * r.amplitude;
630
- ctx.drawImage(source, x, 0, r.sliceWidth, height, x, offset, r.sliceWidth, height);
631
- }
632
- },
633
- cleanup: () => {
634
- return;
635
- },
636
- schema: null
637
- });
638
- var wave = (params = {}) => createDescriptor5(waveDef, params);
639
- export {
640
- wave,
641
- tint,
642
- halftone,
643
- blurVertical,
644
- blurHorizontal,
645
- blur
646
- };
1
+ export {};
@@ -0,0 +1,71 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __export = (target, all) => {
3
+ for (var name in all)
4
+ __defProp(target, name, {
5
+ get: all[name],
6
+ enumerable: true,
7
+ configurable: true,
8
+ set: (newValue) => all[name] = () => newValue
9
+ });
10
+ };
11
+
12
+ // src/tint.ts
13
+ import { Internals } from "remotion";
14
+ var { createEffect } = Internals;
15
+ var DEFAULT_AMOUNT = 0.5;
16
+ var DEFAULT_COLOR = "#ff0000";
17
+ var tintSchema = {
18
+ color: {
19
+ type: "color",
20
+ default: DEFAULT_COLOR,
21
+ description: "Color"
22
+ },
23
+ amount: {
24
+ type: "number",
25
+ min: 0,
26
+ max: 1,
27
+ step: 0.01,
28
+ default: DEFAULT_AMOUNT,
29
+ description: "Amount"
30
+ }
31
+ };
32
+ var resolve = (p) => ({
33
+ color: p.color,
34
+ amount: p.amount ?? DEFAULT_AMOUNT
35
+ });
36
+ var tint = createEffect({
37
+ type: "remotion/tint",
38
+ label: "Tint",
39
+ backend: "2d",
40
+ calculateKey: (params) => {
41
+ const r = resolve(params);
42
+ return `tint-${r.color}-${r.amount}`;
43
+ },
44
+ setup: () => null,
45
+ apply: ({ source, target, width, height, params }) => {
46
+ const ctx = target.getContext("2d");
47
+ if (!ctx) {
48
+ throw new Error("Failed to acquire 2D context for tint effect. The canvas may have been assigned a different context type.");
49
+ }
50
+ const r = resolve(params);
51
+ const amount = Math.max(0, Math.min(1, r.amount));
52
+ ctx.clearRect(0, 0, width, height);
53
+ ctx.globalAlpha = 1;
54
+ ctx.globalCompositeOperation = "source-over";
55
+ ctx.drawImage(source, 0, 0, width, height);
56
+ ctx.globalAlpha = amount;
57
+ ctx.globalCompositeOperation = "source-atop";
58
+ ctx.fillStyle = r.color;
59
+ ctx.fillRect(0, 0, width, height);
60
+ ctx.globalAlpha = 1;
61
+ ctx.globalCompositeOperation = "source-over";
62
+ },
63
+ cleanup: () => {
64
+ return;
65
+ },
66
+ schema: tintSchema
67
+ });
68
+ export {
69
+ tintSchema,
70
+ tint
71
+ };