Skip to content

🎥 Make videos programmatically with React

eh

Jonny Burger0413f3fad247
diff --git a/packages/docs/components/LandingPage/BackgroundAnimation.tsx b/packages/docs/components/LandingPage/BackgroundAnimation.tsx
new file mode 100644
index 0000000000..1c0a418d81
--- /dev/null
+++ b/packages/docs/components/LandingPage/BackgroundAnimation.tsx
@@ -0,0 +1,66 @@
+import React from "react";
+import { random, useVideoConfig } from "remotion";
+import {getLength} from '@remotion/paths'
+import './bganimation.css'
+
+const style: React.CSSProperties = {
+ position: 'absolute',
+ width: '100%',
+}
+
+
+const rx = 0.25;
+const ry = 0.5
+
+
+function ellipseToPath(cx: number, cy: number): string {
+ let output = 'M' + (cx - rx).toString() + ',' + cy.toString();
+ output +=
+ 'a' +
+ rx.toString() +
+ ',' +
+ ry.toString() +
+ ' 0 1,0 ' +
+ (2 * rx).toString() +
+ ',0';
+ output +=
+ 'a' +
+ rx.toString() +
+ ',' +
+ ry.toString() +
+ ' 0 1,0 ' +
+ (-2 * rx).toString() +
+ ',0';
+ return output;
+}
+
+export const BackgroundAnimation: React.FC = () => {
+ const d = ellipseToPath(0.5, 0.5)
+ const length = getLength(d)
+ console.log(length)
+
+ return (
+ <div style={style}>
+ <svg viewBox="0 0 1 1" style={{
+ width: '100%',
+ position: 'absolute',
+ zIndex: -1
+ }}>
+ <g transform="translate(0, -0.4)">
+ <path
+ d={d}
+ fill="none"
+ stroke="var(--ifm-color-primary)"
+ strokeLinecap="round"
+ strokeWidth={0.035}
+ style={{
+ transformOrigin: 'center center',
+ transform: `rotate(${random('hia') * 360}deg)`,
+ animation: `bganimation 20s linear infinite`
+ }}
+ />
+ </g>
+ </svg>
+ </div>
+ )
+}
diff --git a/packages/docs/components/LandingPage/bganimation.css b/packages/docs/components/LandingPage/bganimation.css
new file mode 100644
index 0000000000..3ac677e390
--- /dev/null
+++ b/packages/docs/components/LandingPage/bganimation.css
@@ -0,0 +1,12 @@
+@keyframes bganimation {
+ from {
+ stroke-dasharray: 0.2 1.8;
+ stroke-dashoffset: 0
+ }
+
+ to {
+ stroke-dasharray: 0.2 1.8;
+
+ stroke-dashoffset: 2.2;
+ }
+}
diff --git a/packages/docs/src/pages/index.tsx b/packages/docs/src/pages/index.tsx
index f246f60c9f..790754ca8c 100644
--- a/packages/docs/src/pages/index.tsx
+++ b/packages/docs/src/pages/index.tsx
@@ -12,6 +12,7 @@ import { WriteInReact } from "../../components/LandingPage/WriteInReact";
import styles from "./landing.module.css";
import { VideoApps } from "../../components/LambdaSplash/VideoApps";
import { VideoAppsTitle } from "../../components/LambdaSplash/VideoAppsTitle";
+import { BackgroundAnimation } from "../../components/LandingPage/BackgroundAnimation";
setTimeout(() => {
splitbee.init();
@@ -25,9 +26,10 @@ const NewLanding: React.FC = () => {
<meta
name="description"
content="Create MP4 motion graphics in React. Leverage CSS, SVG, WebGL and more
- technologies to render videos programmatically!"
+ technologies to render videos programmatically!"
/>
</Head>
+ <BackgroundAnimation />
<br />
<br />
<br />