getBoundingBox()
Part of the @remotion/paths package. Available from v3.3.40
Returns the bounding box of the given path, suitable for calculating the viewBox value that you need to pass to an SVG.
The bounding box is the smallest rectangle which can contain the shape in full.
get-bounding-box.tstsximport {getBoundingBox } from "@remotion/paths";constboundingBox =getBoundingBox ("M 35,50 a 25,25,0,1,1,50,0 a 25,25,0,1,1,-50,0");// { x1: 35, x2: 85, y1: 24.999999999999993, y2: 75 };
get-bounding-box.tstsximport {getBoundingBox } from "@remotion/paths";constboundingBox =getBoundingBox ("M 35,50 a 25,25,0,1,1,50,0 a 25,25,0,1,1,-50,0");// { x1: 35, x2: 85, y1: 24.999999999999993, y2: 75 };
This function will throw if the SVG path is invalid.
Return type
Includes the following properties:
x1: The leftmost x coordinate of the bounding boxx2: The rightmost x coordinate of the bounding boxy1: The topmost y coordinate of the bounding boxy2: The bottommost y coordinate of the bounding boxwidth: The width of the bounding box, returned from v3.3.97height: The height of the bounding box, returned from v3.3.97viewBox: TheviewBoxvalue that you can pass to an SVG, returned from v3.3.97
BoundingBox type
In TypeScript, you can get the shape of the return value by importing the BoundingBox type:
tsimport type {BoundingBox } from "@remotion/paths";
tsimport type {BoundingBox } from "@remotion/paths";