reframe-video 0.6.14 → 0.6.15

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/bin.js CHANGED
@@ -1347,6 +1347,17 @@ var init_behaviors = __esm({
1347
1347
  });
1348
1348
 
1349
1349
  // ../core/src/interpolate.ts
1350
+ function springEase(stiffness, damping, velocity) {
1351
+ const K = 5;
1352
+ const zeta = Math.min(0.999, Math.max(0.05, damping / (2 * Math.sqrt(Math.max(1e-6, stiffness)))));
1353
+ const wd = K / zeta * Math.sqrt(1 - zeta * zeta);
1354
+ const coef = (K - velocity) / wd;
1355
+ return (u) => {
1356
+ if (u <= 0) return 0;
1357
+ if (u >= 1) return 1;
1358
+ return 1 - Math.exp(-K * u) * (Math.cos(wd * u) + coef * Math.sin(wd * u));
1359
+ };
1360
+ }
1350
1361
  function easeOutBounce(u) {
1351
1362
  const n1 = 7.5625;
1352
1363
  const d1 = 2.75;
@@ -1390,7 +1401,11 @@ var init_interpolate = __esm({
1390
1401
  // bounce: drops and bounces to rest (lands without overshoot)
1391
1402
  easeInBounce: (u) => 1 - easeOutBounce(1 - u),
1392
1403
  easeOutBounce,
1393
- easeInOutBounce: (u) => u < 0.5 ? (1 - easeOutBounce(1 - 2 * u)) / 2 : (1 + easeOutBounce(2 * u - 1)) / 2
1404
+ easeInOutBounce: (u) => u < 0.5 ? (1 - easeOutBounce(1 - 2 * u)) / 2 : (1 + easeOutBounce(2 * u - 1)) / 2,
1405
+ // damped-spring presets (ζ from damping/(2√stiffness)): 0.5 / 0.30 / 0.90
1406
+ spring: springEase(100, 10, 0),
1407
+ springBouncy: springEase(180, 8, 0),
1408
+ springStiff: springEase(210, 26, 0)
1394
1409
  };
1395
1410
  EASE_NAMES = Object.keys(EASE_TABLE);
1396
1411
  }
@@ -409,6 +409,17 @@
409
409
  var BACK_C3 = BACK_C1 + 1;
410
410
  var ELASTIC_C4 = 2 * Math.PI / 3;
411
411
  var ELASTIC_C5 = 2 * Math.PI / 4.5;
412
+ function springEase(stiffness, damping, velocity) {
413
+ const K = 5;
414
+ const zeta = Math.min(0.999, Math.max(0.05, damping / (2 * Math.sqrt(Math.max(1e-6, stiffness)))));
415
+ const wd = K / zeta * Math.sqrt(1 - zeta * zeta);
416
+ const coef = (K - velocity) / wd;
417
+ return (u) => {
418
+ if (u <= 0) return 0;
419
+ if (u >= 1) return 1;
420
+ return 1 - Math.exp(-K * u) * (Math.cos(wd * u) + coef * Math.sin(wd * u));
421
+ };
422
+ }
412
423
  function easeOutBounce(u) {
413
424
  const n1 = 7.5625;
414
425
  const d1 = 2.75;
@@ -443,7 +454,11 @@
443
454
  // bounce: drops and bounces to rest (lands without overshoot)
444
455
  easeInBounce: (u) => 1 - easeOutBounce(1 - u),
445
456
  easeOutBounce,
446
- easeInOutBounce: (u) => u < 0.5 ? (1 - easeOutBounce(1 - 2 * u)) / 2 : (1 + easeOutBounce(2 * u - 1)) / 2
457
+ easeInOutBounce: (u) => u < 0.5 ? (1 - easeOutBounce(1 - 2 * u)) / 2 : (1 + easeOutBounce(2 * u - 1)) / 2,
458
+ // damped-spring presets (ζ from damping/(2√stiffness)): 0.5 / 0.30 / 0.90
459
+ spring: springEase(100, 10, 0),
460
+ springBouncy: springEase(180, 8, 0),
461
+ springStiff: springEase(210, 26, 0)
447
462
  };
448
463
  var EASE_NAMES = Object.keys(EASE_TABLE);
449
464
  function resolveEase(ease) {
@@ -453,6 +468,10 @@
453
468
  if (!fn) throw new Error(`unknown ease "${ease}" \u2014 valid: ${Object.keys(EASE_TABLE).join(", ")}`);
454
469
  return fn;
455
470
  }
471
+ if ("spring" in ease) {
472
+ const { stiffness = 100, damping = 10, velocity = 0 } = ease.spring;
473
+ return springEase(stiffness, damping, velocity);
474
+ }
456
475
  return cubicBezierEase(...ease.cubicBezier);
457
476
  }
458
477
  function cubicBezierEase(x1, y1, x2, y2) {
package/dist/cli.js CHANGED
@@ -1051,6 +1051,17 @@ var BACK_C2 = BACK_C1 * 1.525;
1051
1051
  var BACK_C3 = BACK_C1 + 1;
1052
1052
  var ELASTIC_C4 = 2 * Math.PI / 3;
1053
1053
  var ELASTIC_C5 = 2 * Math.PI / 4.5;
1054
+ function springEase(stiffness, damping, velocity) {
1055
+ const K = 5;
1056
+ const zeta = Math.min(0.999, Math.max(0.05, damping / (2 * Math.sqrt(Math.max(1e-6, stiffness)))));
1057
+ const wd = K / zeta * Math.sqrt(1 - zeta * zeta);
1058
+ const coef = (K - velocity) / wd;
1059
+ return (u) => {
1060
+ if (u <= 0) return 0;
1061
+ if (u >= 1) return 1;
1062
+ return 1 - Math.exp(-K * u) * (Math.cos(wd * u) + coef * Math.sin(wd * u));
1063
+ };
1064
+ }
1054
1065
  function easeOutBounce(u) {
1055
1066
  const n1 = 7.5625;
1056
1067
  const d1 = 2.75;
@@ -1085,7 +1096,11 @@ var EASE_TABLE = {
1085
1096
  // bounce: drops and bounces to rest (lands without overshoot)
1086
1097
  easeInBounce: (u) => 1 - easeOutBounce(1 - u),
1087
1098
  easeOutBounce,
1088
- easeInOutBounce: (u) => u < 0.5 ? (1 - easeOutBounce(1 - 2 * u)) / 2 : (1 + easeOutBounce(2 * u - 1)) / 2
1099
+ easeInOutBounce: (u) => u < 0.5 ? (1 - easeOutBounce(1 - 2 * u)) / 2 : (1 + easeOutBounce(2 * u - 1)) / 2,
1100
+ // damped-spring presets (ζ from damping/(2√stiffness)): 0.5 / 0.30 / 0.90
1101
+ spring: springEase(100, 10, 0),
1102
+ springBouncy: springEase(180, 8, 0),
1103
+ springStiff: springEase(210, 26, 0)
1089
1104
  };
1090
1105
  var EASE_NAMES = Object.keys(EASE_TABLE);
1091
1106
 
package/dist/diff.js CHANGED
@@ -640,6 +640,17 @@ var BACK_C2 = BACK_C1 * 1.525;
640
640
  var BACK_C3 = BACK_C1 + 1;
641
641
  var ELASTIC_C4 = 2 * Math.PI / 3;
642
642
  var ELASTIC_C5 = 2 * Math.PI / 4.5;
643
+ function springEase(stiffness, damping, velocity) {
644
+ const K = 5;
645
+ const zeta = Math.min(0.999, Math.max(0.05, damping / (2 * Math.sqrt(Math.max(1e-6, stiffness)))));
646
+ const wd = K / zeta * Math.sqrt(1 - zeta * zeta);
647
+ const coef = (K - velocity) / wd;
648
+ return (u) => {
649
+ if (u <= 0) return 0;
650
+ if (u >= 1) return 1;
651
+ return 1 - Math.exp(-K * u) * (Math.cos(wd * u) + coef * Math.sin(wd * u));
652
+ };
653
+ }
643
654
  function easeOutBounce(u) {
644
655
  const n1 = 7.5625;
645
656
  const d1 = 2.75;
@@ -674,7 +685,11 @@ var EASE_TABLE = {
674
685
  // bounce: drops and bounces to rest (lands without overshoot)
675
686
  easeInBounce: (u) => 1 - easeOutBounce(1 - u),
676
687
  easeOutBounce,
677
- easeInOutBounce: (u) => u < 0.5 ? (1 - easeOutBounce(1 - 2 * u)) / 2 : (1 + easeOutBounce(2 * u - 1)) / 2
688
+ easeInOutBounce: (u) => u < 0.5 ? (1 - easeOutBounce(1 - 2 * u)) / 2 : (1 + easeOutBounce(2 * u - 1)) / 2,
689
+ // damped-spring presets (ζ from damping/(2√stiffness)): 0.5 / 0.30 / 0.90
690
+ spring: springEase(100, 10, 0),
691
+ springBouncy: springEase(180, 8, 0),
692
+ springStiff: springEase(210, 26, 0)
678
693
  };
679
694
  var EASE_NAMES = Object.keys(EASE_TABLE);
680
695
 
package/dist/index.js CHANGED
@@ -2851,6 +2851,17 @@ var BACK_C2 = BACK_C1 * 1.525;
2851
2851
  var BACK_C3 = BACK_C1 + 1;
2852
2852
  var ELASTIC_C4 = 2 * Math.PI / 3;
2853
2853
  var ELASTIC_C5 = 2 * Math.PI / 4.5;
2854
+ function springEase(stiffness, damping, velocity) {
2855
+ const K3 = 5;
2856
+ const zeta = Math.min(0.999, Math.max(0.05, damping / (2 * Math.sqrt(Math.max(1e-6, stiffness)))));
2857
+ const wd = K3 / zeta * Math.sqrt(1 - zeta * zeta);
2858
+ const coef = (K3 - velocity) / wd;
2859
+ return (u) => {
2860
+ if (u <= 0) return 0;
2861
+ if (u >= 1) return 1;
2862
+ return 1 - Math.exp(-K3 * u) * (Math.cos(wd * u) + coef * Math.sin(wd * u));
2863
+ };
2864
+ }
2854
2865
  function easeOutBounce(u) {
2855
2866
  const n1 = 7.5625;
2856
2867
  const d1 = 2.75;
@@ -2885,7 +2896,11 @@ var EASE_TABLE = {
2885
2896
  // bounce: drops and bounces to rest (lands without overshoot)
2886
2897
  easeInBounce: (u) => 1 - easeOutBounce(1 - u),
2887
2898
  easeOutBounce,
2888
- easeInOutBounce: (u) => u < 0.5 ? (1 - easeOutBounce(1 - 2 * u)) / 2 : (1 + easeOutBounce(2 * u - 1)) / 2
2899
+ easeInOutBounce: (u) => u < 0.5 ? (1 - easeOutBounce(1 - 2 * u)) / 2 : (1 + easeOutBounce(2 * u - 1)) / 2,
2900
+ // damped-spring presets (ζ from damping/(2√stiffness)): 0.5 / 0.30 / 0.90
2901
+ spring: springEase(100, 10, 0),
2902
+ springBouncy: springEase(180, 8, 0),
2903
+ springStiff: springEase(210, 26, 0)
2889
2904
  };
2890
2905
  var EASE_NAMES = Object.keys(EASE_TABLE);
2891
2906
  function resolveEase(ease) {
@@ -2895,6 +2910,10 @@ function resolveEase(ease) {
2895
2910
  if (!fn) throw new Error(`unknown ease "${ease}" \u2014 valid: ${Object.keys(EASE_TABLE).join(", ")}`);
2896
2911
  return fn;
2897
2912
  }
2913
+ if ("spring" in ease) {
2914
+ const { stiffness = 100, damping = 10, velocity = 0 } = ease.spring;
2915
+ return springEase(stiffness, damping, velocity);
2916
+ }
2898
2917
  return cubicBezierEase(...ease.cubicBezier);
2899
2918
  }
2900
2919
  function cubicBezierEase(x1, y1, x2, y2) {
package/dist/labels.js CHANGED
@@ -598,6 +598,17 @@ var BACK_C2 = BACK_C1 * 1.525;
598
598
  var BACK_C3 = BACK_C1 + 1;
599
599
  var ELASTIC_C4 = 2 * Math.PI / 3;
600
600
  var ELASTIC_C5 = 2 * Math.PI / 4.5;
601
+ function springEase(stiffness, damping, velocity) {
602
+ const K = 5;
603
+ const zeta = Math.min(0.999, Math.max(0.05, damping / (2 * Math.sqrt(Math.max(1e-6, stiffness)))));
604
+ const wd = K / zeta * Math.sqrt(1 - zeta * zeta);
605
+ const coef = (K - velocity) / wd;
606
+ return (u) => {
607
+ if (u <= 0) return 0;
608
+ if (u >= 1) return 1;
609
+ return 1 - Math.exp(-K * u) * (Math.cos(wd * u) + coef * Math.sin(wd * u));
610
+ };
611
+ }
601
612
  function easeOutBounce(u) {
602
613
  const n1 = 7.5625;
603
614
  const d1 = 2.75;
@@ -632,7 +643,11 @@ var EASE_TABLE = {
632
643
  // bounce: drops and bounces to rest (lands without overshoot)
633
644
  easeInBounce: (u) => 1 - easeOutBounce(1 - u),
634
645
  easeOutBounce,
635
- easeInOutBounce: (u) => u < 0.5 ? (1 - easeOutBounce(1 - 2 * u)) / 2 : (1 + easeOutBounce(2 * u - 1)) / 2
646
+ easeInOutBounce: (u) => u < 0.5 ? (1 - easeOutBounce(1 - 2 * u)) / 2 : (1 + easeOutBounce(2 * u - 1)) / 2,
647
+ // damped-spring presets (ζ from damping/(2√stiffness)): 0.5 / 0.30 / 0.90
648
+ spring: springEase(100, 10, 0),
649
+ springBouncy: springEase(180, 8, 0),
650
+ springStiff: springEase(210, 26, 0)
636
651
  };
637
652
  var EASE_NAMES = Object.keys(EASE_TABLE);
638
653
 
package/dist/trace-cli.js CHANGED
@@ -42,6 +42,17 @@ var BACK_C2 = BACK_C1 * 1.525;
42
42
  var BACK_C3 = BACK_C1 + 1;
43
43
  var ELASTIC_C4 = 2 * Math.PI / 3;
44
44
  var ELASTIC_C5 = 2 * Math.PI / 4.5;
45
+ function springEase(stiffness, damping, velocity) {
46
+ const K = 5;
47
+ const zeta = Math.min(0.999, Math.max(0.05, damping / (2 * Math.sqrt(Math.max(1e-6, stiffness)))));
48
+ const wd = K / zeta * Math.sqrt(1 - zeta * zeta);
49
+ const coef = (K - velocity) / wd;
50
+ return (u) => {
51
+ if (u <= 0) return 0;
52
+ if (u >= 1) return 1;
53
+ return 1 - Math.exp(-K * u) * (Math.cos(wd * u) + coef * Math.sin(wd * u));
54
+ };
55
+ }
45
56
  function easeOutBounce(u) {
46
57
  const n1 = 7.5625;
47
58
  const d1 = 2.75;
@@ -76,7 +87,11 @@ var EASE_TABLE = {
76
87
  // bounce: drops and bounces to rest (lands without overshoot)
77
88
  easeInBounce: (u) => 1 - easeOutBounce(1 - u),
78
89
  easeOutBounce,
79
- easeInOutBounce: (u) => u < 0.5 ? (1 - easeOutBounce(1 - 2 * u)) / 2 : (1 + easeOutBounce(2 * u - 1)) / 2
90
+ easeInOutBounce: (u) => u < 0.5 ? (1 - easeOutBounce(1 - 2 * u)) / 2 : (1 + easeOutBounce(2 * u - 1)) / 2,
91
+ // damped-spring presets (ζ from damping/(2√stiffness)): 0.5 / 0.30 / 0.90
92
+ spring: springEase(100, 10, 0),
93
+ springBouncy: springEase(180, 8, 0),
94
+ springStiff: springEase(210, 26, 0)
80
95
  };
81
96
  var EASE_NAMES = Object.keys(EASE_TABLE);
82
97
 
@@ -8,10 +8,24 @@
8
8
  * Semantics: a scene is evaluated as a pure function of continuous time
9
9
  * `evaluate(scene, tSeconds) -> DisplayList`. `fps` is a render hint only.
10
10
  */
11
- export type EaseName = "linear" | "easeInQuad" | "easeOutQuad" | "easeInOutQuad" | "easeInCubic" | "easeOutCubic" | "easeInOutCubic" | "easeInQuart" | "easeOutQuart" | "easeInOutQuart" | "easeInExpo" | "easeOutExpo" | "easeInOutExpo" | "easeInBack" | "easeOutBack" | "easeInOutBack" | "easeInElastic" | "easeOutElastic" | "easeInOutElastic" | "easeInBounce" | "easeOutBounce" | "easeInOutBounce";
11
+ export type EaseName = "linear" | "easeInQuad" | "easeOutQuad" | "easeInOutQuad" | "easeInCubic" | "easeOutCubic" | "easeInOutCubic" | "easeInQuart" | "easeOutQuart" | "easeInOutQuart" | "easeInExpo" | "easeOutExpo" | "easeInOutExpo" | "easeInBack" | "easeOutBack" | "easeInOutBack" | "easeInElastic" | "easeOutElastic" | "easeInOutElastic" | "easeInBounce" | "easeOutBounce" | "easeInOutBounce" | "spring" | "springBouncy" | "springStiff";
12
+ /**
13
+ * A custom spring: a damped harmonic oscillator sampled over the tween's normalized
14
+ * 0..1 window (mass = 1). `stiffness`/`damping` set the damping ratio
15
+ * ζ = damping / (2·√stiffness) — the SHAPE knob (low ζ ⇒ bouncy, high ζ ⇒ snappy);
16
+ * `velocity` is an initial launch slope. Defaults: stiffness 100, damping 10
17
+ * (ζ = 0.5), velocity 0.
18
+ */
19
+ export interface SpringEase {
20
+ spring: {
21
+ stiffness?: number;
22
+ damping?: number;
23
+ velocity?: number;
24
+ };
25
+ }
12
26
  export type Ease = EaseName | {
13
27
  cubicBezier: [number, number, number, number];
14
- };
28
+ } | SpringEase;
15
29
  export type Anchor = "top-left" | "top-center" | "top-right" | "center-left" | "center" | "center-right" | "bottom-left" | "bottom-center" | "bottom-right";
16
30
  export interface Size {
17
31
  width: number;
@@ -135,7 +135,10 @@ Expressive eases for a premium feel: `easeIn/Out/InOutBack` (overshoots past the
135
135
  target then settles — a pop/snap), `easeIn/Out/InOutElastic` (rings around the
136
136
  target — a playful spring), `easeIn/Out/InOutBounce` (drops and bounces to rest).
137
137
  A logo or card "popping" in usually wants `easeOutBack`; a stamp landing,
138
- `easeOutBounce`.
138
+ `easeOutBounce`. Physical springs settle to rest within the tween's duration:
139
+ `spring` (a natural settle), `springBouncy` (rings more), `springStiff` (snappy,
140
+ barely overshoots) — or tune your own with `{ spring: { stiffness, damping, velocity } }`
141
+ (damping ratio = `damping / (2·√stiffness)`; lower ⇒ bouncier).
139
142
  Scene duration is inferred from the timeline. For a **static frame** you can omit
140
143
  `timeline` entirely (or set scene `duration: <seconds>`) — a still defaults to a 1s
141
144
  render; no throwaway `wait` is needed.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "reframe-video",
3
- "version": "0.6.14",
3
+ "version": "0.6.15",
4
4
  "description": "Declarative motion graphics that AI can write and humans can tweak — human edits survive AI regeneration. Deterministic mp4 renders from a plain-data scene format.",
5
5
  "keywords": [
6
6
  "motion-graphics",