Skip to content

🎥 Make videos programmatically with React

remove getParts()

Jonny Burger4ea2ee14cab2
diff --git a/packages/docs/components/TableOfContents/paths.tsx b/packages/docs/components/TableOfContents/paths.tsx
index ecfbbf2162..02e0217d9d 100644
--- a/packages/docs/components/TableOfContents/paths.tsx
+++ b/packages/docs/components/TableOfContents/paths.tsx
@@ -79,16 +79,6 @@ export const TableOfContents: React.FC = () => {
<strong>reduceInstructions()</strong>
<div>Reduce the amount of instruction types</div>
</TOCItem>{" "}
- <TOCItem link="/docs/paths/get-parts">
- <strong
- style={{
- textDecoration: "line-through",
- }}
- >
- getParts()
- </strong>
- <div>Split SVG path into its parts</div>
- </TOCItem>
</Grid>
</div>
);
diff --git a/packages/docs/docs/paths/get-parts.md b/packages/docs/docs/paths/get-parts.md
index 5211228985..4cf25e1b5e 100644
--- a/packages/docs/docs/paths/get-parts.md
+++ b/packages/docs/docs/paths/get-parts.md
@@ -7,126 +7,5 @@ crumb: "@remotion/paths"
_Part of the [`@remotion/paths`](/docs/paths) package._
:::warning
-**Deprecated** in favor of [`getSubpaths()`](/docs/paths/get-subpaths).
+**Removed in v4** in favor of [`getSubpaths()`](/docs/paths/get-subpaths).
:::
-
-Takes an SVG path and returns an array of parts of the path.
-
-Example of a path that has two straight lines:
-
-```tsx twoslash
-import { getParts } from "@remotion/paths";
-
-const parts = getParts(`
- M 0 0 L 100 0
- M 0 100 L 200 100
-`);
-```
-
-An array is returned containing two parts.
-
-```tsx twoslash
-import { getParts } from "@remotion/paths";
-
-const parts = getParts(`
- M 0 0 L 100 0
- M 0 100 L 200 100
-`);
-
-// ---cut---
-
-console.log(parts[0].length); // 100
-console.log(parts[1].length); // 200
-```
-
-## Properties of a part
-
-### `length`
-
-Returns the length of the part.
-
-```tsx twoslash
-import { getParts } from "@remotion/paths";
-
-const parts = getParts(`
- M 0 0 L 100 0
- M 0 100 L 200 100
-`);
-
-// ---cut---
-console.log(parts[0].length); // 100
-```
-
-### `start`
-
-Returns the `x` and `y` coordinates of the start point of the part.
-
-```tsx twoslash
-import { getParts } from "@remotion/paths";
-
-const parts = getParts(`
- M 0 0 L 100 0
- M 0 100 L 200 100
-`);
-
-console.log(parts[1].length); // 200
-// ---cut---
-console.log(parts[0].start); // { x: 0, y: 0 }
-```
-
-### `end`
-
-Returns the `x` and `y` coordinates of the end point of the part.
-
-```tsx twoslash
-import { getParts } from "@remotion/paths";
-
-const parts = getParts(`
- M 0 0 L 100 0
- M 0 100 L 200 100
-`);
-
-// ---cut---
-console.log(parts[0].end); // { x: 100, y: 0 }
-```
-
-### `getPointAtLength()`
-
-Returns the `x` and `y` coordinates of a point along the line of a part. The input must be between `0` and `length`.
-
-```tsx twoslash
-import { getParts } from "@remotion/paths";
-
-const parts = getParts(`
- M 0 0 L 100 0
- M 0 100 L 200 100
-`);
-
-// ---cut---
-console.log(parts[0].getPointAtLength(50)); // { x: 50, y: 0 }
-```
-
-### `getTangentAtLength()`
-
-Returns tangents `x` and `y` of a point along the line of a part. The input must be between `0` and the return value of [`getLength()`](/docs/paths/get-length).
-
-```tsx twoslash
-import { getParts } from "@remotion/paths";
-
-const parts = getParts(`
- M 0 0 L 100 0
- M 0 100 L 200 100
-`);
-
-// ---cut---
-console.log(parts[0].getTangentAtLength(50)); // { x: 1, y: 0 }
-```
-
-## Credits
-
-Source code stems mostly from [svg-path-properties](https://www.npmjs.com/package/svg-path-properties).
-
-## See also
-
-- [`@remotion/paths`](/docs/paths)
-- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/paths/src/get-parts.ts)
diff --git a/packages/paths/README.md b/packages/paths/README.md
index e8fffbe6a7..8ae0b8ddba 100644
--- a/packages/paths/README.md
+++ b/packages/paths/README.md
@@ -12,7 +12,6 @@ No dependencies are needed, meaning this package can be used independently of Re
## API
- [`getLength()`](https://remotion.dev/docs/paths/get-length)
-- [`getParts()`](https://remotion.dev/docs/paths/get-parts)
- [`getPointAtLength()`](https://remotion.dev/docs/paths/get-point-at-length)
- [`getTangentAtLength()`](https://remotion.dev/docs/paths/get-tangent-at-length)
- [`reversePath()`](https://remotion.dev/docs/paths/reverse-path)
diff --git a/packages/paths/src/get-parts.ts b/packages/paths/src/get-parts.ts
deleted file mode 100644
index b74d57bd7f..0000000000
--- a/packages/paths/src/get-parts.ts
+++ /dev/null
@@ -1,36 +0,0 @@
-import {construct} from './helpers/construct';
-import type {Part} from './helpers/types';
-
-/**
- * Splits a valid SVG path into it's parts.
- * @param {string} path A valid SVG path
- * @link https://remotion.dev/docs/paths/get-parts
- * @deprecated In favor of getSubpaths()
- */
-export const getParts = (path: string): Part[] => {
- const parts = [];
- const constructed = construct(path);
-
- let i = 0;
- for (const fn of constructed.functions) {
- if (!fn) {
- i++;
- continue;
- }
-
- const properties: Part = {
- start: fn.getPointAtLength(0),
- end: fn.getPointAtLength(
- constructed.partial_lengths[i] - constructed.partial_lengths[i - 1]
- ),
- length:
- constructed.partial_lengths[i] - constructed.partial_lengths[i - 1],
- getPointAtLength: fn.getPointAtLength,
- getTangentAtLength: fn.getTangentAtLength,
- };
- i++;
- parts.push(properties);
- }
-
- return parts;
-};
diff --git a/packages/paths/src/index.ts b/packages/paths/src/index.ts
index 4bdb2d580b..d564d5c3e2 100644
--- a/packages/paths/src/index.ts
+++ b/packages/paths/src/index.ts
@@ -2,7 +2,6 @@ export {evolvePath} from './evolve-path';
export {extendViewBox} from './extend-viewbox';
export {getBoundingBox} from './get-bounding-box';
export {getLength} from './get-length';
-export {getParts} from './get-parts';
export {getPointAtLength} from './get-point-at-length';
export {getSubpaths} from './get-subpaths';
export {getTangentAtLength} from './get-tangent-at-length';
diff --git a/packages/paths/src/test/get-parts.test.ts b/packages/paths/src/test/get-parts.test.ts
deleted file mode 100644
index ea92621d7f..0000000000
--- a/packages/paths/src/test/get-parts.test.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import {expect, test} from 'vitest';
-import {getParts} from '../get-parts';
-
-test('Should be able to get parts of a path', () => {
- const parts = getParts(`
- M 0 0 L 100 0
- M 0 100 L 100 100 L 200 200
- `);
- expect(parts[0].length).toEqual(100);
- expect(parts[1].length).toEqual(100);
- expect(parts[0].getPointAtLength(100).x).toEqual(100);
-});