🎥 Make videos programmatically with React
bounding box
Jonny Burger0e1fe6522d98
diff --git a/packages/paths/src/get-bounding-box.ts b/packages/paths/src/get-bounding-box.tsindex 97ee758fef..c609605a8e 100644--- a/packages/paths/src/get-bounding-box.ts+++ b/packages/paths/src/get-bounding-box.ts@@ -1,11 +1,11 @@'use strict';+import type {BoundingBox} from './helpers/types';import {normalizePath} from './normalize-path';import {unarc} from './unarc';import {unshort} from './unshort';type minMax = [min: number, max: number];-export type BBox = [minX: number, minY: number, maxX: number, maxY: number];// Precision for consider cubic polynom as quadratic oneconst CBEZIER_MINMAX_EPSILON = 0.00000001;@@ -86,12 +86,7 @@ function minmaxC(A: [number, number, number, number]): minMax {return [min, max];}-/**- * Compute bounding boxes of SVG paths.- * @param {String} d SVG path for which their bounding box will be computed.- * @returns {BBox}- */-export default function svgPathBbox(d: string): BBox {+export const getBoundingBox = (d: string): BoundingBox => {const min = [Infinity, Infinity];const max = [-Infinity, -Infinity];const abs = normalizePath(d);@@ -210,5 +205,5 @@ export default function svgPathBbox(d: string): BBox {}}- return [min[0], min[1], max[0], max[1]];-}+ return {x1: min[0], y1: min[1], x2: max[0], y2: max[1]};+};diff --git a/packages/paths/src/helpers/types.ts b/packages/paths/src/helpers/types.tsindex 0cdd9e9462..5107e7f2fc 100644--- a/packages/paths/src/helpers/types.ts+++ b/packages/paths/src/helpers/types.ts@@ -35,3 +35,5 @@ export type pathOrders =| 't'| 'v'| 'z';++export type BoundingBox = {x1: number; y1: number; x2: number; y2: number};diff --git a/packages/paths/src/index.ts b/packages/paths/src/index.tsindex 0806f47db4..87acd99254 100644--- a/packages/paths/src/index.ts+++ b/packages/paths/src/index.ts@@ -1,11 +1,12 @@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';-export {Part} from './helpers/types';+export {BoundingBox, Part} from './helpers/types';export {interpolatePath} from './interpolate-path';export {normalizePath} from './normalize-path';export {reversePath} from './reverse-path';