🎥 Make videos programmatically with React
demo
Jonny Burgercfa0268efcc6
diff --git a/packages/docs/docs/interpolate-colors.md b/packages/docs/docs/interpolate-colors.mdindex 9c1b03b27c..a34ecf80e7 100644--- a/packages/docs/docs/interpolate-colors.md+++ b/packages/docs/docs/interpolate-colors.md@@ -24,19 +24,19 @@ In this example, we are interpolating colors from red to yellow. At frame 0 (theUsing the following snippet, we can calculate the current color for any frame:```tsx-import {useCurrentFrame, interpolateColors} from 'remotion'+import {useCurrentFrame, interpolateColors} from 'remotion';const frame = useCurrentFrame(); // 10const color = interpolateColors(input,[0, 20],['red', 'yellow']-); //rgba(255, 128, 0, 1)+); // rgba(255, 128, 0, 1)const color = interpolateColors(input,[0, 20],['#ff0000', '#ffff00']-); //rgba(255, 128, 0, 1)+); // rgba(255, 128, 0, 1)```## Example: interpolate `rgb` or `rgba` colors@@ -50,17 +50,17 @@ import {useCurrentFrame, interpolateColors} from 'remotion'const frame = useCurrentFrame(); // 10-//rgb+// RGB colorsconst color = interpolateColors(input,[0, 20],['rgb(255, 0, 0)', 'rgb(255, 255, 0)']-); //rgba(255, 128, 0, 1)+); // rgba(255, 128, 0, 1)-//rgba+// RGBA colorsconst color = interpolateColors(input,[0, 20],- ['rgba(255, 0, 0, 1)', 'rgba(255, 255, 0, 1)']-); //rgba(255, 128, 0, 1)+ ['rgba(255, 0, 0, 1)', 'rgba(255, 255, 0, 0)']+); // rgba(255, 128, 0, 0.5)```## Example: interpolate `hsl` or `hsla` colors@@ -77,17 +77,30 @@ const frame = useCurrentFrame(); // 10const color = interpolateColors(input,[0, 20],['hsl(0, 100%, 50%)', 'hsl(60, 100%, 50%)']-); //rgba(255, 128, 0, 1)+); // rgba(255, 128, 0, 1)//hsla exampleconst color = interpolateColors(input,[0, 20],['hsla(0, 100%, 50%, 1)', 'hsla(60, 100%, 50%, 1)']-); //rgba(255, 128, 0, 1)+); // rgba(255, 128, 0, 1)```+## Example: interpolate color names++Interpolating CSS color names is also supported.++```tsx+import {useCurrentFrame, interpolateColors} from 'remotion'++const frame = useCurrentFrame(); // 10++const color = interpolateColors(input,+ [0, 20],+ ['red', 'yellow']+); // rgba(255, 128, 0, 1)+```## See also- [interpolate()](/docs/interpolate)-- [spring()](/docs/spring)\ No newline at end of filediff --git a/packages/docs/docs/interpolate.md b/packages/docs/docs/interpolate.mdindex 892219d422..37d50bb6ce 100644--- a/packages/docs/docs/interpolate.md+++ b/packages/docs/docs/interpolate.md@@ -155,3 +155,4 @@ interpolate(frame, [0, 10, 40, 100], [0, 0.2, 0.6, 1], {- [Easing](/docs/easing)- [spring()](/docs/spring)+- [interpolateColors()](/docs/interpolate-colors)diff --git a/packages/example/src/ColorInterpolation/index.tsx b/packages/example/src/ColorInterpolation/index.tsxnew file mode 100644index 0000000000..f1fd137fd2--- /dev/null+++ b/packages/example/src/ColorInterpolation/index.tsx@@ -0,0 +1,18 @@+import React from 'react';+import {interpolateColors, useCurrentFrame} from 'remotion';++export const ColorInterpolation: React.FC = () => {+ const frame = useCurrentFrame();+ return (+ <div+ style={{+ flex: 1,+ backgroundColor: interpolateColors(+ frame,+ [0, 50, 100],+ ['red', 'yellow', 'blue']+ ),+ }}+ />+ );+};diff --git a/packages/example/src/Video.tsx b/packages/example/src/Video.tsxindex 16a5beec9d..1ee3292861 100644--- a/packages/example/src/Video.tsx+++ b/packages/example/src/Video.tsx@@ -1,5 +1,6 @@import React from 'react';import {Composition, getInputProps} from 'remotion';+import {ColorInterpolation} from './ColorInterpolation';import {Framer} from './Framer';import {MissingImg} from './MissingImg';import RemoteVideo from './RemoteVideo';@@ -240,6 +241,14 @@ export const Index: React.FC = () => {fps={30}durationInFrames={600}/>+ <Composition+ id="color-interpolation"+ component={ColorInterpolation}+ width={1280}+ height={720}+ fps={30}+ durationInFrames={100}+ /></>);};