path-rite

rotatePathAround

Rotate a path around a specific point.

rotatePathAround(svgPath: string, angle: number, centerX: number, centerY: number): string

svgPath — SVG path d-attribute string.

angle — Rotation angle in radians.

centerX — X coordinate of the rotation center.

centerY — Y coordinate of the rotation center.

Returns — A new SVG path string rotated around the given point.

// Rotate 45 degrees around the center of a 100x100 shape
const rotated = pathRite.rotatePathAround(
  "M 0 0 L 100 0 L 100 100 L 0 100 Z",
  Math.PI / 4, 50, 50
);