@remotion/effects 4.0.466 → 4.0.468
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.
- package/dist/chromatic-aberration/chromatic-aberration-runtime.d.ts +22 -0
- package/dist/chromatic-aberration/chromatic-aberration-shaders.d.ts +2 -0
- package/dist/chromatic-aberration/index.d.ts +9 -0
- package/dist/chromatic-aberration.d.ts +1 -0
- package/dist/color-utils.d.ts +2 -0
- package/dist/contrast.d.ts +7 -0
- package/dist/duotone.d.ts +31 -0
- package/dist/esm/barrel-distortion.mjs +14 -1
- package/dist/esm/blur.mjs +7 -1
- package/dist/esm/brightness.mjs +14 -1
- package/dist/esm/chromatic-aberration.mjs +343 -0
- package/dist/esm/contrast.mjs +151 -0
- package/dist/esm/duotone.mjs +365 -0
- package/dist/esm/glow.mjs +585 -0
- package/dist/esm/grayscale.mjs +14 -1
- package/dist/esm/halftone.mjs +51 -29
- package/dist/esm/hue.mjs +14 -1
- package/dist/esm/invert.mjs +14 -1
- package/dist/esm/mirror.mjs +14 -1
- package/dist/esm/saturation.mjs +14 -1
- package/dist/esm/scale.mjs +7 -1
- package/dist/esm/shine.mjs +389 -0
- package/dist/esm/tint.mjs +14 -1
- package/dist/esm/translate.mjs +218 -0
- package/dist/esm/vignette.mjs +439 -0
- package/dist/esm/wave.mjs +7 -1
- package/dist/glow/glow-runtime.d.ts +52 -0
- package/dist/glow/glow-shaders.d.ts +5 -0
- package/dist/glow/index.d.ts +13 -0
- package/dist/glow.d.ts +1 -0
- package/dist/halftone.d.ts +24 -7
- package/dist/shine.d.ts +17 -0
- package/dist/translate/index.d.ts +18 -0
- package/dist/translate.d.ts +1 -0
- package/dist/validate-effect-param.d.ts +1 -0
- package/dist/vignette.d.ts +68 -0
- package/package.json +59 -3
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
// src/shine.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/shine.ts
|
|
99
|
+
var { createEffect, createWebGL2ContextError } = Internals;
|
|
100
|
+
var DEFAULT_PROGRESS = 0.5;
|
|
101
|
+
var DEFAULT_ANGLE = 30;
|
|
102
|
+
var DEFAULT_HALO_SIGMA = 200;
|
|
103
|
+
var DEFAULT_CORE_SIGMA = 65;
|
|
104
|
+
var DEFAULT_HALO_INTENSITY = 0.3;
|
|
105
|
+
var DEFAULT_CORE_INTENSITY = 0.4;
|
|
106
|
+
var shineSchema = {
|
|
107
|
+
progress: {
|
|
108
|
+
type: "number",
|
|
109
|
+
min: 0,
|
|
110
|
+
max: 1,
|
|
111
|
+
step: 0.01,
|
|
112
|
+
default: DEFAULT_PROGRESS,
|
|
113
|
+
description: "Progress"
|
|
114
|
+
},
|
|
115
|
+
angle: {
|
|
116
|
+
type: "number",
|
|
117
|
+
min: -180,
|
|
118
|
+
max: 180,
|
|
119
|
+
step: 1,
|
|
120
|
+
default: DEFAULT_ANGLE,
|
|
121
|
+
description: "Angle"
|
|
122
|
+
},
|
|
123
|
+
haloSigma: {
|
|
124
|
+
type: "number",
|
|
125
|
+
min: 1,
|
|
126
|
+
max: 500,
|
|
127
|
+
step: 1,
|
|
128
|
+
default: DEFAULT_HALO_SIGMA,
|
|
129
|
+
description: "Halo sigma"
|
|
130
|
+
},
|
|
131
|
+
coreSigma: {
|
|
132
|
+
type: "number",
|
|
133
|
+
min: 1,
|
|
134
|
+
max: 500,
|
|
135
|
+
step: 1,
|
|
136
|
+
default: DEFAULT_CORE_SIGMA,
|
|
137
|
+
description: "Core sigma"
|
|
138
|
+
},
|
|
139
|
+
haloIntensity: {
|
|
140
|
+
type: "number",
|
|
141
|
+
min: 0,
|
|
142
|
+
max: 1,
|
|
143
|
+
step: 0.01,
|
|
144
|
+
default: DEFAULT_HALO_INTENSITY,
|
|
145
|
+
description: "Halo intensity"
|
|
146
|
+
},
|
|
147
|
+
coreIntensity: {
|
|
148
|
+
type: "number",
|
|
149
|
+
min: 0,
|
|
150
|
+
max: 1,
|
|
151
|
+
step: 0.01,
|
|
152
|
+
default: DEFAULT_CORE_INTENSITY,
|
|
153
|
+
description: "Core intensity"
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
var resolve = (p) => ({
|
|
157
|
+
progress: p.progress ?? DEFAULT_PROGRESS,
|
|
158
|
+
angle: p.angle ?? DEFAULT_ANGLE,
|
|
159
|
+
haloSigma: p.haloSigma ?? DEFAULT_HALO_SIGMA,
|
|
160
|
+
coreSigma: p.coreSigma ?? DEFAULT_CORE_SIGMA,
|
|
161
|
+
haloIntensity: p.haloIntensity ?? DEFAULT_HALO_INTENSITY,
|
|
162
|
+
coreIntensity: p.coreIntensity ?? DEFAULT_CORE_INTENSITY
|
|
163
|
+
});
|
|
164
|
+
var validatePositive = (value, name) => {
|
|
165
|
+
if (value <= 0) {
|
|
166
|
+
throw new TypeError(`"${name}" must be greater than 0, but got ${JSON.stringify(value)}`);
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
var validateShineParams = (params) => {
|
|
170
|
+
assertEffectParamsObject(params, "Shine");
|
|
171
|
+
assertOptionalFiniteNumber(params.progress, "progress");
|
|
172
|
+
assertOptionalFiniteNumber(params.angle, "angle");
|
|
173
|
+
assertOptionalFiniteNumber(params.haloSigma, "haloSigma");
|
|
174
|
+
assertOptionalFiniteNumber(params.coreSigma, "coreSigma");
|
|
175
|
+
assertOptionalFiniteNumber(params.haloIntensity, "haloIntensity");
|
|
176
|
+
assertOptionalFiniteNumber(params.coreIntensity, "coreIntensity");
|
|
177
|
+
const r = resolve(params);
|
|
178
|
+
validateUnitInterval(r.progress, "progress");
|
|
179
|
+
validatePositive(r.haloSigma, "haloSigma");
|
|
180
|
+
validatePositive(r.coreSigma, "coreSigma");
|
|
181
|
+
validateUnitInterval(r.haloIntensity, "haloIntensity");
|
|
182
|
+
validateUnitInterval(r.coreIntensity, "coreIntensity");
|
|
183
|
+
};
|
|
184
|
+
var SHINE_VS = `#version 300 es
|
|
185
|
+
in vec2 aPos;
|
|
186
|
+
in vec2 aUv;
|
|
187
|
+
out vec2 vUv;
|
|
188
|
+
|
|
189
|
+
void main() {
|
|
190
|
+
vUv = aUv;
|
|
191
|
+
gl_Position = vec4(aPos, 0.0, 1.0);
|
|
192
|
+
}
|
|
193
|
+
`;
|
|
194
|
+
var SHINE_FS = `#version 300 es
|
|
195
|
+
precision highp float;
|
|
196
|
+
|
|
197
|
+
in vec2 vUv;
|
|
198
|
+
out vec4 fragColor;
|
|
199
|
+
|
|
200
|
+
uniform sampler2D uSource;
|
|
201
|
+
uniform vec2 uResolution;
|
|
202
|
+
uniform vec2 uBandNormal;
|
|
203
|
+
uniform float uBandT;
|
|
204
|
+
uniform float uHaloSigma;
|
|
205
|
+
uniform float uCoreSigma;
|
|
206
|
+
uniform float uHaloIntensity;
|
|
207
|
+
uniform float uCoreIntensity;
|
|
208
|
+
|
|
209
|
+
void main() {
|
|
210
|
+
vec4 source = texture(uSource, vUv);
|
|
211
|
+
vec2 px = vec2(vUv.x * uResolution.x, (1.0 - vUv.y) * uResolution.y);
|
|
212
|
+
vec2 center = uResolution * 0.5;
|
|
213
|
+
|
|
214
|
+
float dist = dot(px - center, uBandNormal) - uBandT;
|
|
215
|
+
float halo = exp(-(dist * dist) / (uHaloSigma * uHaloSigma)) * uHaloIntensity;
|
|
216
|
+
float core = exp(-(dist * dist) / (uCoreSigma * uCoreSigma)) * uCoreIntensity;
|
|
217
|
+
float intensity = clamp(halo + core, 0.0, 1.0);
|
|
218
|
+
|
|
219
|
+
vec3 finalPremult = source.rgb * (1.0 - intensity) + intensity * source.a;
|
|
220
|
+
fragColor = vec4(finalPremult, source.a);
|
|
221
|
+
}
|
|
222
|
+
`;
|
|
223
|
+
var compileShader = (gl, type, source) => {
|
|
224
|
+
const shader = gl.createShader(type);
|
|
225
|
+
if (!shader) {
|
|
226
|
+
throw new Error("Failed to create WebGL shader");
|
|
227
|
+
}
|
|
228
|
+
gl.shaderSource(shader, source);
|
|
229
|
+
gl.compileShader(shader);
|
|
230
|
+
if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
|
|
231
|
+
const log = gl.getShaderInfoLog(shader);
|
|
232
|
+
gl.deleteShader(shader);
|
|
233
|
+
throw new Error(`Shine shader compile failed: ${log ?? "(no log)"}`);
|
|
234
|
+
}
|
|
235
|
+
return shader;
|
|
236
|
+
};
|
|
237
|
+
var linkProgram = (gl, vs, fs) => {
|
|
238
|
+
const program = gl.createProgram();
|
|
239
|
+
if (!program) {
|
|
240
|
+
throw new Error("Failed to create WebGL program");
|
|
241
|
+
}
|
|
242
|
+
gl.attachShader(program, vs);
|
|
243
|
+
gl.attachShader(program, fs);
|
|
244
|
+
gl.linkProgram(program);
|
|
245
|
+
if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
|
|
246
|
+
const log = gl.getProgramInfoLog(program);
|
|
247
|
+
gl.deleteProgram(program);
|
|
248
|
+
throw new Error(`Shine program link failed: ${log ?? "(no log)"}`);
|
|
249
|
+
}
|
|
250
|
+
return program;
|
|
251
|
+
};
|
|
252
|
+
var shine = createEffect({
|
|
253
|
+
type: "remotion/shine",
|
|
254
|
+
label: "shine()",
|
|
255
|
+
documentationLink: "https://www.remotion.dev/docs/effects/shine",
|
|
256
|
+
backend: "webgl2",
|
|
257
|
+
calculateKey: (params) => {
|
|
258
|
+
const r = resolve(params);
|
|
259
|
+
return `shine-${r.progress}-${r.angle}-${r.haloSigma}-${r.coreSigma}-${r.haloIntensity}-${r.coreIntensity}`;
|
|
260
|
+
},
|
|
261
|
+
setup: (target) => {
|
|
262
|
+
const gl = target.getContext("webgl2", {
|
|
263
|
+
premultipliedAlpha: true,
|
|
264
|
+
alpha: true,
|
|
265
|
+
preserveDrawingBuffer: true
|
|
266
|
+
});
|
|
267
|
+
if (!gl) {
|
|
268
|
+
throw createWebGL2ContextError("shine effect");
|
|
269
|
+
}
|
|
270
|
+
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true);
|
|
271
|
+
const vs = compileShader(gl, gl.VERTEX_SHADER, SHINE_VS);
|
|
272
|
+
const fs = compileShader(gl, gl.FRAGMENT_SHADER, SHINE_FS);
|
|
273
|
+
const program = linkProgram(gl, vs, fs);
|
|
274
|
+
gl.deleteShader(vs);
|
|
275
|
+
gl.deleteShader(fs);
|
|
276
|
+
const vao = gl.createVertexArray();
|
|
277
|
+
if (!vao) {
|
|
278
|
+
throw new Error("Failed to create WebGL vertex array");
|
|
279
|
+
}
|
|
280
|
+
gl.bindVertexArray(vao);
|
|
281
|
+
const data = new Float32Array([
|
|
282
|
+
-1,
|
|
283
|
+
-1,
|
|
284
|
+
0,
|
|
285
|
+
0,
|
|
286
|
+
1,
|
|
287
|
+
-1,
|
|
288
|
+
1,
|
|
289
|
+
0,
|
|
290
|
+
-1,
|
|
291
|
+
1,
|
|
292
|
+
0,
|
|
293
|
+
1,
|
|
294
|
+
1,
|
|
295
|
+
1,
|
|
296
|
+
1,
|
|
297
|
+
1
|
|
298
|
+
]);
|
|
299
|
+
const vbo = gl.createBuffer();
|
|
300
|
+
if (!vbo) {
|
|
301
|
+
throw new Error("Failed to create WebGL buffer");
|
|
302
|
+
}
|
|
303
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, vbo);
|
|
304
|
+
gl.bufferData(gl.ARRAY_BUFFER, data, gl.STATIC_DRAW);
|
|
305
|
+
const aPos = gl.getAttribLocation(program, "aPos");
|
|
306
|
+
const aUv = gl.getAttribLocation(program, "aUv");
|
|
307
|
+
gl.enableVertexAttribArray(aPos);
|
|
308
|
+
gl.vertexAttribPointer(aPos, 2, gl.FLOAT, false, 16, 0);
|
|
309
|
+
gl.enableVertexAttribArray(aUv);
|
|
310
|
+
gl.vertexAttribPointer(aUv, 2, gl.FLOAT, false, 16, 8);
|
|
311
|
+
gl.bindVertexArray(null);
|
|
312
|
+
const texture = gl.createTexture();
|
|
313
|
+
if (!texture) {
|
|
314
|
+
throw new Error("Failed to create WebGL texture");
|
|
315
|
+
}
|
|
316
|
+
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
317
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
|
|
318
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
|
|
319
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
320
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
|
321
|
+
gl.bindTexture(gl.TEXTURE_2D, null);
|
|
322
|
+
return {
|
|
323
|
+
gl,
|
|
324
|
+
program,
|
|
325
|
+
vao,
|
|
326
|
+
vbo,
|
|
327
|
+
texture,
|
|
328
|
+
uSource: gl.getUniformLocation(program, "uSource"),
|
|
329
|
+
uResolution: gl.getUniformLocation(program, "uResolution"),
|
|
330
|
+
uBandNormal: gl.getUniformLocation(program, "uBandNormal"),
|
|
331
|
+
uBandT: gl.getUniformLocation(program, "uBandT"),
|
|
332
|
+
uHaloSigma: gl.getUniformLocation(program, "uHaloSigma"),
|
|
333
|
+
uCoreSigma: gl.getUniformLocation(program, "uCoreSigma"),
|
|
334
|
+
uHaloIntensity: gl.getUniformLocation(program, "uHaloIntensity"),
|
|
335
|
+
uCoreIntensity: gl.getUniformLocation(program, "uCoreIntensity")
|
|
336
|
+
};
|
|
337
|
+
},
|
|
338
|
+
apply: ({ source, width, height, params, state, flipSourceY }) => {
|
|
339
|
+
const r = resolve(params);
|
|
340
|
+
const angleRad = r.angle * Math.PI / 180;
|
|
341
|
+
const bandNormalX = Math.cos(angleRad);
|
|
342
|
+
const bandNormalY = -Math.sin(angleRad);
|
|
343
|
+
const bboxProjection = Math.abs(bandNormalX) * width + Math.abs(bandNormalY) * height;
|
|
344
|
+
const sweepHalfRange = bboxProjection / 2 + 3 * r.haloSigma;
|
|
345
|
+
const bandT = -sweepHalfRange + r.progress * sweepHalfRange * 2;
|
|
346
|
+
const { gl, program, vao, texture } = state;
|
|
347
|
+
gl.viewport(0, 0, width, height);
|
|
348
|
+
gl.bindFramebuffer(gl.FRAMEBUFFER, null);
|
|
349
|
+
gl.clearColor(0, 0, 0, 0);
|
|
350
|
+
gl.clear(gl.COLOR_BUFFER_BIT);
|
|
351
|
+
gl.activeTexture(gl.TEXTURE0);
|
|
352
|
+
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
353
|
+
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, flipSourceY);
|
|
354
|
+
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, source);
|
|
355
|
+
gl.useProgram(program);
|
|
356
|
+
if (state.uSource)
|
|
357
|
+
gl.uniform1i(state.uSource, 0);
|
|
358
|
+
if (state.uResolution)
|
|
359
|
+
gl.uniform2f(state.uResolution, width, height);
|
|
360
|
+
if (state.uBandNormal)
|
|
361
|
+
gl.uniform2f(state.uBandNormal, bandNormalX, bandNormalY);
|
|
362
|
+
if (state.uBandT)
|
|
363
|
+
gl.uniform1f(state.uBandT, bandT);
|
|
364
|
+
if (state.uHaloSigma)
|
|
365
|
+
gl.uniform1f(state.uHaloSigma, r.haloSigma);
|
|
366
|
+
if (state.uCoreSigma)
|
|
367
|
+
gl.uniform1f(state.uCoreSigma, r.coreSigma);
|
|
368
|
+
if (state.uHaloIntensity)
|
|
369
|
+
gl.uniform1f(state.uHaloIntensity, r.haloIntensity);
|
|
370
|
+
if (state.uCoreIntensity)
|
|
371
|
+
gl.uniform1f(state.uCoreIntensity, r.coreIntensity);
|
|
372
|
+
gl.bindVertexArray(vao);
|
|
373
|
+
gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
|
|
374
|
+
gl.bindVertexArray(null);
|
|
375
|
+
gl.bindTexture(gl.TEXTURE_2D, null);
|
|
376
|
+
gl.useProgram(null);
|
|
377
|
+
},
|
|
378
|
+
cleanup: ({ gl, program, vao, vbo, texture }) => {
|
|
379
|
+
gl.deleteTexture(texture);
|
|
380
|
+
gl.deleteBuffer(vbo);
|
|
381
|
+
gl.deleteProgram(program);
|
|
382
|
+
gl.deleteVertexArray(vao);
|
|
383
|
+
},
|
|
384
|
+
schema: shineSchema,
|
|
385
|
+
validateParams: validateShineParams
|
|
386
|
+
});
|
|
387
|
+
export {
|
|
388
|
+
shine
|
|
389
|
+
};
|
package/dist/esm/tint.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/tint.ts
|
|
86
99
|
var { createEffect } = Internals;
|
|
@@ -114,7 +127,7 @@ var validateTintParams = (params) => {
|
|
|
114
127
|
};
|
|
115
128
|
var tint = createEffect({
|
|
116
129
|
type: "remotion/tint",
|
|
117
|
-
label: "
|
|
130
|
+
label: "tint()",
|
|
118
131
|
documentationLink: "https://www.remotion.dev/docs/effects/tint",
|
|
119
132
|
backend: "2d",
|
|
120
133
|
calculateKey: (params) => {
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
// src/translate/index.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/translate/index.ts
|
|
99
|
+
var { createEffect } = Internals;
|
|
100
|
+
var xyTranslateSchema = {
|
|
101
|
+
x: {
|
|
102
|
+
type: "number",
|
|
103
|
+
step: 1,
|
|
104
|
+
default: 0,
|
|
105
|
+
description: "X"
|
|
106
|
+
},
|
|
107
|
+
y: {
|
|
108
|
+
type: "number",
|
|
109
|
+
step: 1,
|
|
110
|
+
default: 0,
|
|
111
|
+
description: "Y"
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
var uvTranslateSchema = {
|
|
115
|
+
u: {
|
|
116
|
+
type: "number",
|
|
117
|
+
step: 0.01,
|
|
118
|
+
default: 0,
|
|
119
|
+
description: "U"
|
|
120
|
+
},
|
|
121
|
+
v: {
|
|
122
|
+
type: "number",
|
|
123
|
+
step: 0.01,
|
|
124
|
+
default: 0,
|
|
125
|
+
description: "V"
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
var resolveXyTranslate = (params) => ({
|
|
129
|
+
x: params.x ?? 0,
|
|
130
|
+
y: params.y ?? 0
|
|
131
|
+
});
|
|
132
|
+
var resolveUvTranslate = (params) => ({
|
|
133
|
+
u: params.u ?? 0,
|
|
134
|
+
v: params.v ?? 0
|
|
135
|
+
});
|
|
136
|
+
var validateXyTranslateParams = (params) => {
|
|
137
|
+
assertEffectParamsObject(params, "xyTranslate");
|
|
138
|
+
assertOptionalFiniteNumber(params.x, "x");
|
|
139
|
+
assertOptionalFiniteNumber(params.y, "y");
|
|
140
|
+
};
|
|
141
|
+
var validateUvTranslateParams = (params) => {
|
|
142
|
+
assertEffectParamsObject(params, "uvTranslate");
|
|
143
|
+
assertOptionalFiniteNumber(params.u, "u");
|
|
144
|
+
assertOptionalFiniteNumber(params.v, "v");
|
|
145
|
+
};
|
|
146
|
+
var applyTranslate = ({
|
|
147
|
+
source,
|
|
148
|
+
target,
|
|
149
|
+
width,
|
|
150
|
+
height,
|
|
151
|
+
x,
|
|
152
|
+
y
|
|
153
|
+
}) => {
|
|
154
|
+
const ctx = target.getContext("2d");
|
|
155
|
+
if (!ctx) {
|
|
156
|
+
throw new Error("Failed to acquire 2D context for translate effect. The canvas may have been assigned a different context type.");
|
|
157
|
+
}
|
|
158
|
+
ctx.clearRect(0, 0, width, height);
|
|
159
|
+
ctx.drawImage(source, x, y, width, height);
|
|
160
|
+
};
|
|
161
|
+
var xyTranslate = createEffect({
|
|
162
|
+
type: "remotion/xy-translate",
|
|
163
|
+
label: "xyTranslate()",
|
|
164
|
+
documentationLink: "https://www.remotion.dev/docs/effects/xy-translate",
|
|
165
|
+
backend: "2d",
|
|
166
|
+
calculateKey: (params) => {
|
|
167
|
+
const r = resolveXyTranslate(params);
|
|
168
|
+
return `xy-translate-${r.x}-${r.y}`;
|
|
169
|
+
},
|
|
170
|
+
setup: () => null,
|
|
171
|
+
apply: ({ source, target, width, height, params }) => {
|
|
172
|
+
const r = resolveXyTranslate(params);
|
|
173
|
+
applyTranslate({
|
|
174
|
+
source,
|
|
175
|
+
target,
|
|
176
|
+
width,
|
|
177
|
+
height,
|
|
178
|
+
x: r.x,
|
|
179
|
+
y: r.y
|
|
180
|
+
});
|
|
181
|
+
},
|
|
182
|
+
cleanup: () => {
|
|
183
|
+
return;
|
|
184
|
+
},
|
|
185
|
+
schema: xyTranslateSchema,
|
|
186
|
+
validateParams: validateXyTranslateParams
|
|
187
|
+
});
|
|
188
|
+
var uvTranslate = createEffect({
|
|
189
|
+
type: "remotion/uv-translate",
|
|
190
|
+
label: "uvTranslate()",
|
|
191
|
+
documentationLink: "https://www.remotion.dev/docs/effects/uv-translate",
|
|
192
|
+
backend: "2d",
|
|
193
|
+
calculateKey: (params) => {
|
|
194
|
+
const r = resolveUvTranslate(params);
|
|
195
|
+
return `uv-translate-${r.u}-${r.v}`;
|
|
196
|
+
},
|
|
197
|
+
setup: () => null,
|
|
198
|
+
apply: ({ source, target, width, height, params }) => {
|
|
199
|
+
const r = resolveUvTranslate(params);
|
|
200
|
+
applyTranslate({
|
|
201
|
+
source,
|
|
202
|
+
target,
|
|
203
|
+
width,
|
|
204
|
+
height,
|
|
205
|
+
x: r.u * width,
|
|
206
|
+
y: r.v * height
|
|
207
|
+
});
|
|
208
|
+
},
|
|
209
|
+
cleanup: () => {
|
|
210
|
+
return;
|
|
211
|
+
},
|
|
212
|
+
schema: uvTranslateSchema,
|
|
213
|
+
validateParams: validateUvTranslateParams
|
|
214
|
+
});
|
|
215
|
+
export {
|
|
216
|
+
xyTranslate,
|
|
217
|
+
uvTranslate
|
|
218
|
+
};
|