🎥 Make videos programmatically with React
document getBoundingBox()
Jonny Burgere1ca3f13f33a
diff --git a/packages/docs/components/TableOfContents/paths.tsx b/packages/docs/components/TableOfContents/paths.tsxindex b2f4a2f8f3..5121343619 100644--- a/packages/docs/components/TableOfContents/paths.tsx+++ b/packages/docs/components/TableOfContents/paths.tsx@@ -59,6 +59,10 @@ export const TableOfContents: React.FC = () => {<strong>translatePath()</strong><div>Translates the position of an path against X/Y coordinates</div></TOCItem>+ <TOCItem link="/docs/paths/get-bounding-box">+ <strong>getBoundingBox()</strong>+ <div>Get the bounding box of a SVG path</div>+ </TOCItem></Grid></div>);diff --git a/packages/docs/docs/paths/get-bounding-box.md b/packages/docs/docs/paths/get-bounding-box.mdnew file mode 100644index 0000000000..1e18e40933--- /dev/null+++ b/packages/docs/docs/paths/get-bounding-box.md@@ -0,0 +1,34 @@+---+title: getBoundingBox()+crumb: "@remotion/paths"+---++_Part of the [`@remotion/paths`](/docs/paths) package. Available from v3.3.40_++Returns the bounding box of the given path, suitable for calculating the `viewBox` value that you need to pass to an SVG.++The bounding box is the smallest rectangle which can contain the shape in full.++```tsx twoslash title="get-bounding-box.ts"+import { getBoundingBox } from "@remotion/paths";++const boundingBox = getBoundingBox(+ "M 35,50 a 25,25,0,1,1,50,0 a 25,25,0,1,1,-50,0"+);+// {x1: 35, x2: 85, y1: 24.999999999999993, y2: 75};+```++This function will throw if the SVG path is invalid.++## `BoundingBox` type++In TypeScript, you can get the shape of the return value by importing the `BoundingBox` type:++```ts twoslash+import type { BoundingBox } from "@remotion/paths";+```++## See also++- [`@remotion/paths`](/docs/paths)+- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/paths/src/get-bounding-box.ts)diff --git a/packages/docs/sidebars.js b/packages/docs/sidebars.jsindex dacdcad587..576a3f6fef 100644--- a/packages/docs/sidebars.js+++ b/packages/docs/sidebars.js@@ -263,6 +263,7 @@ module.exports = {"paths/extend-viewbox","paths/get-subpaths","paths/translate-path",+ "paths/get-bounding-box",],},{