@remotion/rough-notation 4.0.503 → 4.0.505

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.
Files changed (2) hide show
  1. package/dist/esm/index.mjs +21 -29
  2. package/package.json +4 -4
@@ -793,49 +793,32 @@ var cValues = [
793
793
  0.0123412297999872
794
794
  ]
795
795
  ];
796
- var binomialCoefficients = [[1], [1, 1], [1, 2, 1], [1, 3, 3, 1]];
797
796
  var cubicPoint = (xs, ys, t) => {
798
797
  const x = (1 - t) * (1 - t) * (1 - t) * xs[0] + 3 * (1 - t) * (1 - t) * t * xs[1] + 3 * (1 - t) * t * t * xs[2] + t * t * t * xs[3];
799
798
  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];
800
799
  return { x, y };
801
800
  };
802
- var getDerivative = (derivative, t, vs) => {
803
- const n = vs.length - 1;
804
- let value;
805
- if (n === 0) {
806
- return 0;
807
- }
808
- if (derivative === 0) {
809
- value = 0;
810
- for (let k = 0;k <= n; k++) {
811
- value += binomialCoefficients[n][k] * (1 - t) ** (n - k) * t ** k * vs[k];
812
- }
813
- return value;
814
- }
815
- const _vs = new Array(n);
816
- for (let k = 0;k < n; k++) {
817
- _vs[k] = n * (vs[k + 1] - vs[k]);
818
- }
819
- return getDerivative(derivative - 1, t, _vs);
820
- };
821
- function bFunc(xs, ys, t) {
822
- const xbase = getDerivative(1, t, xs);
823
- const ybase = getDerivative(1, t, ys);
824
- const combined = xbase * xbase + ybase * ybase;
825
- return Math.sqrt(combined);
826
- }
827
801
  var getCubicArcLength = ({
828
802
  sx,
829
803
  sy,
830
804
  t
831
805
  }) => {
806
+ const v0x = 3 * (sx[1] - sx[0]);
807
+ const v1x = 3 * (sx[2] - sx[1]);
808
+ const v2x = 3 * (sx[3] - sx[2]);
809
+ const v0y = 3 * (sy[1] - sy[0]);
810
+ const v1y = 3 * (sy[2] - sy[1]);
811
+ const v2y = 3 * (sy[3] - sy[2]);
832
812
  let correctedT;
833
813
  const n = 20;
834
814
  const z = t / 2;
835
815
  let sum = 0;
836
816
  for (let i = 0;i < n; i++) {
837
817
  correctedT = z * tValues[n][i] + z;
838
- sum += cValues[n][i] * bFunc(sx, sy, correctedT);
818
+ const mt = 1 - correctedT;
819
+ const xbase = mt * mt * v0x + 2 * mt * correctedT * v1x + correctedT * correctedT * v2x;
820
+ const ybase = mt * mt * v0y + 2 * mt * correctedT * v1y + correctedT * correctedT * v2y;
821
+ sum += cValues[n][i] * Math.sqrt(xbase * xbase + ybase * ybase);
839
822
  }
840
823
  return z * sum;
841
824
  };
@@ -845,8 +828,17 @@ var quadraticPoint = (xs, ys, t) => {
845
828
  return { x, y };
846
829
  };
847
830
  var cubicDerivative = (xs, ys, t) => {
848
- const derivative = quadraticPoint([3 * (xs[1] - xs[0]), 3 * (xs[2] - xs[1]), 3 * (xs[3] - xs[2])], [3 * (ys[1] - ys[0]), 3 * (ys[2] - ys[1]), 3 * (ys[3] - ys[2])], t);
849
- return derivative;
831
+ const v0x = 3 * (xs[1] - xs[0]);
832
+ const v1x = 3 * (xs[2] - xs[1]);
833
+ const v2x = 3 * (xs[3] - xs[2]);
834
+ const v0y = 3 * (ys[1] - ys[0]);
835
+ const v1y = 3 * (ys[2] - ys[1]);
836
+ const v2y = 3 * (ys[3] - ys[2]);
837
+ const mt = 1 - t;
838
+ return {
839
+ x: mt * mt * v0x + 2 * mt * t * v1x + t * t * v2x,
840
+ y: mt * mt * v0y + 2 * mt * t * v1y + t * t * v2y
841
+ };
850
842
  };
851
843
  var getQuadraticArcLength = (xs, ys, t) => {
852
844
  if (t === undefined) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remotion/rough-notation",
3
- "version": "4.0.503",
3
+ "version": "4.0.505",
4
4
  "description": "Rough annotation primitives for Remotion",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -26,8 +26,8 @@
26
26
  "url": "https://github.com/remotion-dev/remotion/issues"
27
27
  },
28
28
  "dependencies": {
29
- "@remotion/paths": "4.0.503",
30
- "remotion": "4.0.503",
29
+ "@remotion/paths": "4.0.505",
30
+ "remotion": "4.0.505",
31
31
  "roughjs": "4.6.6"
32
32
  },
33
33
  "peerDependencies": {
@@ -45,7 +45,7 @@
45
45
  "devDependencies": {
46
46
  "react": "19.2.3",
47
47
  "react-dom": "19.2.3",
48
- "@remotion/eslint-config-internal": "4.0.503",
48
+ "@remotion/eslint-config-internal": "4.0.505",
49
49
  "eslint": "9.19.0",
50
50
  "@typescript/native-preview": "7.0.0-dev.20260217.1"
51
51
  },