Skip to content

🎥 Make videos programmatically with React

sketch it out

Jonny Burgerebdfd5d21855
diff --git a/packages/docs/components/demos/Pie.tsx b/packages/docs/components/demos/Pie.tsx
new file mode 100644
index 0000000000..182139510e
--- /dev/null
+++ b/packages/docs/components/demos/Pie.tsx
@@ -0,0 +1,24 @@
+import { Pie } from "@remotion/shapes";
+import React from "react";
+import { AbsoluteFill } from "remotion";
+
+export const PieDemo: React.FC<{
+ radius: number;
+ darkMode: boolean;
+ fillAmount: number;
+}> = ({ radius, darkMode, fillAmount }) => {
+ return (
+ <AbsoluteFill
+ style={{
+ justifyContent: "center",
+ alignItems: "center",
+ }}
+ >
+ <Pie
+ fillAmount={fillAmount}
+ fill={darkMode ? "white" : "var(--ifm-link-color)"}
+ radius={radius}
+ />
+ </AbsoluteFill>
+ );
+};
diff --git a/packages/docs/components/demos/index.tsx b/packages/docs/components/demos/index.tsx
index df85976ff3..5193c42be4 100644
--- a/packages/docs/components/demos/index.tsx
+++ b/packages/docs/components/demos/index.tsx
@@ -9,6 +9,7 @@ import {
circleDemo,
ellipseDemo,
noiseDemo,
+ pieDemo,
rectDemo,
starDemo,
triangleDemo,
@@ -29,6 +30,7 @@ const demos: DemoType[] = [
circleDemo,
ellipseDemo,
starDemo,
+ pieDemo,
];
export const Demo: React.FC<{
diff --git a/packages/docs/components/demos/types.ts b/packages/docs/components/demos/types.ts
index e3e0c45821..a528387a6d 100644
--- a/packages/docs/components/demos/types.ts
+++ b/packages/docs/components/demos/types.ts
@@ -1,6 +1,7 @@
import { CircleDemo } from "./Circle";
import { EllipseDemo } from "./Ellipse";
import { NoiseComp } from "./NoiseDemo";
+import { PieDemo } from "./Pie";
import { RectDemo } from "./Rect";
import { StarDemo } from "./Star";
import { TriangleDemo } from "./Triangle";
@@ -151,7 +152,28 @@ export const circleDemo: DemoType = {
durationInFrames: 150,
fps: 30,
id: "circle",
- autoPlay: true,
+ autoPlay: false,
+ options: [
+ {
+ default: 200,
+ max: 1000,
+ step: 5,
+ min: 1,
+ type: "numeric",
+ name: "radius",
+ optional: "no",
+ },
+ ],
+};
+
+export const pieDemo: DemoType = {
+ comp: PieDemo,
+ compHeight: 720,
+ compWidth: 1280,
+ durationInFrames: 150,
+ fps: 30,
+ id: "pie",
+ autoPlay: false,
options: [
{
default: 200,
@@ -162,6 +184,15 @@ export const circleDemo: DemoType = {
name: "radius",
optional: "no",
},
+ {
+ default: 0.5,
+ step: 0.01,
+ min: 0,
+ max: 1,
+ type: "numeric",
+ name: "fillAmount",
+ optional: "no",
+ },
],
};
@@ -172,7 +203,7 @@ export const ellipseDemo: DemoType = {
durationInFrames: 150,
fps: 30,
id: "ellipse",
- autoPlay: true,
+ autoPlay: false,
options: [
{
default: 150,
@@ -202,7 +233,7 @@ export const starDemo: DemoType = {
durationInFrames: 150,
fps: 30,
id: "star",
- autoPlay: true,
+ autoPlay: false,
options: [
{
default: 100,
diff --git a/packages/docs/components/shapes/shapes-info.tsx b/packages/docs/components/shapes/shapes-info.tsx
index 57bcea4611..9085763788 100644
--- a/packages/docs/components/shapes/shapes-info.tsx
+++ b/packages/docs/components/shapes/shapes-info.tsx
@@ -1,6 +1,7 @@
import {
makeCircle,
makeEllipse,
+ makePie,
makeRect,
makeStar,
makeTriangle,
@@ -52,6 +53,23 @@ export const shapeComponents: ShapeComponent[] = [
},
],
},
+ {
+ shape: "Pie",
+ fn: makePie,
+ params: [
+ {
+ name: "radius",
+ type: "number",
+ description: "The radius of the circle.",
+ },
+ {
+ name: "fillAmount",
+ type: "number",
+ description:
+ "The percentage of the circle that is filled. 0 means fully empty, 1 means fully filled.",
+ },
+ ],
+ },
{
shape: "Ellipse",
fn: makeEllipse,
diff --git a/packages/docs/docs/shapes/make-pie.md b/packages/docs/docs/shapes/make-pie.md
new file mode 100644
index 0000000000..b4b7fd934d
--- /dev/null
+++ b/packages/docs/docs/shapes/make-pie.md
@@ -0,0 +1,39 @@
+---
+title: makePie()
+crumb: "@remotion/shapes"
+---
+
+import {MakeShapeSeeAlso, ShapeOptions, MakeShapeReturnType} from "../../components/shapes/shapes-info"
+
+_Part of the [`@remotion/shapes`](/docs/shapes) package._
+
+Generates a piece of pie SVG path.
+
+## Example
+
+```tsx twoslash title="pie.ts"
+import { makePie } from "@remotion/shapes";
+
+const { path, width, height, transformOrigin } = makePie({
+ radius: 50,
+ fillAmount: 0.5,
+});
+
+// TOOD: Wrong paths
+console.log(path); // M 0 0 m -50, 0 a 50,50 0 1,0 100,0 50,50 0 1,0 -100,0
+console.log(width); // 100
+console.log(height); // 100
+console.log(transformOrigin); // '50 50'
+```
+
+## Arguments
+
+<ShapeOptions shape="pie"/>
+
+## Return type
+
+<MakeShapeReturnType shape="pie"/>
+
+## See also
+
+<MakeShapeSeeAlso shape="pie"/>
diff --git a/packages/docs/docs/shapes/pie.md b/packages/docs/docs/shapes/pie.md
new file mode 100644
index 0000000000..054cd18bf0
--- /dev/null
+++ b/packages/docs/docs/shapes/pie.md
@@ -0,0 +1,49 @@
+---
+title: <Pie />
+crumb: "@remotion/shapes"
+---
+
+import {ShapeSeeAlso, ShapeOptions} from "../../components/shapes/shapes-info"
+
+_Part of the [`@remotion/shapes`](/docs/shapes) package._
+
+Renders an SVG element drawing a pie piece.
+
+## Explorer
+
+<Demo type="pie" />
+
+## Example
+
+```tsx twoslash title="src/Pie.tsx"
+import { Pie } from "@remotion/shapes";
+import { AbsoluteFill } from "remotion";
+
+export const MyComposition = () => {
+ return (
+ <AbsoluteFill
+ style={{
+ backgroundColor: "white",
+ justifyContent: "center",
+ alignItems: "center",
+ }}
+ >
+ <Pie
+ radius={100}
+ fillAmount={0.5}
+ fill="green"
+ stroke="red"
+ strokeWidth={1}
+ />
+ </AbsoluteFill>
+ );
+};
+```
+
+## Props
+
+<ShapeOptions shape="pie" all />
+
+## See also
+
+<ShapeSeeAlso shape="pie"/>
diff --git a/packages/docs/sidebars.js b/packages/docs/sidebars.js
index bd23c724af..8e515ce05d 100644
--- a/packages/docs/sidebars.js
+++ b/packages/docs/sidebars.js
@@ -300,11 +300,13 @@ module.exports = {
"shapes/circle",
"shapes/ellipse",
"shapes/star",
+ "shapes/pie",
"shapes/make-rect",
"shapes/make-triangle",
"shapes/make-circle",
"shapes/make-ellipse",
"shapes/make-star",
+ "shapes/make-pie",
],
},
],