|
| 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) |
0 commit comments