@remotion/paths 4.0.502 → 4.0.504
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/esm/index.mjs
CHANGED
|
@@ -760,7 +760,6 @@ var cValues = [
|
|
|
760
760
|
0.0123412297999872
|
|
761
761
|
]
|
|
762
762
|
];
|
|
763
|
-
var binomialCoefficients = [[1], [1, 1], [1, 2, 1], [1, 3, 3, 1]];
|
|
764
763
|
|
|
765
764
|
// src/helpers/bezier-functions.ts
|
|
766
765
|
var cubicPoint = (xs, ys, t) => {
|
|
@@ -768,43 +767,27 @@ var cubicPoint = (xs, ys, t) => {
|
|
|
768
767
|
const y = (1 - t) * (1 - t) * (1 - t) * ys[0] + 3 * (1 - t) * (1 - t) * t * ys[1] + 3 * (1 - t) * t * t * ys[2] + t * t * t * ys[3];
|
|
769
768
|
return { x, y };
|
|
770
769
|
};
|
|
771
|
-
var getDerivative = (derivative, t, vs) => {
|
|
772
|
-
const n = vs.length - 1;
|
|
773
|
-
let value;
|
|
774
|
-
if (n === 0) {
|
|
775
|
-
return 0;
|
|
776
|
-
}
|
|
777
|
-
if (derivative === 0) {
|
|
778
|
-
value = 0;
|
|
779
|
-
for (let k = 0;k <= n; k++) {
|
|
780
|
-
value += binomialCoefficients[n][k] * (1 - t) ** (n - k) * t ** k * vs[k];
|
|
781
|
-
}
|
|
782
|
-
return value;
|
|
783
|
-
}
|
|
784
|
-
const _vs = new Array(n);
|
|
785
|
-
for (let k = 0;k < n; k++) {
|
|
786
|
-
_vs[k] = n * (vs[k + 1] - vs[k]);
|
|
787
|
-
}
|
|
788
|
-
return getDerivative(derivative - 1, t, _vs);
|
|
789
|
-
};
|
|
790
|
-
function bFunc(xs, ys, t) {
|
|
791
|
-
const xbase = getDerivative(1, t, xs);
|
|
792
|
-
const ybase = getDerivative(1, t, ys);
|
|
793
|
-
const combined = xbase * xbase + ybase * ybase;
|
|
794
|
-
return Math.sqrt(combined);
|
|
795
|
-
}
|
|
796
770
|
var getCubicArcLength = ({
|
|
797
771
|
sx,
|
|
798
772
|
sy,
|
|
799
773
|
t
|
|
800
774
|
}) => {
|
|
775
|
+
const v0x = 3 * (sx[1] - sx[0]);
|
|
776
|
+
const v1x = 3 * (sx[2] - sx[1]);
|
|
777
|
+
const v2x = 3 * (sx[3] - sx[2]);
|
|
778
|
+
const v0y = 3 * (sy[1] - sy[0]);
|
|
779
|
+
const v1y = 3 * (sy[2] - sy[1]);
|
|
780
|
+
const v2y = 3 * (sy[3] - sy[2]);
|
|
801
781
|
let correctedT;
|
|
802
782
|
const n = 20;
|
|
803
783
|
const z = t / 2;
|
|
804
784
|
let sum = 0;
|
|
805
785
|
for (let i = 0;i < n; i++) {
|
|
806
786
|
correctedT = z * tValues[n][i] + z;
|
|
807
|
-
|
|
787
|
+
const mt = 1 - correctedT;
|
|
788
|
+
const xbase = mt * mt * v0x + 2 * mt * correctedT * v1x + correctedT * correctedT * v2x;
|
|
789
|
+
const ybase = mt * mt * v0y + 2 * mt * correctedT * v1y + correctedT * correctedT * v2y;
|
|
790
|
+
sum += cValues[n][i] * Math.sqrt(xbase * xbase + ybase * ybase);
|
|
808
791
|
}
|
|
809
792
|
return z * sum;
|
|
810
793
|
};
|
|
@@ -814,8 +797,17 @@ var quadraticPoint = (xs, ys, t) => {
|
|
|
814
797
|
return { x, y };
|
|
815
798
|
};
|
|
816
799
|
var cubicDerivative = (xs, ys, t) => {
|
|
817
|
-
const
|
|
818
|
-
|
|
800
|
+
const v0x = 3 * (xs[1] - xs[0]);
|
|
801
|
+
const v1x = 3 * (xs[2] - xs[1]);
|
|
802
|
+
const v2x = 3 * (xs[3] - xs[2]);
|
|
803
|
+
const v0y = 3 * (ys[1] - ys[0]);
|
|
804
|
+
const v1y = 3 * (ys[2] - ys[1]);
|
|
805
|
+
const v2y = 3 * (ys[3] - ys[2]);
|
|
806
|
+
const mt = 1 - t;
|
|
807
|
+
return {
|
|
808
|
+
x: mt * mt * v0x + 2 * mt * t * v1x + t * t * v2x,
|
|
809
|
+
y: mt * mt * v0y + 2 * mt * t * v1y + t * t * v2y
|
|
810
|
+
};
|
|
819
811
|
};
|
|
820
812
|
var getQuadraticArcLength = (xs, ys, t) => {
|
|
821
813
|
if (t === undefined) {
|
|
@@ -6,7 +6,10 @@ export declare const getCubicArcLength: ({ sx, sy, t, }: {
|
|
|
6
6
|
t: number;
|
|
7
7
|
}) => number;
|
|
8
8
|
export declare const quadraticPoint: (xs: number[], ys: number[], t: number) => Point;
|
|
9
|
-
export declare const cubicDerivative: (xs: number[], ys: number[], t: number) =>
|
|
9
|
+
export declare const cubicDerivative: (xs: number[], ys: number[], t: number) => {
|
|
10
|
+
x: number;
|
|
11
|
+
y: number;
|
|
12
|
+
};
|
|
10
13
|
export declare const getQuadraticArcLength: (xs: number[], ys: number[], t: number) => number;
|
|
11
14
|
export declare const quadraticDerivative: (xs: number[], ys: number[], t: number) => {
|
|
12
15
|
x: number;
|
|
@@ -14,46 +14,23 @@ const cubicPoint = (xs, ys, t) => {
|
|
|
14
14
|
return { x, y };
|
|
15
15
|
};
|
|
16
16
|
exports.cubicPoint = cubicPoint;
|
|
17
|
-
/**
|
|
18
|
-
* Compute the curve derivative (hodograph) at t.
|
|
19
|
-
*/
|
|
20
|
-
const getDerivative = (derivative, t, vs) => {
|
|
21
|
-
// the derivative of any 't'-less function is zero.
|
|
22
|
-
const n = vs.length - 1;
|
|
23
|
-
let value;
|
|
24
|
-
if (n === 0) {
|
|
25
|
-
return 0;
|
|
26
|
-
}
|
|
27
|
-
// direct values? compute!
|
|
28
|
-
if (derivative === 0) {
|
|
29
|
-
value = 0;
|
|
30
|
-
for (let k = 0; k <= n; k++) {
|
|
31
|
-
value += bezier_values_1.binomialCoefficients[n][k] * (1 - t) ** (n - k) * t ** k * vs[k];
|
|
32
|
-
}
|
|
33
|
-
return value;
|
|
34
|
-
}
|
|
35
|
-
// Still some derivative? go down one order, then try
|
|
36
|
-
// for the lower order curve's.
|
|
37
|
-
const _vs = new Array(n);
|
|
38
|
-
for (let k = 0; k < n; k++) {
|
|
39
|
-
_vs[k] = n * (vs[k + 1] - vs[k]);
|
|
40
|
-
}
|
|
41
|
-
return getDerivative(derivative - 1, t, _vs);
|
|
42
|
-
};
|
|
43
|
-
function bFunc(xs, ys, t) {
|
|
44
|
-
const xbase = getDerivative(1, t, xs);
|
|
45
|
-
const ybase = getDerivative(1, t, ys);
|
|
46
|
-
const combined = xbase * xbase + ybase * ybase;
|
|
47
|
-
return Math.sqrt(combined);
|
|
48
|
-
}
|
|
49
17
|
const getCubicArcLength = ({ sx, sy, t, }) => {
|
|
18
|
+
const v0x = 3 * (sx[1] - sx[0]);
|
|
19
|
+
const v1x = 3 * (sx[2] - sx[1]);
|
|
20
|
+
const v2x = 3 * (sx[3] - sx[2]);
|
|
21
|
+
const v0y = 3 * (sy[1] - sy[0]);
|
|
22
|
+
const v1y = 3 * (sy[2] - sy[1]);
|
|
23
|
+
const v2y = 3 * (sy[3] - sy[2]);
|
|
50
24
|
let correctedT;
|
|
51
25
|
const n = 20;
|
|
52
26
|
const z = t / 2;
|
|
53
27
|
let sum = 0;
|
|
54
28
|
for (let i = 0; i < n; i++) {
|
|
55
29
|
correctedT = z * bezier_values_1.tValues[n][i] + z;
|
|
56
|
-
|
|
30
|
+
const mt = 1 - correctedT;
|
|
31
|
+
const xbase = mt * mt * v0x + 2 * mt * correctedT * v1x + correctedT * correctedT * v2x;
|
|
32
|
+
const ybase = mt * mt * v0y + 2 * mt * correctedT * v1y + correctedT * correctedT * v2y;
|
|
33
|
+
sum += bezier_values_1.cValues[n][i] * Math.sqrt(xbase * xbase + ybase * ybase);
|
|
57
34
|
}
|
|
58
35
|
return z * sum;
|
|
59
36
|
};
|
|
@@ -65,8 +42,17 @@ const quadraticPoint = (xs, ys, t) => {
|
|
|
65
42
|
};
|
|
66
43
|
exports.quadraticPoint = quadraticPoint;
|
|
67
44
|
const cubicDerivative = (xs, ys, t) => {
|
|
68
|
-
const
|
|
69
|
-
|
|
45
|
+
const v0x = 3 * (xs[1] - xs[0]);
|
|
46
|
+
const v1x = 3 * (xs[2] - xs[1]);
|
|
47
|
+
const v2x = 3 * (xs[3] - xs[2]);
|
|
48
|
+
const v0y = 3 * (ys[1] - ys[0]);
|
|
49
|
+
const v1y = 3 * (ys[2] - ys[1]);
|
|
50
|
+
const v2y = 3 * (ys[3] - ys[2]);
|
|
51
|
+
const mt = 1 - t;
|
|
52
|
+
return {
|
|
53
|
+
x: mt * mt * v0x + 2 * mt * t * v1x + t * t * v2x,
|
|
54
|
+
y: mt * mt * v0y + 2 * mt * t * v1y + t * t * v2y,
|
|
55
|
+
};
|
|
70
56
|
};
|
|
71
57
|
exports.cubicDerivative = cubicDerivative;
|
|
72
58
|
const getQuadraticArcLength = (xs, ys, t) => {
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"url": "https://github.com/remotion-dev/remotion/tree/main/packages/paths"
|
|
4
4
|
},
|
|
5
5
|
"name": "@remotion/paths",
|
|
6
|
-
"version": "4.0.
|
|
6
|
+
"version": "4.0.504",
|
|
7
7
|
"description": "Utilities for working with SVG paths",
|
|
8
8
|
"main": "dist/index.js",
|
|
9
9
|
"types": "dist/index.d.ts",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"utilities"
|
|
27
27
|
],
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@remotion/eslint-config-internal": "4.0.
|
|
29
|
+
"@remotion/eslint-config-internal": "4.0.504",
|
|
30
30
|
"eslint": "9.19.0",
|
|
31
31
|
"@typescript/native-preview": "7.0.0-dev.20260217.1"
|
|
32
32
|
},
|