🎥 Make videos programmatically with React
better docs
Jonny Burger7fbc89bde7e9
diff --git a/packages/docs/components/shapes/shapes-info.tsx b/packages/docs/components/shapes/shapes-info.tsxindex 095441d093..c10ef390b5 100644--- a/packages/docs/components/shapes/shapes-info.tsx+++ b/packages/docs/components/shapes/shapes-info.tsx@@ -11,24 +11,93 @@ export const shapeComponents = [shape: "Rect",name: "<Rect>",fn: makeRect,+ params: [+ {+ name: "width",+ type: "number",+ description: "The width of the rectangle.",+ },+ {+ name: "height",+ type: "number",+ description: "The height of the rectangle.",+ },+ ],},{shape: "Circle",name: "<Circle>",fn: makeCircle,+ params: [+ {+ name: "radius",+ type: "number",+ description: "The radius of the circle.",+ },+ ],},{shape: "Ellipse",name: "<Ellipse>",fn: makeEllipse,+ params: [+ {+ name: "rx",+ type: "number",+ description: "The radius of the ellipse on the X axis.",+ },+ {+ name: "ry",+ type: "number",+ description: "The radius of the ellipse on the Y axis.",+ },+ ],},{shape: "Triangle",name: "<Triangle>",fn: makeTriangle,+ params: [+ {+ name: "length",+ type: "number",+ description: "The length of one triangle side.",+ },+ {+ name: "direction",+ type: '"left" | "right" | "up" | "down"',+ description: "The direction of the triangle.",+ },+ ],},];+export const ShapeOptions: React.FC<{+ shape: string;+}> = ({ shape }) => {+ const shapeComponent = shapeComponents.find(+ (c) => c.shape.toLowerCase() === shape.toLowerCase()+ );++ return (+ <React.Fragment>+ {shapeComponent.params.map((p) => {+ return (+ <React.Fragment key={p.name}>+ <h3>+ <code>{p.name}</code>+ </h3>+ <p>+ <em>{p.type}</em>+ </p>+ <p>{p.description}</p>+ </React.Fragment>+ );+ })}+ </React.Fragment>+ );+};+export const MakeShapeSeeAlso: React.FC<{shape: string;}> = ({ shape }) => {diff --git a/packages/docs/docs/shapes/make-circle.md b/packages/docs/docs/shapes/make-circle.mdindex e13b18a00b..47e20eb856 100644--- a/packages/docs/docs/shapes/make-circle.md+++ b/packages/docs/docs/shapes/make-circle.md@@ -3,31 +3,28 @@ title: makeCircle()crumb: "@remotion/shapes"----_Part of the [` @remotion/shapes`](/docs/shapes) package._+_Part of the [`@remotion/shapes`](/docs/shapes) package._-Generates Circle SVG path+Generates a circle SVG path.## Arguments-### `options`+<ShapeOptions shape="circle"/>-An object with the following arguments:+## Example-- `cx`: `number` - The x axis coordinate of the center of the circle-- `cy`: `number` - The y axis coordinate of the center of the circle-- `radius`: `number` - The radius of the circle. A value lower or equal to zero disables rendering of the circle--Example Circle path generation--```tsx twoslash+```tsx twoslash title="circle.ts"import { makeCircle } from "@remotion/shapes";-const circlePath = makeCircle({ cx: 50, cy: 50, radius: 50 });-console.log(circlePath); // M 50 50 m -50, 0 a 50,50 0 1,0 100,0 50,50 0 1,0 -100,0+const { path, width, height } = makeCircle({ radius: 50 });++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```## See also-import {MakeShapeSeeAlso} from "../../components/shapes/shapes-info"+import {MakeShapeSeeAlso, ShapeOptions} from "../../components/shapes/shapes-info"<MakeShapeSeeAlso shape="circle"/>diff --git a/packages/docs/docs/shapes/make-ellipse.md b/packages/docs/docs/shapes/make-ellipse.mdindex f025c942dd..29716d4de7 100644--- a/packages/docs/docs/shapes/make-ellipse.md+++ b/packages/docs/docs/shapes/make-ellipse.md@@ -3,30 +3,29 @@ title: makeEllipse()crumb: "@remotion/shapes"---+import {MakeShapeSeeAlso, ShapeOptions} from "../../components/shapes/shapes-info"+_Part of the [`@remotion/shapes`](/docs/shapes) package._-Renders an SVG element with an ellipse inside.+Generates an ellipse SVG path.## Arguments-### `options`--An object with the following arguments:+<ShapeOptions shape="ellipse"/>-- `rx`: `number` - The width of the triangle-- `ry`: `number` - The height of the triangle.+## Example-Example Triangle path generation--```tsx twoslash+```tsx twoslash title="ellipse.ts"import { makeEllipse } from "@remotion/shapes";-const ellipse = makeEllipse({+const { path, width, height } = makeEllipse({rx: 100,ry: 50,});-console.log(ellipse); // M 100 0 a 100 100 0 1 0 1 0+console.log(path); // M 100 0 a 100 100 0 1 0 1 0+console.log(width); // 200+console.log(height); // 100```## Credits@@ -35,6 +34,4 @@ Source code stems mostly from [triangle](https://stackblitz.com/edit/react-trian## See also-import {MakeShapeSeeAlso} from "../../components/shapes/shapes-info"-<MakeShapeSeeAlso shape="ellipse"/>diff --git a/packages/docs/docs/shapes/make-rect.md b/packages/docs/docs/shapes/make-rect.mdindex 5eb77e9d03..5ecf44c665 100644--- a/packages/docs/docs/shapes/make-rect.md+++ b/packages/docs/docs/shapes/make-rect.md@@ -3,33 +3,28 @@ title: makeRect()crumb: "@remotion/shapes"----_Part of the [` @remotion/shapes`](/docs/shapes) package._+import {MakeShapeSeeAlso, ShapeOptions} from "../../components/shapes/shapes-info"-Generates an SVG path for a rectangle.+_Part of the [`@remotion/shapes`](/docs/shapes) package._-## Arguments--An object with the following entries:--### `width`--The width of the rectangle+Generates an SVG rectangle.-### `height`+## Arguments-The height of the rectangle+<ShapeOptions shape="rect"/>## Example-```tsx twoslash+```tsx twoslash title="rect.ts"import { makeRect } from "@remotion/shapes";-const rect = makeRect({ width: 100, height: 100 });-console.log(rect); // M 0 0 l 100 0 l 0 100 l -100 0 Z+const { path, width, height } = makeRect({ width: 100, height: 100 });++console.log(path); // M 0 0 l 100 0 l 0 100 l -100 0 Z+console.log(width); // 100+console.log(height); // 100```## See also-import {MakeShapeSeeAlso} from "../../components/shapes/shapes-info"-<MakeShapeSeeAlso shape="rect"/>diff --git a/packages/docs/docs/shapes/make-triangle.md b/packages/docs/docs/shapes/make-triangle.mdindex 12d46efeb5..2430c3cfd7 100644--- a/packages/docs/docs/shapes/make-triangle.md+++ b/packages/docs/docs/shapes/make-triangle.md@@ -3,19 +3,17 @@ title: makeTriangle()crumb: "@remotion/shapes"----_Part of the [` @remotion/shapes`](/docs/shapes) package._+import {MakeShapeSeeAlso, ShapeOptions} from "../../components/shapes/shapes-info"++_Part of the [`@remotion/shapes`](/docs/shapes) package._Generates a triangle SVG path.## Arguments-### `options`--An object with the following arguments:+<ShapeOptions shape="triangle"/>-- `width`: `number` - The width of the triangle-- `height`: `number` - The height of the triangle.-- `direction`: `string` - The identifier what kind of rectangle, possible values are `left`, `right`, `top` and `bottom`+## ExampleExample Triangle path generation@@ -34,7 +32,7 @@ console.log(height); // 100## Credits-Source code stems mostly from [triangle](https://stackblitz.com/edit/react-triangle-svg?file=index.js).+Source code partially taken from [this StackBlitz](https://stackblitz.com/edit/react-triangle-svg?file=index.js).## See also