@remotion/paths 3.3.54 → 3.3.56
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/evolve-path.d.ts +2 -2
- package/dist/evolve-path.js +2 -2
- package/dist/extend-viewbox.d.ts +2 -2
- package/dist/extend-viewbox.js +2 -2
- package/dist/get-bounding-box.d.ts +5 -0
- package/dist/get-bounding-box.js +5 -0
- package/dist/get-length.d.ts +2 -2
- package/dist/get-length.js +2 -2
- package/dist/get-parts.d.ts +2 -2
- package/dist/get-parts.js +2 -2
- package/dist/get-point-at-length.d.ts +3 -3
- package/dist/get-point-at-length.js +3 -3
- package/dist/get-subpaths.d.ts +2 -2
- package/dist/get-subpaths.js +2 -2
- package/dist/get-tangent-at-length.d.ts +2 -2
- package/dist/get-tangent-at-length.js +2 -2
- package/dist/interpolate-path.d.ts +2 -2
- package/dist/interpolate-path.js +2 -2
- package/dist/normalize-path.d.ts +2 -2
- package/dist/normalize-path.js +2 -2
- package/dist/parse-path.d.ts +6 -0
- package/dist/parse-path.js +6 -0
- package/dist/reduce-instructions.d.ts +5 -0
- package/dist/reduce-instructions.js +5 -0
- package/dist/reset-path.d.ts +5 -0
- package/dist/reset-path.js +5 -0
- package/dist/reverse-path.d.ts +2 -2
- package/dist/reverse-path.js +2 -2
- package/dist/scale-path.d.ts +9 -0
- package/dist/scale-path.js +9 -0
- package/dist/serialize-instructions.js +6 -0
- package/dist/translate-path.d.ts +8 -0
- package/dist/translate-path.js +8 -0
- package/dist/warp-path/index.d.ts +5 -0
- package/dist/warp-path/index.js +5 -0
- package/package.json +2 -2
- package/dist/helpers/parse.d.ts +0 -2
- package/dist/helpers/parse.js +0 -51
package/dist/evolve-path.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Animates an SVG from being invisible to it's full length.
|
|
2
|
+
* @description Animates an SVG from being invisible to it's full length.
|
|
3
3
|
* @param {string} path A valid SVG path
|
|
4
4
|
* @param {number} progress The first valid SVG path
|
|
5
|
-
* @
|
|
5
|
+
* @see [Documentation](https://remotion.dev/docs/paths/evolve-path)
|
|
6
6
|
*/
|
|
7
7
|
export declare const evolvePath: (progress: number, path: string) => {
|
|
8
8
|
strokeDasharray: string;
|
package/dist/evolve-path.js
CHANGED
|
@@ -3,10 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.evolvePath = void 0;
|
|
4
4
|
const get_length_1 = require("./get-length");
|
|
5
5
|
/**
|
|
6
|
-
* Animates an SVG from being invisible to it's full length.
|
|
6
|
+
* @description Animates an SVG from being invisible to it's full length.
|
|
7
7
|
* @param {string} path A valid SVG path
|
|
8
8
|
* @param {number} progress The first valid SVG path
|
|
9
|
-
* @
|
|
9
|
+
* @see [Documentation](https://remotion.dev/docs/paths/evolve-path)
|
|
10
10
|
*/
|
|
11
11
|
const evolvePath = (progress, path) => {
|
|
12
12
|
const length = (0, get_length_1.getLength)(path);
|
package/dist/extend-viewbox.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Extends a viewbox in all directions by a scale factor.
|
|
2
|
+
* @description Extends a viewbox in all directions by a scale factor.
|
|
3
3
|
* @param {string} currentViewBox A valid SVG viewBox
|
|
4
|
-
* @
|
|
4
|
+
* @see [Documentation](https://remotion.dev/docs/paths/extend-viewbox)
|
|
5
5
|
*/
|
|
6
6
|
export declare const extendViewBox: (currentViewBox: string, scale: number) => string;
|
package/dist/extend-viewbox.js
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.extendViewBox = void 0;
|
|
4
4
|
/**
|
|
5
|
-
* Extends a viewbox in all directions by a scale factor.
|
|
5
|
+
* @description Extends a viewbox in all directions by a scale factor.
|
|
6
6
|
* @param {string} currentViewBox A valid SVG viewBox
|
|
7
|
-
* @
|
|
7
|
+
* @see [Documentation](https://remotion.dev/docs/paths/extend-viewbox)
|
|
8
8
|
*/
|
|
9
9
|
const extendViewBox = (currentViewBox, scale) => {
|
|
10
10
|
const relativeScale = scale - 1;
|
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
import type { BoundingBox, ReducedInstruction } from './helpers/types';
|
|
2
|
+
/**
|
|
3
|
+
* @description Returns the bounding box of the given path, suitable for calculating the viewBox value that you need to pass to an SVG.
|
|
4
|
+
* @param {string} d
|
|
5
|
+
* @see [Documentation](https://www.remotion.dev/docs/paths/get-bounding-box)
|
|
6
|
+
*/
|
|
2
7
|
export declare const getBoundingBox: (d: string) => BoundingBox;
|
|
3
8
|
export declare const getBoundingBoxFromInstructions: (instructions: ReducedInstruction[]) => BoundingBox;
|
package/dist/get-bounding-box.js
CHANGED
|
@@ -67,6 +67,11 @@ function minmaxC(A) {
|
|
|
67
67
|
}
|
|
68
68
|
return [min, max];
|
|
69
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* @description Returns the bounding box of the given path, suitable for calculating the viewBox value that you need to pass to an SVG.
|
|
72
|
+
* @param {string} d
|
|
73
|
+
* @see [Documentation](https://www.remotion.dev/docs/paths/get-bounding-box)
|
|
74
|
+
*/
|
|
70
75
|
const getBoundingBox = (d) => {
|
|
71
76
|
const parsed = (0, parse_path_1.parsePath)(d);
|
|
72
77
|
const unarced = (0, remove_a_s_t_curves_1.removeATSHVInstructions)((0, normalize_path_1.normalizeInstructions)(parsed));
|
package/dist/get-length.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Gets the length of an SVG path.
|
|
2
|
+
* @description Gets the length of an SVG path.
|
|
3
3
|
* @param {string} path A valid SVG path
|
|
4
|
-
* @
|
|
4
|
+
* @see [Documentation](https://remotion.dev/docs/paths/get-length)
|
|
5
5
|
*/
|
|
6
6
|
export declare const getLength: (path: string) => number;
|
package/dist/get-length.js
CHANGED
|
@@ -4,9 +4,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
exports.getLength = void 0;
|
|
5
5
|
const construct_1 = require("./helpers/construct");
|
|
6
6
|
/**
|
|
7
|
-
* Gets the length of an SVG path.
|
|
7
|
+
* @description Gets the length of an SVG path.
|
|
8
8
|
* @param {string} path A valid SVG path
|
|
9
|
-
* @
|
|
9
|
+
* @see [Documentation](https://remotion.dev/docs/paths/get-length)
|
|
10
10
|
*/
|
|
11
11
|
const getLength = (path) => {
|
|
12
12
|
const constructucted = (0, construct_1.construct)(path);
|
package/dist/get-parts.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Part } from './helpers/types';
|
|
2
2
|
/**
|
|
3
|
-
* Splits a valid SVG path into it's parts.
|
|
3
|
+
* @description Splits a valid SVG path into it's parts.
|
|
4
4
|
* @param {string} path A valid SVG path
|
|
5
|
-
* @
|
|
5
|
+
* @see [Documentation](https://remotion.dev/docs/paths/get-parts)
|
|
6
6
|
* @deprecated In favor of getSubpaths()
|
|
7
7
|
*/
|
|
8
8
|
export declare const getParts: (path: string) => Part[];
|
package/dist/get-parts.js
CHANGED
|
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getParts = void 0;
|
|
4
4
|
const construct_1 = require("./helpers/construct");
|
|
5
5
|
/**
|
|
6
|
-
* Splits a valid SVG path into it's parts.
|
|
6
|
+
* @description Splits a valid SVG path into it's parts.
|
|
7
7
|
* @param {string} path A valid SVG path
|
|
8
|
-
* @
|
|
8
|
+
* @see [Documentation](https://remotion.dev/docs/paths/get-parts)
|
|
9
9
|
* @deprecated In favor of getSubpaths()
|
|
10
10
|
*/
|
|
11
11
|
const getParts = (path) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Gets the coordinates of a point which is on an SVG path.
|
|
2
|
+
* @description Gets the coordinates of a point which is on an SVG path.
|
|
3
3
|
* @param {string} path A valid SVG path
|
|
4
4
|
* @param {number} length The length at which the point should be sampled
|
|
5
|
-
* @
|
|
6
|
-
|
|
5
|
+
* @see [Documentation](https://remotion.dev/docs/paths/get-point-at-length)
|
|
6
|
+
*/
|
|
7
7
|
export declare const getPointAtLength: (path: string, length: number) => import("./helpers/types").Point;
|
|
@@ -4,11 +4,11 @@ exports.getPointAtLength = void 0;
|
|
|
4
4
|
const construct_1 = require("./helpers/construct");
|
|
5
5
|
const get_part_at_length_1 = require("./helpers/get-part-at-length");
|
|
6
6
|
/**
|
|
7
|
-
* Gets the coordinates of a point which is on an SVG path.
|
|
7
|
+
* @description Gets the coordinates of a point which is on an SVG path.
|
|
8
8
|
* @param {string} path A valid SVG path
|
|
9
9
|
* @param {number} length The length at which the point should be sampled
|
|
10
|
-
* @
|
|
11
|
-
|
|
10
|
+
* @see [Documentation](https://remotion.dev/docs/paths/get-point-at-length)
|
|
11
|
+
*/
|
|
12
12
|
const getPointAtLength = (path, length) => {
|
|
13
13
|
const constructed = (0, construct_1.construct)(path);
|
|
14
14
|
const fractionPart = (0, get_part_at_length_1.getPartAtLength)(path, length);
|
package/dist/get-subpaths.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Splits a valid SVG path into it's parts.
|
|
2
|
+
* @description Splits a valid SVG path into it's parts.
|
|
3
3
|
* @param {string} path A valid SVG path
|
|
4
|
-
* @
|
|
4
|
+
* @see [Documentation](https://remotion.dev/docs/paths/get-subpaths)
|
|
5
5
|
*/
|
|
6
6
|
export declare const getSubpaths: (path: string) => string[];
|
package/dist/get-subpaths.js
CHANGED
|
@@ -4,9 +4,9 @@ exports.getSubpaths = void 0;
|
|
|
4
4
|
const construct_1 = require("./helpers/construct");
|
|
5
5
|
const serialize_instructions_1 = require("./serialize-instructions");
|
|
6
6
|
/**
|
|
7
|
-
* Splits a valid SVG path into it's parts.
|
|
7
|
+
* @description Splits a valid SVG path into it's parts.
|
|
8
8
|
* @param {string} path A valid SVG path
|
|
9
|
-
* @
|
|
9
|
+
* @see [Documentation](https://remotion.dev/docs/paths/get-subpaths)
|
|
10
10
|
*/
|
|
11
11
|
const getSubpaths = (path) => {
|
|
12
12
|
const { segments } = (0, construct_1.construct)(path);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Gets tangent values x and y of a point which is on an SVG path
|
|
2
|
+
* @description Gets tangent values x and y of a point which is on an SVG path
|
|
3
3
|
* @param {string} path A valid SVG path
|
|
4
4
|
* @param {number} length The length at which the tangent should be sampled
|
|
5
|
-
* @
|
|
5
|
+
* @see [Documentation](https://remotion.dev/docs/paths/get-tangent-at-length)
|
|
6
6
|
*/
|
|
7
7
|
export declare const getTangentAtLength: (path: string, length: number) => import("./helpers/types").Point;
|
|
@@ -4,10 +4,10 @@ exports.getTangentAtLength = void 0;
|
|
|
4
4
|
const construct_1 = require("./helpers/construct");
|
|
5
5
|
const get_part_at_length_1 = require("./helpers/get-part-at-length");
|
|
6
6
|
/**
|
|
7
|
-
* Gets tangent values x and y of a point which is on an SVG path
|
|
7
|
+
* @description Gets tangent values x and y of a point which is on an SVG path
|
|
8
8
|
* @param {string} path A valid SVG path
|
|
9
9
|
* @param {number} length The length at which the tangent should be sampled
|
|
10
|
-
* @
|
|
10
|
+
* @see [Documentation](https://remotion.dev/docs/paths/get-tangent-at-length)
|
|
11
11
|
*/
|
|
12
12
|
const getTangentAtLength = (path, length) => {
|
|
13
13
|
const constructed = (0, construct_1.construct)(path);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Interpolates between two SVG paths.
|
|
2
|
+
* @description Interpolates between two SVG paths.
|
|
3
3
|
* @param {number} value A number - 0 means first path, 1 means second path, any other values will be interpolated
|
|
4
4
|
* @param {string} firstPath The first valid SVG path
|
|
5
5
|
* @param {string} secondPath The second valid SVG path
|
|
6
|
-
* @
|
|
6
|
+
* @see [Documentation](https://remotion.dev/docs/paths/interpolate-path)
|
|
7
7
|
*/
|
|
8
8
|
export declare const interpolatePath: (value: number, firstPath: string, secondPath: string) => string;
|
package/dist/interpolate-path.js
CHANGED
|
@@ -332,11 +332,11 @@ function interpolatePathCommands(aCommandsInput, bCommandsInput) {
|
|
|
332
332
|
};
|
|
333
333
|
}
|
|
334
334
|
/**
|
|
335
|
-
* Interpolates between two SVG paths.
|
|
335
|
+
* @description Interpolates between two SVG paths.
|
|
336
336
|
* @param {number} value A number - 0 means first path, 1 means second path, any other values will be interpolated
|
|
337
337
|
* @param {string} firstPath The first valid SVG path
|
|
338
338
|
* @param {string} secondPath The second valid SVG path
|
|
339
|
-
* @
|
|
339
|
+
* @see [Documentation](https://remotion.dev/docs/paths/interpolate-path)
|
|
340
340
|
*/
|
|
341
341
|
const interpolatePath = (value, firstPath, secondPath) => {
|
|
342
342
|
// at 1 return the final value without the extensions used during interpolation
|
package/dist/normalize-path.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { AbsoluteInstruction, Instruction } from './helpers/types';
|
|
2
2
|
/**
|
|
3
|
-
* Removes all relative coordinates from an SVG path and converts them into absolute coordinates.
|
|
3
|
+
* @description Removes all relative coordinates from an SVG path and converts them into absolute coordinates.
|
|
4
4
|
* @param {string} path A valid SVG path
|
|
5
|
-
* @
|
|
5
|
+
* @see [Documentation](https://remotion.dev/docs/paths/normalize-path)
|
|
6
6
|
*/
|
|
7
7
|
export declare const normalizePath: (path: string) => string;
|
|
8
8
|
export declare const normalizeInstructions: (instructions: Instruction[]) => AbsoluteInstruction[];
|
package/dist/normalize-path.js
CHANGED
|
@@ -4,9 +4,9 @@ exports.normalizeInstructions = exports.normalizePath = void 0;
|
|
|
4
4
|
const parse_path_1 = require("./parse-path");
|
|
5
5
|
const serialize_instructions_1 = require("./serialize-instructions");
|
|
6
6
|
/**
|
|
7
|
-
* Removes all relative coordinates from an SVG path and converts them into absolute coordinates.
|
|
7
|
+
* @description Removes all relative coordinates from an SVG path and converts them into absolute coordinates.
|
|
8
8
|
* @param {string} path A valid SVG path
|
|
9
|
-
* @
|
|
9
|
+
* @see [Documentation](https://remotion.dev/docs/paths/normalize-path)
|
|
10
10
|
*/
|
|
11
11
|
const normalizePath = (path) => {
|
|
12
12
|
const instructions = (0, parse_path_1.parsePath)(path);
|
package/dist/parse-path.d.ts
CHANGED
|
@@ -1,2 +1,8 @@
|
|
|
1
1
|
import type { Instruction } from './helpers/types';
|
|
2
|
+
/**
|
|
3
|
+
* @description Parses an SVG string path into an array of Instruction's.
|
|
4
|
+
* @param {string} path
|
|
5
|
+
* @returns an array of objects containing the Instructions
|
|
6
|
+
* @see [Documentation](https://www.remotion.dev/docs/paths/parse-path)
|
|
7
|
+
*/
|
|
2
8
|
export declare const parsePath: (path: string) => Instruction[];
|
package/dist/parse-path.js
CHANGED
|
@@ -42,6 +42,12 @@ const makeInstructions = (arr, instruction, cb) => {
|
|
|
42
42
|
};
|
|
43
43
|
const segmentRegExp = /([astvzqmhlc])([^astvzqmhlc]*)/gi;
|
|
44
44
|
const numberRegExp = /-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/gi;
|
|
45
|
+
/**
|
|
46
|
+
* @description Parses an SVG string path into an array of Instruction's.
|
|
47
|
+
* @param {string} path
|
|
48
|
+
* @returns an array of objects containing the Instructions
|
|
49
|
+
* @see [Documentation](https://www.remotion.dev/docs/paths/parse-path)
|
|
50
|
+
*/
|
|
45
51
|
const parsePath = (path) => {
|
|
46
52
|
if (!path) {
|
|
47
53
|
throw new Error('No path provided');
|
|
@@ -1,2 +1,7 @@
|
|
|
1
1
|
import type { Instruction, ReducedInstruction } from './helpers/types';
|
|
2
|
+
/**
|
|
3
|
+
* @description Takes an array of Instruction's and reduces the amount of instruction types them so the path only consists of M, L, C, Q and Z instructions.
|
|
4
|
+
* @param {Array} instruction
|
|
5
|
+
* @see [Documentation](https://www.remotion.dev/docs/paths/reduce-instructions)
|
|
6
|
+
*/
|
|
2
7
|
export declare const reduceInstructions: (instruction: Instruction[]) => ReducedInstruction[];
|
|
@@ -3,6 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.reduceInstructions = void 0;
|
|
4
4
|
const remove_a_s_t_curves_1 = require("./helpers/remove-a-s-t-curves");
|
|
5
5
|
const normalize_path_1 = require("./normalize-path");
|
|
6
|
+
/**
|
|
7
|
+
* @description Takes an array of Instruction's and reduces the amount of instruction types them so the path only consists of M, L, C, Q and Z instructions.
|
|
8
|
+
* @param {Array} instruction
|
|
9
|
+
* @see [Documentation](https://www.remotion.dev/docs/paths/reduce-instructions)
|
|
10
|
+
*/
|
|
6
11
|
const reduceInstructions = (instruction) => {
|
|
7
12
|
const simplified = (0, normalize_path_1.normalizeInstructions)(instruction);
|
|
8
13
|
return (0, remove_a_s_t_curves_1.removeATSHVInstructions)(simplified);
|
package/dist/reset-path.d.ts
CHANGED
|
@@ -1 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description Translates an SVG path so that the top-left corner of the bounding box is at 0, 0.
|
|
3
|
+
* @param {string} d a valid SVG path
|
|
4
|
+
* @see [Documentation](https://www.remotion.dev/docs/paths/reset-path)
|
|
5
|
+
*/
|
|
1
6
|
export declare const resetPath: (d: string) => string;
|
package/dist/reset-path.js
CHANGED
|
@@ -3,6 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.resetPath = void 0;
|
|
4
4
|
const get_bounding_box_1 = require("./get-bounding-box");
|
|
5
5
|
const translate_path_1 = require("./translate-path");
|
|
6
|
+
/**
|
|
7
|
+
* @description Translates an SVG path so that the top-left corner of the bounding box is at 0, 0.
|
|
8
|
+
* @param {string} d a valid SVG path
|
|
9
|
+
* @see [Documentation](https://www.remotion.dev/docs/paths/reset-path)
|
|
10
|
+
*/
|
|
6
11
|
const resetPath = (d) => {
|
|
7
12
|
const box = (0, get_bounding_box_1.getBoundingBox)(d);
|
|
8
13
|
return (0, translate_path_1.translatePath)(d, -box.x1, -box.y1);
|
package/dist/reverse-path.d.ts
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* not recognise the public domain, where this code is MIT licensed.
|
|
6
6
|
*/
|
|
7
7
|
/**
|
|
8
|
-
* Reverses a path so the end and start are switched.
|
|
8
|
+
* @description Reverses a path so the end and start are switched.
|
|
9
9
|
* @param {string} path A valid SVG path
|
|
10
|
-
* @
|
|
10
|
+
* @see [Documentation](https://remotion.dev/docs/paths/reverse-path)
|
|
11
11
|
*/
|
|
12
12
|
export declare const reversePath: (path: string) => string;
|
package/dist/reverse-path.js
CHANGED
|
@@ -129,9 +129,9 @@ function reverseNormalizedPath(normalized) {
|
|
|
129
129
|
return revstring;
|
|
130
130
|
}
|
|
131
131
|
/**
|
|
132
|
-
* Reverses a path so the end and start are switched.
|
|
132
|
+
* @description Reverses a path so the end and start are switched.
|
|
133
133
|
* @param {string} path A valid SVG path
|
|
134
|
-
* @
|
|
134
|
+
* @see [Documentation](https://remotion.dev/docs/paths/reverse-path)
|
|
135
135
|
*/
|
|
136
136
|
const reversePath = (path) => {
|
|
137
137
|
const normalizedPath = (0, normalize_path_1.normalizePath)(path);
|
package/dist/scale-path.d.ts
CHANGED
|
@@ -1 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description Allows you to grow or shrink the size of a path.
|
|
3
|
+
* @param {string} path A valid SVG path
|
|
4
|
+
* @param {string} d
|
|
5
|
+
* @param {Number} scaleX
|
|
6
|
+
* @param {Number} scaleY
|
|
7
|
+
* @returns a new path with respect to the scale values provided
|
|
8
|
+
* @see [Documentation](https://www.remotion.dev/docs/paths/scale-path)
|
|
9
|
+
*/
|
|
1
10
|
export declare const scalePath: (d: string, scaleX: number, scaleY: number) => string;
|
package/dist/scale-path.js
CHANGED
|
@@ -6,6 +6,15 @@ const parse_path_1 = require("./parse-path");
|
|
|
6
6
|
const reduce_instructions_1 = require("./reduce-instructions");
|
|
7
7
|
const serialize_instructions_1 = require("./serialize-instructions");
|
|
8
8
|
const translate_path_1 = require("./translate-path");
|
|
9
|
+
/**
|
|
10
|
+
* @description Allows you to grow or shrink the size of a path.
|
|
11
|
+
* @param {string} path A valid SVG path
|
|
12
|
+
* @param {string} d
|
|
13
|
+
* @param {Number} scaleX
|
|
14
|
+
* @param {Number} scaleY
|
|
15
|
+
* @returns a new path with respect to the scale values provided
|
|
16
|
+
* @see [Documentation](https://www.remotion.dev/docs/paths/scale-path)
|
|
17
|
+
*/
|
|
9
18
|
const scalePath = (d, scaleX, scaleY) => {
|
|
10
19
|
const reduced = (0, reduce_instructions_1.reduceInstructions)((0, parse_path_1.parsePath)(d));
|
|
11
20
|
const bounded = (0, get_bounding_box_1.getBoundingBoxFromInstructions)(reduced);
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.serializeInstructions = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* @description Takes an array of Instruction's and serializes it into an SVG path string.
|
|
6
|
+
* @param {Array} instruction
|
|
7
|
+
* @returns a serialized SVG path string
|
|
8
|
+
* @see [Documentation](https://www.remotion.dev/docs/paths/serialize-instructions)
|
|
9
|
+
*/
|
|
4
10
|
const serializeInstruction = (instruction) => {
|
|
5
11
|
if (instruction.type === 'A') {
|
|
6
12
|
return `A ${instruction.rx} ${instruction.ry} ${instruction.xAxisRotation} ${Number(instruction.largeArcFlag)} ${Number(instruction.sweepFlag)} ${instruction.x} ${instruction.y}`;
|
package/dist/translate-path.d.ts
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
1
|
import type { Instruction } from './helpers/types';
|
|
2
2
|
export declare const translateSegments: (segments: Instruction[], x: number, y: number) => Instruction[];
|
|
3
|
+
/**
|
|
4
|
+
* @description Translates the path by the given x and y coordinates.
|
|
5
|
+
* @param {string} path the originalSVG path
|
|
6
|
+
* @param {Number} x the amount of horizontal translation
|
|
7
|
+
* @param {Number} y the amount of vertical translation
|
|
8
|
+
* @returns a new string containing a path, if it is valid
|
|
9
|
+
* @see [Documentation](https://www.remotion.dev/docs/paths/translate-path)
|
|
10
|
+
*/
|
|
3
11
|
export declare const translatePath: (path: string, x: number, y: number) => string;
|
package/dist/translate-path.js
CHANGED
|
@@ -102,6 +102,14 @@ const translateSegments = (segments, x, y) => {
|
|
|
102
102
|
});
|
|
103
103
|
};
|
|
104
104
|
exports.translateSegments = translateSegments;
|
|
105
|
+
/**
|
|
106
|
+
* @description Translates the path by the given x and y coordinates.
|
|
107
|
+
* @param {string} path the originalSVG path
|
|
108
|
+
* @param {Number} x the amount of horizontal translation
|
|
109
|
+
* @param {Number} y the amount of vertical translation
|
|
110
|
+
* @returns a new string containing a path, if it is valid
|
|
111
|
+
* @see [Documentation](https://www.remotion.dev/docs/paths/translate-path)
|
|
112
|
+
*/
|
|
105
113
|
const translatePath = (path, x, y) => {
|
|
106
114
|
return (0, serialize_instructions_1.serializeInstructions)((0, exports.translateSegments)((0, parse_path_1.parsePath)(path), x, y));
|
|
107
115
|
};
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import type { WarpPathFn } from './warp-helpers';
|
|
2
|
+
/**
|
|
3
|
+
* @description This function works by splitting SVG instructions into many smaller SVG instructions and then remapping the coordinates of each instruction.
|
|
4
|
+
* @param {string} path an SVG path string
|
|
5
|
+
* @see [Documentation](https://www.remotion.dev/docs/paths/warp-path)
|
|
6
|
+
*/
|
|
2
7
|
export declare const warpPath: (path: string, transformer: WarpPathFn, options?: {
|
|
3
8
|
interpolationThreshold?: number;
|
|
4
9
|
}) => string;
|
package/dist/warp-path/index.js
CHANGED
|
@@ -11,6 +11,11 @@ const getDefaultInterpolationThreshold = (instructions) => {
|
|
|
11
11
|
const longer = Math.max(boundingBox.y2 - boundingBox.y1, boundingBox.x2 - boundingBox.x1);
|
|
12
12
|
return longer * 0.01;
|
|
13
13
|
};
|
|
14
|
+
/**
|
|
15
|
+
* @description This function works by splitting SVG instructions into many smaller SVG instructions and then remapping the coordinates of each instruction.
|
|
16
|
+
* @param {string} path an SVG path string
|
|
17
|
+
* @see [Documentation](https://www.remotion.dev/docs/paths/warp-path)
|
|
18
|
+
*/
|
|
14
19
|
const warpPath = (path, transformer, options) => {
|
|
15
20
|
var _a;
|
|
16
21
|
const reduced = (0, reduce_instructions_1.reduceInstructions)((0, parse_path_1.parsePath)(path));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remotion/paths",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.56",
|
|
4
4
|
"description": "Utility functions for SVG paths",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -35,5 +35,5 @@
|
|
|
35
35
|
"publishConfig": {
|
|
36
36
|
"access": "public"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "40e96323b08717213c20fffcce8a985f0310f6e5"
|
|
39
39
|
}
|
package/dist/helpers/parse.d.ts
DELETED
package/dist/helpers/parse.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Copied from: https://github.com/rveciana/svg-path-properties
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.parsePath = void 0;
|
|
5
|
-
const length = {
|
|
6
|
-
a: 7,
|
|
7
|
-
c: 6,
|
|
8
|
-
h: 1,
|
|
9
|
-
l: 2,
|
|
10
|
-
m: 2,
|
|
11
|
-
q: 4,
|
|
12
|
-
s: 4,
|
|
13
|
-
t: 2,
|
|
14
|
-
v: 1,
|
|
15
|
-
z: 0,
|
|
16
|
-
};
|
|
17
|
-
const segmentRegExp = /([astvzqmhlc])([^astvzqmhlc]*)/gi;
|
|
18
|
-
const numberRegExp = /-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/gi;
|
|
19
|
-
const parsePath = (path) => {
|
|
20
|
-
const segments = (path && path.length > 0 ? path : 'M0,0').match(segmentRegExp);
|
|
21
|
-
if (!segments) {
|
|
22
|
-
throw new Error(`No path elements found in string ${path}`);
|
|
23
|
-
}
|
|
24
|
-
return segments.reduce((segmentsArray, segmentString) => {
|
|
25
|
-
let command = segmentString.charAt(0);
|
|
26
|
-
let type = command.toLowerCase();
|
|
27
|
-
const args = parseValues(segmentString.substr(1));
|
|
28
|
-
// overloaded moveTo
|
|
29
|
-
if (type === 'm' && args.length > 2) {
|
|
30
|
-
segmentsArray.push([command, ...args.splice(0, 2)]);
|
|
31
|
-
type = 'l';
|
|
32
|
-
command = command === 'm' ? 'l' : 'L';
|
|
33
|
-
}
|
|
34
|
-
while (args.length >= 0) {
|
|
35
|
-
if (args.length === length[type]) {
|
|
36
|
-
segmentsArray.push([command, ...args.splice(0, length[type])]);
|
|
37
|
-
break;
|
|
38
|
-
}
|
|
39
|
-
if (args.length < length[type]) {
|
|
40
|
-
throw new Error(`Malformed path data: "${command}" must have ${length[type]} elements and has ${args.length}: ${segmentString}`);
|
|
41
|
-
}
|
|
42
|
-
segmentsArray.push([command, ...args.splice(0, length[type])]);
|
|
43
|
-
}
|
|
44
|
-
return segmentsArray;
|
|
45
|
-
}, []);
|
|
46
|
-
};
|
|
47
|
-
exports.parsePath = parsePath;
|
|
48
|
-
const parseValues = (args) => {
|
|
49
|
-
const numbers = args.match(numberRegExp);
|
|
50
|
-
return numbers ? numbers.map(Number) : [];
|
|
51
|
-
};
|