Skip to main content

centerPath()v4.0.486

Part of the @remotion/paths package.

Translates an SVG path so that the center of the bounding box is at a target point.

By default, the path is centered around 0, 0.

center-path.ts
import { centerPath } from "@remotion/paths"; const newPath = centerPath("M 10 10 L 20 20"); // M -5 -5 L 5 5

Arguments​

path​

The original SVG path.

target?​

The point that the center of the bounding box should be translated to. Default: {x: 0, y: 0}.

center-path-target.ts
import { centerPath } from "@remotion/paths"; const newPath = centerPath("M 10 10 L 20 20", { x: 100, y: 50 }); // M 95 45 L 105 55

Return value​

Returns a new string containing the translated path.

This function will throw if the SVG path is invalid.

Compatibility​

BrowsersServersEnvironments
Chrome
Firefox
Safari
Node.js
Bun
Serverless Functions

See also​