🎥 Make videos programmatically with React
import {useLayoutEffect, useRef} from 'react';
import {AbsoluteFill} from 'remotion';
const Component: React.FC = () => {
const ref = useRef<HTMLCanvasElement>(null);
useLayoutEffect(() => {
if (!ref.current) return;
const ctx = ref.current.getContext('2d');
if (!ctx) return;
ctx.fillStyle = 'purple';
ctx.fillRect(0, 0, 100, 100);
ctx.fillStyle = 'yellow';
ctx.fillRect(25, 25, 50, 50);
}, []);
return (
<AbsoluteFill
style={{
justifyContent: 'center',
alignItems: 'center',
backgroundColor: 'white',
}}
>
<canvas
ref={ref}
style={{
borderRadius: '10px 20px 30px 40px',
}}
width={100}
height={100}
/>
</AbsoluteFill>
);
};
export const borderRadiusDifferent = {
component: Component,
id: 'border-radius-different',
width: 200,
height: 200,
fps: 25,
durationInFrames: 1,
} as const;