Skip to content

🎥 Make videos programmatically with React

LGTM

Jonny Burger61c11aa7b973
diff --git a/packages/docs/docs/canvasimage.mdx b/packages/docs/docs/canvasimage.mdx
index 5ff0eb38e7..8a11fe5b2a 100644
--- a/packages/docs/docs/canvasimage.mdx
+++ b/packages/docs/docs/canvasimage.mdx
@@ -9,8 +9,9 @@ crumb: 'API'
Renders a static image onto a [`<canvas>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/canvas) element.
-Use it when you want to apply Remotion [`effects`](/docs/effects/api) to a static image.
-Use [`<Img>`](/docs/img) if you need a regular `<img>` tag without effects.
+Benefit: You can attach [`effects`](/docs/effects/api) to the image.
+Drawback: Assets must support CORS.
+Use [`<Img>`](/docs/img) if you want a component based on the regular `<img>` tag.
```tsx twoslash title="MyComp.tsx"
import {AbsoluteFill, CanvasImage, staticFile} from 'remotion';
@@ -18,7 +19,7 @@ import {AbsoluteFill, CanvasImage, staticFile} from 'remotion';
export const MyComp: React.FC = () => {
return (
<AbsoluteFill>
- <CanvasImage src={staticFile('image.png')} width={1920} height={1080} />
+ <CanvasImage src={staticFile('image.png')} />
</AbsoluteFill>
);
};
@@ -52,7 +53,7 @@ Must be one of these values:
### `effects?`
-An array of Remotion effects to apply to the image after it has been drawn to the source canvas.
+An array of Remotion [effects](/docs/effects/api) to apply to the image after it has been drawn to the source canvas.
### `className?`
@@ -62,10 +63,6 @@ A class name to apply to the `<canvas>` element.
Inline styles to apply to the `<canvas>` element.
-### `id?`
-
-An ID to apply to the `<canvas>` element.
-
### `onError?`
Called when the image cannot be loaded, decoded, or drawn.
diff --git a/packages/example/src/SimpleImg/CanvasImg.tsx b/packages/example/src/SimpleImg/CanvasImg.tsx
index e5d3c4fd3f..9d0c99c07d 100644
--- a/packages/example/src/SimpleImg/CanvasImg.tsx
+++ b/packages/example/src/SimpleImg/CanvasImg.tsx
@@ -1,6 +1,16 @@
+import {halftone} from '@remotion/effects/halftone';
import React from 'react';
import {CanvasImage, staticFile} from 'remotion';
export const CanvasImg = (): React.ReactNode => {
- return <CanvasImage src={staticFile('1.jpg')} />;
+ return (
+ <CanvasImage
+ effects={[
+ halftone({
+ dotSize: 28,
+ }),
+ ]}
+ src={staticFile('1.jpg')}
+ />
+ );
};