@remotion/paths 3.3.36 → 3.3.38
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/index.d.ts +1 -0
- package/dist/index.js +3 -1
- package/dist/translate-path.d.ts +1 -0
- package/dist/translate-path.js +43 -0
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.reversePath = exports.normalizePath = exports.interpolatePath = exports.getTangentAtLength = exports.getSubpaths = exports.getPointAtLength = exports.getParts = exports.getLength = exports.extendViewBox = exports.evolvePath = void 0;
|
|
3
|
+
exports.translatePath = exports.reversePath = exports.normalizePath = exports.interpolatePath = exports.getTangentAtLength = exports.getSubpaths = exports.getPointAtLength = exports.getParts = exports.getLength = exports.extendViewBox = exports.evolvePath = void 0;
|
|
4
4
|
var evolve_path_1 = require("./evolve-path");
|
|
5
5
|
Object.defineProperty(exports, "evolvePath", { enumerable: true, get: function () { return evolve_path_1.evolvePath; } });
|
|
6
6
|
var extend_viewbox_1 = require("./extend-viewbox");
|
|
@@ -21,3 +21,5 @@ var normalize_path_1 = require("./normalize-path");
|
|
|
21
21
|
Object.defineProperty(exports, "normalizePath", { enumerable: true, get: function () { return normalize_path_1.normalizePath; } });
|
|
22
22
|
var reverse_path_1 = require("./reverse-path");
|
|
23
23
|
Object.defineProperty(exports, "reversePath", { enumerable: true, get: function () { return reverse_path_1.reversePath; } });
|
|
24
|
+
var translate_path_1 = require("./translate-path");
|
|
25
|
+
Object.defineProperty(exports, "translatePath", { enumerable: true, get: function () { return translate_path_1.translatePath; } });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const translatePath: (path: string, x: number, y: number) => string;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.translatePath = void 0;
|
|
4
|
+
const parse_1 = require("./helpers/parse");
|
|
5
|
+
const serialize = (path) => {
|
|
6
|
+
return path.reduce((str, seg) => {
|
|
7
|
+
return (str + ' ' + seg[0] + ' ' + seg.slice(1).join(',')).trim();
|
|
8
|
+
}, '');
|
|
9
|
+
};
|
|
10
|
+
const translateSegments = (path, x, y) => {
|
|
11
|
+
const segments = (0, parse_1.parsePath)(path);
|
|
12
|
+
return segments.map((segment) => {
|
|
13
|
+
const cmd = segment[0];
|
|
14
|
+
// Shift coords only for commands with absolute values
|
|
15
|
+
if ('ACHLMRQSTVZ'.indexOf(cmd) === -1) {
|
|
16
|
+
return segment;
|
|
17
|
+
}
|
|
18
|
+
const name = cmd.toLowerCase();
|
|
19
|
+
// V is the only command, with shifted coords parity
|
|
20
|
+
if (name === 'v') {
|
|
21
|
+
segment[1] = segment[1] + y;
|
|
22
|
+
return segment;
|
|
23
|
+
}
|
|
24
|
+
// ARC is: ['A', rx, ry, x-axis-rotation, large-arc-flag, sweep-flag, x, y]
|
|
25
|
+
// touch x, y only
|
|
26
|
+
if (name === 'a') {
|
|
27
|
+
segment[6] = segment[6] + x;
|
|
28
|
+
segment[7] = segment[7] + (y !== null && y !== void 0 ? y : 0);
|
|
29
|
+
return segment;
|
|
30
|
+
}
|
|
31
|
+
// All other commands have [cmd, x1, y1, x2, y2, x3, y3, ...] format
|
|
32
|
+
return segment.map((val, i) => {
|
|
33
|
+
if (!i) {
|
|
34
|
+
return val;
|
|
35
|
+
}
|
|
36
|
+
return i % 2 ? val + x : val + (y !== null && y !== void 0 ? y : 0);
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
const translatePath = (path, x, y) => {
|
|
41
|
+
return serialize(translateSegments(path, x, y));
|
|
42
|
+
};
|
|
43
|
+
exports.translatePath = translatePath;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remotion/paths",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.38",
|
|
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": "ac58695e452e58deb5c010f09bcc94d036930e6c"
|
|
39
39
|
}
|