Skip to content

🎥 Make videos programmatically with React

document serializeInstructions()

Jonny Burger625d32209648
diff --git a/packages/docs/components/TableOfContents/paths.tsx b/packages/docs/components/TableOfContents/paths.tsx
index f17fa775a8..dab9955a64 100644
--- a/packages/docs/components/TableOfContents/paths.tsx
+++ b/packages/docs/components/TableOfContents/paths.tsx
@@ -10,7 +10,6 @@ export const TableOfContents: React.FC = () => {
<strong>getLength()</strong>
<div>Obtain length of an SVG path</div>
</TOCItem>
-
<TOCItem link="/docs/paths/get-tangent-at-length">
<strong>getPointAtLength()</strong>
<div>Get coordinates at a certain point of an SVG path</div>
@@ -64,6 +63,10 @@ export const TableOfContents: React.FC = () => {
<strong>parsePath()</strong>
<div>Parse a string into an array of instructions</div>
</TOCItem>
+ <TOCItem link="/docs/paths/serialize-instructions">
+ <strong>serializeInstructions()</strong>
+ <div>Turn an array of instructions into a SVG path</div>
+ </TOCItem>{" "}
<TOCItem link="/docs/paths/get-parts">
<strong
style={{
diff --git a/packages/docs/docs/paths/serialize-instructions.md b/packages/docs/docs/paths/serialize-instructions.md
new file mode 100644
index 0000000000..ef7588fca8
--- /dev/null
+++ b/packages/docs/docs/paths/serialize-instructions.md
@@ -0,0 +1,33 @@
+---
+title: serializeInstructions()
+crumb: "@remotion/paths"
+---
+
+_Part of the [`@remotion/paths`](/docs/paths) package. Available from v3.3.40_
+
+Takes an array of [`Instruction`](/docs/paths/parse-path)'s and serializes it into an SVG path string.
+
+```tsx twoslash title="serialize-instructions.ts"
+import { serializeInstructions } from "@remotion/paths";
+
+const newPath = serializeInstructions([
+ {
+ type: "M",
+ x: 10,
+ y: 10,
+ },
+ {
+ type: "L",
+ x: 20,
+ y: 20,
+ },
+]); // M 10 10 L 20 20
+```
+
+This function may throw if the instructions don't match the [`Instruction`](/docs/paths/parse-path) type, but it does not explicitly check for invalid input.
+
+## See also
+
+- [`@remotion/paths`](/docs/paths)
+- [`parsePath()`](/docs/paths/parse-path)
+- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/paths/src/serialize-instructions.ts)
diff --git a/packages/docs/sidebars.js b/packages/docs/sidebars.js
index 83827bf63c..693394e67e 100644
--- a/packages/docs/sidebars.js
+++ b/packages/docs/sidebars.js
@@ -266,6 +266,7 @@ module.exports = {
"paths/extend-viewbox",
"paths/get-parts",
"paths/parse-path",
+ "paths/serialize-instructions",
],
},
{