Skip to content

Commit 03ae033

Browse files
committed
Add zoom blur effect
1 parent fee1709 commit 03ae033

17 files changed

Lines changed: 612 additions & 1 deletion

File tree

packages/docs/components/effects-demos/registry.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import {wave} from '@remotion/effects/wave';
3434
import {waves} from '@remotion/effects/waves';
3535
import {whiteNoise} from '@remotion/effects/white-noise';
3636
import {zigzag} from '@remotion/effects/zigzag';
37+
import {zoomBlur} from '@remotion/effects/zoom-blur';
3738
import {lightLeakEffectSchema} from '@remotion/light-leaks';
3839
import {starburstEffectSchema} from '@remotion/starburst';
3940
import {EffectsBarrelDistortionPreview} from '../effects/effects-barrel-distortion-preview';
@@ -80,6 +81,7 @@ import {EffectsWavePreview} from '../effects/effects-wave-preview';
8081
import {EffectsWavesPreview} from '../effects/effects-waves-preview';
8182
import {EffectsWhiteNoisePreview} from '../effects/effects-white-noise-preview';
8283
import {EffectsZigzagPreview} from '../effects/effects-zigzag-preview';
84+
import {EffectsZoomBlurPreview} from '../effects/effects-zoom-blur-preview';
8385
import type {EffectsDemoType} from './types';
8486

8587
const defaults = {
@@ -338,6 +340,14 @@ export const effectsDemos: EffectsDemoType[] = [
338340
comp: EffectsLinearProgressiveBlurPreview,
339341
schema: linearProgressiveBlur().definition.schema,
340342
},
343+
{
344+
...defaults,
345+
id: 'effects-zoom-blur',
346+
effectName: 'zoomBlur',
347+
effectImportPath: '@remotion/effects/zoom-blur',
348+
comp: EffectsZoomBlurPreview,
349+
schema: zoomBlur().definition.schema,
350+
},
341351
{
342352
...defaults,
343353
id: 'effects-chromatic-aberration',
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import {zoomBlur} from '@remotion/effects/zoom-blur';
2+
import React from 'react';
3+
import {CanvasImage} from 'remotion';
4+
import {EFFECTS_PREVIEW_IMAGE_SRC} from './effects-preview-image';
5+
6+
export const EffectsZoomBlurPreview: React.FC<{
7+
readonly amount: number;
8+
readonly center: readonly [number, number];
9+
readonly samples: number;
10+
}> = ({amount, center, samples}) => {
11+
return (
12+
<CanvasImage
13+
src={EFFECTS_PREVIEW_IMAGE_SRC}
14+
width={1280}
15+
height={720}
16+
fit="cover"
17+
effects={[zoomBlur({amount, center, samples})]}
18+
/>
19+
);
20+
};

packages/docs/docs/effects/table-of-contents.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,13 @@ const categories: {
105105
name: 'linearProgressiveBlur()',
106106
description: 'Gradient-controlled blur effect',
107107
},
108+
{
109+
link: '/docs/effects/zoom-blur',
110+
preview: '/img/effects-zoom-blur-preview.png',
111+
alt: 'zoom blur effect preview',
112+
name: 'zoomBlur()',
113+
description: 'Radial zoom blur effect',
114+
},
108115
{
109116
link: '/docs/effects/drop-shadow',
110117
preview: '/img/effects-drop-shadow-preview.png',
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
---
2+
image: /generated/articles-docs-effects-zoom-blur.png
3+
slug: /effects/zoom-blur
4+
title: zoomBlur()
5+
sidebar_label: zoomBlur()
6+
crumb: '@remotion/effects'
7+
---
8+
9+
# zoomBlur()<AvailableFrom v="4.0.476" />
10+
11+
_Part of the [`@remotion/effects`](/docs/effects/api) package._
12+
13+
A radial zoom blur that smears pixels away from a configurable center point. It can be applied to canvas-based components such as [`<Video>`](/docs/media/video), [`<HtmlInCanvas>`](/docs/remotion/html-in-canvas) and [`<Solid>`](/docs/solid).
14+
15+
## Preview
16+
17+
<EffectsDemo type="effects-zoom-blur" />
18+
19+
## Example
20+
21+
```tsx twoslash title="MyComp.tsx"
22+
import {AbsoluteFill, interpolate, useCurrentFrame} from 'remotion';
23+
import {Video} from '@remotion/media';
24+
import {zoomBlur} from '@remotion/effects/zoom-blur';
25+
26+
export const MyComp: React.FC = () => {
27+
const frame = useCurrentFrame();
28+
const amount = interpolate(frame, [0, 20], [80, 0], {
29+
extrapolateRight: 'clamp',
30+
});
31+
32+
return (
33+
<AbsoluteFill>
34+
<Video
35+
src="https://remotion.media/video.mp4"
36+
effects={[
37+
zoomBlur({
38+
amount,
39+
center: [0.25, 0.5],
40+
}),
41+
]}
42+
/>
43+
</AbsoluteFill>
44+
);
45+
};
46+
```
47+
48+
## API
49+
50+
Pass an object with the following properties.
51+
52+
### `amount?`
53+
54+
The blur strength in pixels. Defaults to `40`.
55+
56+
Set to `0` to leave the source unchanged.
57+
58+
### `center?`
59+
60+
The origin of the blur in UV coordinates. Defaults to `[0.5, 0.5]`.
61+
62+
Use `[0, 0.5]` for a center on the left edge, `[1, 0.5]` for a center on the right edge, and `[0.5, 0.5]` for a centered zoom blur.
63+
64+
### `samples?`
65+
66+
The number of samples used to average the blur. Defaults to `24`.
67+
68+
Higher values are smoother and more expensive to render. Must be an integer between `1` and `64`.
69+
70+
### `disabled?`
71+
72+
When `true`, the effect is skipped. Defaults to `false`.
73+
74+
## Requirements
75+
76+
`zoomBlur()` uses a WebGL2 backend. During renders, enable WebGL via [`Config.setChromiumOpenGlRenderer('angle')`](/docs/config#setchromiumopenglrenderer). See [Using WebGL during renders](/docs/remotion/html-in-canvas#using-webgl-during-renders).
77+
78+
## See also
79+
80+
- [`@remotion/effects`](/docs/effects/api)
81+
- [`blur()`](/docs/effects/blur)
82+
- [`linearProgressiveBlur()`](/docs/effects/linear-progressive-blur)
83+
- [HTML-in-canvas guide](/docs/html-in-canvas)
84+
- [Source code for this effect](https://github.com/remotion-dev/remotion/blob/main/packages/effects/src/zoom-blur/index.ts)

packages/docs/sidebars.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ const sidebars: SidebarsConfig = {
307307
'effects/white-noise',
308308
'effects/xy-translate',
309309
'effects/zigzag',
310+
'effects/zoom-blur',
310311
],
311312
},
312313
{

packages/docs/src/data/articles.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2069,6 +2069,15 @@ export const articles = [
20692069
noAi: false,
20702070
slug: 'effects/zigzag',
20712071
},
2072+
{
2073+
id: 'effects/zoom-blur',
2074+
title: 'zoomBlur()',
2075+
relativePath: 'docs/effects/zoom-blur.mdx',
2076+
compId: 'articles-docs-effects-zoom-blur',
2077+
crumb: '@remotion/effects',
2078+
noAi: false,
2079+
slug: 'effects/zoom-blur',
2080+
},
20722081
{
20732082
id: 'electron',
20742083
title: 'Using Remotion in Electron',

packages/docs/src/remotion/Root.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ import {EffectsWavePreview} from '../../components/effects/effects-wave-preview'
4747
import {EffectsWavesPreview} from '../../components/effects/effects-waves-preview';
4848
import {EffectsWhiteNoisePreview} from '../../components/effects/effects-white-noise-preview';
4949
import {EffectsZigzagPreview} from '../../components/effects/effects-zigzag-preview';
50+
import {EffectsZoomBlurPreview} from '../../components/effects/effects-zoom-blur-preview';
5051
import {articles} from '../data/articles';
5152
import {AllTemplates} from './AllTemplates';
5253
import {Article} from './Article';
@@ -303,6 +304,13 @@ export const RemotionRoot: React.FC = () => {
303304
endBlur: 50,
304305
}}
305306
/>
307+
<Still
308+
id="effects-zoom-blur-preview"
309+
component={EffectsZoomBlurPreview}
310+
width={1280}
311+
height={720}
312+
defaultProps={{amount: 80, center: [0.22, 0.5], samples: 32}}
313+
/>
306314
<Still
307315
id="effects-wave-preview"
308316
component={EffectsWavePreview}
40.3 KB
Loading
719 KB
Loading

packages/effects/bundle.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ const effectEntrypoints = [
4343
'src/waves.ts',
4444
'src/zigzag.ts',
4545
'src/white-noise.ts',
46+
'src/zoom-blur.ts',
4647
];
4748

4849
console.time('Generated.');

0 commit comments

Comments
 (0)