Skip to content

🎥 Make videos programmatically with React

alright

Jonny Burgerbe7489896623
diff --git a/packages/docs/components/LandingPage/BackgroundAnimation.tsx b/packages/docs/components/LandingPage/BackgroundAnimation.tsx
index b51326297f..ff9fedcf7c 100644
--- a/packages/docs/components/LandingPage/BackgroundAnimation.tsx
+++ b/packages/docs/components/LandingPage/BackgroundAnimation.tsx
@@ -1,37 +1,36 @@
+import { getLength } from "@remotion/paths";
import React, { useEffect } from "react";
-import {getLength} from '@remotion/paths'
-import styles from './bg-anim.module.css'
+import styles from "./bg-anim.module.css";
const rx = 0.2;
-const ry = 0.45
-
+const ry = 0.45;
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;
+ 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;
}
-const strokeWidth = 0.035
+const strokeWidth = 0.035;
export const BackgroundAnimation: React.FC = () => {
- const d = ellipseToPath(0.5, 0.5)
- const length = getLength(d)
+ const d = ellipseToPath(0.5, 0.5);
+ const length = getLength(d);
const css = `
@keyframes bganimation {
@@ -46,61 +45,64 @@ export const BackgroundAnimation: React.FC = () => {
`;
useEffect(() => {
- const _style = document.createElement('style');
+ const _style = document.createElement("style");
_style.innerHTML = css;
document.head.appendChild(_style);
- }, [css])
+ }, [css]);
return (
- <div className={styles.bganimcontainer}>
- <svg className={styles.svg} viewBox="0 0 1 1" style={{
- width: '100%',
- zIndex: -1,
- position: 'absolute',
- }}>
- <path
- d={d}
- fill="none"
- stroke="var(--ifm-color-primary)"
- strokeLinecap="round"
- className={styles.p}
+ <div className={styles.bganimcontainer}>
+ <svg
+ className={styles.svg}
+ viewBox="0 0 1 1"
style={{
- transformOrigin: 'center center',
- transform: `rotate(120deg)`,
- animation: `bganimation 20s linear infinite`,
- strokeDasharray: `${length * 0.2} ${length * 0.8}`,
+ width: "100%",
+ zIndex: -1,
+ position: "absolute",
}}
+ >
+ <path
+ d={d}
+ fill="none"
+ stroke="var(--ifm-color-primary)"
+ strokeLinecap="round"
+ className={styles.p}
+ style={{
+ transformOrigin: "center center",
+ transform: `rotate(120deg)`,
+ animation: `bganimation 20s linear infinite`,
+ strokeDasharray: `${length * 0.2} ${length * 0.8}`,
+ }}
/>
- <path
- d={d}
- fill="none"
- stroke="var(--ifm-color-primary)"
- strokeLinecap="round"
- strokeWidth={strokeWidth}
- className={styles.p}
- style={{
- transformOrigin: 'center center',
- transform: `rotate(0deg)`,
- animation: `bganimation 20s linear infinite`,
- strokeDasharray: `${length * 0.2} ${length * 0.8}`,
-
- }}
+ <path
+ d={d}
+ fill="none"
+ stroke="var(--ifm-color-primary)"
+ strokeLinecap="round"
+ strokeWidth={strokeWidth}
+ className={styles.p}
+ style={{
+ transformOrigin: "center center",
+ transform: `rotate(0deg)`,
+ animation: `bganimation 20s linear infinite`,
+ strokeDasharray: `${length * 0.2} ${length * 0.8}`,
+ }}
/>
- <path
- d={d}
- fill="none"
- stroke="var(--ifm-color-primary)"
- strokeLinecap="round"
- strokeWidth={strokeWidth}
- className={styles.p}
- style={{
- transformOrigin: 'center center',
- transform: `rotate(240deg)`,
- animation: `bganimation 20s linear infinite`,
- strokeDasharray: `${length * 0.2} ${length * 0.8}`,
- }}
+ <path
+ d={d}
+ fill="none"
+ stroke="var(--ifm-color-primary)"
+ strokeLinecap="round"
+ strokeWidth={strokeWidth}
+ className={styles.p}
+ style={{
+ transformOrigin: "center center",
+ transform: `rotate(240deg)`,
+ animation: `bganimation 20s linear infinite`,
+ strokeDasharray: `${length * 0.2} ${length * 0.8}`,
+ }}
/>
- </svg>
+ </svg>
</div>
- )
-}
+ );
+};
diff --git a/packages/docs/components/LandingPage/bg-anim.module.css b/packages/docs/components/LandingPage/bg-anim.module.css
index 12590deea7..68aaab22ed 100644
--- a/packages/docs/components/LandingPage/bg-anim.module.css
+++ b/packages/docs/components/LandingPage/bg-anim.module.css
@@ -9,8 +9,8 @@
@media screen and (max-width: 700px) {
.bganimcontainer {
position: absolute;
- width: 100vw;
- height: 100vw;
+ width: 100%;
+ height: 100%;
left: 50%;
margin-left: -50%;
min-width: 0;
@@ -35,5 +35,4 @@
.p {
stroke-width: 0.04;
}
-
}