🎥 Make videos programmatically with React
document parsePath()
Jonny Burger6400fc97222f
diff --git a/packages/docs/components/TableOfContents/paths.tsx b/packages/docs/components/TableOfContents/paths.tsxindex 649856b90f..f17fa775a8 100644--- a/packages/docs/components/TableOfContents/paths.tsx+++ b/packages/docs/components/TableOfContents/paths.tsx@@ -60,6 +60,10 @@ export const TableOfContents: React.FC = () => {<strong>getSubpaths()</strong><div>Split SVG path into its parts</div></TOCItem>+ <TOCItem link="/docs/paths/parse-path">+ <strong>parsePath()</strong>+ <div>Parse a string into an array of instructions</div>+ </TOCItem><TOCItem link="/docs/paths/get-parts"><strongstyle={{diff --git a/packages/docs/docs/paths/parse-path.md b/packages/docs/docs/paths/parse-path.mdnew file mode 100644index 0000000000..d700382495--- /dev/null+++ b/packages/docs/docs/paths/parse-path.md@@ -0,0 +1,161 @@+---+title: parsePath()+crumb: "@remotion/paths"+---++_Part of the [`@remotion/paths`](/docs/paths) package. Available from v3.3.40_++Parses an SVG string path into an array of `Instruction`'s.++```tsx twoslash title="reset-path.ts"+import { parsePath } from "@remotion/paths";++const newPath = parsePath("M 10 10 L 20 20");++/*+ [+ { type: "M", x: 10, y: 10 },+ { type: "L", x: 20, y: 20 },+ ]+*/+```++This function will throw if the SVG path is invalid.++## Return type type++An array of `Instruction`'s. The `Instruction` type can also be imported from `@remotion/paths`:++```ts twoslash+import type { Instruction } from "@remotion/paths";+```++The type has the following shape:++```ts twoslash+export type Instruction =+ | {+ type: "M";+ x: number;+ y: number;+ }+ | {+ type: "L";+ x: number;+ y: number;+ }+ | {+ type: "H";+ x: number;+ }+ | {+ type: "V";+ y: number;+ }+ | {+ type: "C";+ cp1x: number;+ cp1y: number;+ cp2x: number;+ cp2y: number;+ x: number;+ y: number;+ }+ | {+ type: "S";+ cpx: number;+ cpy: number;+ x: number;+ y: number;+ }+ | {+ type: "Q";+ cpx: number;+ cpy: number;+ x: number;+ y: number;+ }+ | {+ type: "T";+ x: number;+ y: number;+ }+ | {+ type: "A";+ rx: number;+ ry: number;+ xAxisRotation: number;+ largeArcFlag: boolean;+ sweepFlag: boolean;+ x: number;+ y: number;+ }+ | {+ type: "m";+ dx: number;+ dy: number;+ }+ | {+ type: "l";+ dx: number;+ dy: number;+ }+ | {+ type: "h";+ dx: number;+ }+ | {+ type: "v";+ dy: number;+ }+ | {+ type: "c";+ cp1dx: number;+ cp1dy: number;+ cp2dx: number;+ cp2dy: number;+ dx: number;+ dy: number;+ }+ | {+ type: "s";+ cpdx: number;+ cpdy: number;+ dx: number;+ dy: number;+ }+ | {+ type: "q";+ cpdx: number;+ cpdy: number;+ dx: number;+ dy: number;+ }+ | {+ type: "t";+ dx: number;+ dy: number;+ }+ | {+ type: "a";+ rx: number;+ ry: number;+ xAxisRotation: number;+ largeArcFlag: boolean;+ sweepFlag: boolean;+ dx: number;+ dy: number;+ }+ | {+ type: "Z";+ }+ | {+ type: "z";+ };+```++## See also++- [`serializeInstructions()`](/docs/paths/serialize-instructions)+- [`@remotion/paths`](/docs/paths)+- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/paths/src/parse-path.ts)diff --git a/packages/docs/sidebars.js b/packages/docs/sidebars.jsindex 488abe971b..83827bf63c 100644--- a/packages/docs/sidebars.js+++ b/packages/docs/sidebars.js@@ -265,6 +265,7 @@ module.exports = {"paths/get-bounding-box","paths/extend-viewbox","paths/get-parts",+ "paths/parse-path",],},{