@redwilly/anima 0.1.0 → 0.1.2

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 (239) hide show
  1. package/dist/cli/index.js +203 -57
  2. package/dist/index.d.ts +2086 -18
  3. package/dist/index.js +5343 -22
  4. package/package.json +5 -3
  5. package/dist/cli/SceneLoader.d.ts +0 -22
  6. package/dist/cli/SceneLoader.js +0 -47
  7. package/dist/cli/commands/export-frame.d.ts +0 -13
  8. package/dist/cli/commands/export-frame.js +0 -60
  9. package/dist/cli/commands/list-scenes.d.ts +0 -5
  10. package/dist/cli/commands/list-scenes.js +0 -22
  11. package/dist/cli/commands/preview.d.ts +0 -5
  12. package/dist/cli/commands/preview.js +0 -11
  13. package/dist/cli/commands/render.d.ts +0 -16
  14. package/dist/cli/commands/render.js +0 -76
  15. package/dist/cli/index.d.ts +0 -2
  16. package/dist/core/animations/Animation.d.ts +0 -41
  17. package/dist/core/animations/Animation.js +0 -76
  18. package/dist/core/animations/camera/Follow.d.ts +0 -70
  19. package/dist/core/animations/camera/Follow.js +0 -69
  20. package/dist/core/animations/camera/Shake.d.ts +0 -90
  21. package/dist/core/animations/camera/Shake.js +0 -87
  22. package/dist/core/animations/camera/index.d.ts +0 -2
  23. package/dist/core/animations/camera/index.js +0 -2
  24. package/dist/core/animations/categories/ExitAnimation.d.ts +0 -17
  25. package/dist/core/animations/categories/ExitAnimation.js +0 -15
  26. package/dist/core/animations/categories/IntroductoryAnimation.d.ts +0 -16
  27. package/dist/core/animations/categories/IntroductoryAnimation.js +0 -14
  28. package/dist/core/animations/categories/TransformativeAnimation.d.ts +0 -25
  29. package/dist/core/animations/categories/TransformativeAnimation.js +0 -25
  30. package/dist/core/animations/categories/index.d.ts +0 -3
  31. package/dist/core/animations/categories/index.js +0 -3
  32. package/dist/core/animations/composition/Parallel.d.ts +0 -37
  33. package/dist/core/animations/composition/Parallel.js +0 -79
  34. package/dist/core/animations/composition/Sequence.d.ts +0 -41
  35. package/dist/core/animations/composition/Sequence.js +0 -95
  36. package/dist/core/animations/composition/index.d.ts +0 -2
  37. package/dist/core/animations/composition/index.js +0 -3
  38. package/dist/core/animations/draw/Draw.d.ts +0 -30
  39. package/dist/core/animations/draw/Draw.js +0 -122
  40. package/dist/core/animations/draw/Unwrite.d.ts +0 -30
  41. package/dist/core/animations/draw/Unwrite.js +0 -120
  42. package/dist/core/animations/draw/Write.d.ts +0 -35
  43. package/dist/core/animations/draw/Write.js +0 -119
  44. package/dist/core/animations/draw/index.d.ts +0 -3
  45. package/dist/core/animations/draw/index.js +0 -3
  46. package/dist/core/animations/draw/partialPath.d.ts +0 -6
  47. package/dist/core/animations/draw/partialPath.js +0 -138
  48. package/dist/core/animations/easing/bounce.d.ts +0 -13
  49. package/dist/core/animations/easing/bounce.js +0 -37
  50. package/dist/core/animations/easing/index.d.ts +0 -7
  51. package/dist/core/animations/easing/index.js +0 -11
  52. package/dist/core/animations/easing/manim.d.ts +0 -46
  53. package/dist/core/animations/easing/manim.js +0 -102
  54. package/dist/core/animations/easing/registry.d.ts +0 -8
  55. package/dist/core/animations/easing/registry.js +0 -25
  56. package/dist/core/animations/easing/standard.d.ts +0 -113
  57. package/dist/core/animations/easing/standard.js +0 -151
  58. package/dist/core/animations/easing/types.d.ts +0 -6
  59. package/dist/core/animations/easing/types.js +0 -0
  60. package/dist/core/animations/fade/FadeIn.d.ts +0 -17
  61. package/dist/core/animations/fade/FadeIn.js +0 -22
  62. package/dist/core/animations/fade/FadeOut.d.ts +0 -17
  63. package/dist/core/animations/fade/FadeOut.js +0 -23
  64. package/dist/core/animations/fade/index.d.ts +0 -2
  65. package/dist/core/animations/fade/index.js +0 -2
  66. package/dist/core/animations/index.d.ts +0 -11
  67. package/dist/core/animations/index.js +0 -17
  68. package/dist/core/animations/keyframes/KeyframeAnimation.d.ts +0 -33
  69. package/dist/core/animations/keyframes/KeyframeAnimation.js +0 -40
  70. package/dist/core/animations/keyframes/KeyframeTrack.d.ts +0 -31
  71. package/dist/core/animations/keyframes/KeyframeTrack.js +0 -83
  72. package/dist/core/animations/keyframes/index.d.ts +0 -4
  73. package/dist/core/animations/keyframes/index.js +0 -5
  74. package/dist/core/animations/keyframes/types.d.ts +0 -25
  75. package/dist/core/animations/keyframes/types.js +0 -6
  76. package/dist/core/animations/morph/MorphTo.d.ts +0 -22
  77. package/dist/core/animations/morph/MorphTo.js +0 -42
  78. package/dist/core/animations/morph/index.d.ts +0 -1
  79. package/dist/core/animations/morph/index.js +0 -1
  80. package/dist/core/animations/transform/MoveTo.d.ts +0 -24
  81. package/dist/core/animations/transform/MoveTo.js +0 -38
  82. package/dist/core/animations/transform/Rotate.d.ts +0 -23
  83. package/dist/core/animations/transform/Rotate.js +0 -34
  84. package/dist/core/animations/transform/Scale.d.ts +0 -23
  85. package/dist/core/animations/transform/Scale.js +0 -35
  86. package/dist/core/animations/transform/index.d.ts +0 -3
  87. package/dist/core/animations/transform/index.js +0 -3
  88. package/dist/core/animations/types.d.ts +0 -52
  89. package/dist/core/animations/types.js +0 -6
  90. package/dist/core/camera/Camera.d.ts +0 -87
  91. package/dist/core/camera/Camera.js +0 -175
  92. package/dist/core/camera/CameraFrame.d.ts +0 -242
  93. package/dist/core/camera/CameraFrame.js +0 -322
  94. package/dist/core/camera/index.d.ts +0 -4
  95. package/dist/core/camera/index.js +0 -3
  96. package/dist/core/camera/types.d.ts +0 -17
  97. package/dist/core/camera/types.js +0 -1
  98. package/dist/core/errors/AnimationErrors.d.ts +0 -12
  99. package/dist/core/errors/AnimationErrors.js +0 -37
  100. package/dist/core/errors/index.d.ts +0 -1
  101. package/dist/core/errors/index.js +0 -1
  102. package/dist/core/math/Vector2/Vector2.d.ts +0 -23
  103. package/dist/core/math/Vector2/Vector2.js +0 -46
  104. package/dist/core/math/Vector2/index.d.ts +0 -1
  105. package/dist/core/math/Vector2/index.js +0 -1
  106. package/dist/core/math/bezier/BezierPath.d.ts +0 -38
  107. package/dist/core/math/bezier/BezierPath.js +0 -264
  108. package/dist/core/math/bezier/evaluators.d.ts +0 -9
  109. package/dist/core/math/bezier/evaluators.js +0 -36
  110. package/dist/core/math/bezier/index.d.ts +0 -8
  111. package/dist/core/math/bezier/index.js +0 -6
  112. package/dist/core/math/bezier/length.d.ts +0 -5
  113. package/dist/core/math/bezier/length.js +0 -27
  114. package/dist/core/math/bezier/morphing.d.ts +0 -16
  115. package/dist/core/math/bezier/morphing.js +0 -151
  116. package/dist/core/math/bezier/sampling.d.ts +0 -7
  117. package/dist/core/math/bezier/sampling.js +0 -153
  118. package/dist/core/math/bezier/split.d.ts +0 -19
  119. package/dist/core/math/bezier/split.js +0 -44
  120. package/dist/core/math/bezier/types.d.ts +0 -8
  121. package/dist/core/math/bezier/types.js +0 -0
  122. package/dist/core/math/color/Color.d.ts +0 -28
  123. package/dist/core/math/color/Color.js +0 -60
  124. package/dist/core/math/color/conversions.d.ts +0 -17
  125. package/dist/core/math/color/conversions.js +0 -100
  126. package/dist/core/math/color/index.d.ts +0 -2
  127. package/dist/core/math/color/index.js +0 -2
  128. package/dist/core/math/index.d.ts +0 -4
  129. package/dist/core/math/index.js +0 -5
  130. package/dist/core/math/matrix/Matrix3x3.d.ts +0 -23
  131. package/dist/core/math/matrix/Matrix3x3.js +0 -91
  132. package/dist/core/math/matrix/factories.d.ts +0 -12
  133. package/dist/core/math/matrix/factories.js +0 -44
  134. package/dist/core/math/matrix/index.d.ts +0 -2
  135. package/dist/core/math/matrix/index.js +0 -2
  136. package/dist/core/renderer/FrameRenderer.d.ts +0 -37
  137. package/dist/core/renderer/FrameRenderer.js +0 -75
  138. package/dist/core/renderer/ProgressReporter.d.ts +0 -19
  139. package/dist/core/renderer/ProgressReporter.js +0 -58
  140. package/dist/core/renderer/Renderer.d.ts +0 -36
  141. package/dist/core/renderer/Renderer.js +0 -102
  142. package/dist/core/renderer/drawMobject.d.ts +0 -8
  143. package/dist/core/renderer/drawMobject.js +0 -109
  144. package/dist/core/renderer/formats/index.d.ts +0 -3
  145. package/dist/core/renderer/formats/index.js +0 -3
  146. package/dist/core/renderer/formats/png.d.ts +0 -5
  147. package/dist/core/renderer/formats/png.js +0 -7
  148. package/dist/core/renderer/formats/sprite.d.ts +0 -6
  149. package/dist/core/renderer/formats/sprite.js +0 -24
  150. package/dist/core/renderer/formats/video.d.ts +0 -8
  151. package/dist/core/renderer/formats/video.js +0 -51
  152. package/dist/core/renderer/index.d.ts +0 -7
  153. package/dist/core/renderer/index.js +0 -9
  154. package/dist/core/renderer/types.d.ts +0 -87
  155. package/dist/core/renderer/types.js +0 -13
  156. package/dist/core/scene/Scene.d.ts +0 -104
  157. package/dist/core/scene/Scene.js +0 -225
  158. package/dist/core/scene/index.d.ts +0 -2
  159. package/dist/core/scene/index.js +0 -1
  160. package/dist/core/scene/types.d.ts +0 -23
  161. package/dist/core/scene/types.js +0 -0
  162. package/dist/core/serialization/animation.d.ts +0 -23
  163. package/dist/core/serialization/animation.js +0 -176
  164. package/dist/core/serialization/easingLookup.d.ts +0 -13
  165. package/dist/core/serialization/easingLookup.js +0 -65
  166. package/dist/core/serialization/index.d.ts +0 -23
  167. package/dist/core/serialization/index.js +0 -29
  168. package/dist/core/serialization/mobject.d.ts +0 -23
  169. package/dist/core/serialization/mobject.js +0 -248
  170. package/dist/core/serialization/prettyPrint.d.ts +0 -12
  171. package/dist/core/serialization/prettyPrint.js +0 -16
  172. package/dist/core/serialization/primitives.d.ts +0 -24
  173. package/dist/core/serialization/primitives.js +0 -98
  174. package/dist/core/serialization/registry.d.ts +0 -29
  175. package/dist/core/serialization/registry.js +0 -39
  176. package/dist/core/serialization/scene.d.ts +0 -28
  177. package/dist/core/serialization/scene.js +0 -114
  178. package/dist/core/serialization/types.d.ts +0 -152
  179. package/dist/core/serialization/types.js +0 -6
  180. package/dist/core/timeline/Timeline.d.ts +0 -70
  181. package/dist/core/timeline/Timeline.js +0 -144
  182. package/dist/core/timeline/index.d.ts +0 -5
  183. package/dist/core/timeline/index.js +0 -4
  184. package/dist/core/timeline/types.d.ts +0 -29
  185. package/dist/core/timeline/types.js +0 -0
  186. package/dist/mobjects/Mobject.d.ts +0 -98
  187. package/dist/mobjects/Mobject.js +0 -343
  188. package/dist/mobjects/VGroup/VGroup.d.ts +0 -51
  189. package/dist/mobjects/VGroup/VGroup.js +0 -142
  190. package/dist/mobjects/VGroup/index.d.ts +0 -3
  191. package/dist/mobjects/VGroup/index.js +0 -2
  192. package/dist/mobjects/VGroup/layout.d.ts +0 -20
  193. package/dist/mobjects/VGroup/layout.js +0 -139
  194. package/dist/mobjects/VMobject.d.ts +0 -106
  195. package/dist/mobjects/VMobject.js +0 -216
  196. package/dist/mobjects/geometry/Arc.d.ts +0 -8
  197. package/dist/mobjects/geometry/Arc.js +0 -46
  198. package/dist/mobjects/geometry/Arrow.d.ts +0 -7
  199. package/dist/mobjects/geometry/Arrow.js +0 -34
  200. package/dist/mobjects/geometry/Circle.d.ts +0 -4
  201. package/dist/mobjects/geometry/Circle.js +0 -10
  202. package/dist/mobjects/geometry/Line.d.ts +0 -8
  203. package/dist/mobjects/geometry/Line.js +0 -19
  204. package/dist/mobjects/geometry/Point.d.ts +0 -5
  205. package/dist/mobjects/geometry/Point.js +0 -11
  206. package/dist/mobjects/geometry/Polygon.d.ts +0 -7
  207. package/dist/mobjects/geometry/Polygon.js +0 -21
  208. package/dist/mobjects/geometry/Rectangle.d.ts +0 -6
  209. package/dist/mobjects/geometry/Rectangle.js +0 -18
  210. package/dist/mobjects/geometry/index.d.ts +0 -7
  211. package/dist/mobjects/geometry/index.js +0 -7
  212. package/dist/mobjects/graph/Graph.d.ts +0 -28
  213. package/dist/mobjects/graph/Graph.js +0 -119
  214. package/dist/mobjects/graph/GraphEdge.d.ts +0 -26
  215. package/dist/mobjects/graph/GraphEdge.js +0 -64
  216. package/dist/mobjects/graph/GraphNode.d.ts +0 -19
  217. package/dist/mobjects/graph/GraphNode.js +0 -63
  218. package/dist/mobjects/graph/index.d.ts +0 -5
  219. package/dist/mobjects/graph/index.js +0 -5
  220. package/dist/mobjects/graph/layouts/circular.d.ts +0 -8
  221. package/dist/mobjects/graph/layouts/circular.js +0 -23
  222. package/dist/mobjects/graph/layouts/forceDirected.d.ts +0 -9
  223. package/dist/mobjects/graph/layouts/forceDirected.js +0 -102
  224. package/dist/mobjects/graph/layouts/index.d.ts +0 -3
  225. package/dist/mobjects/graph/layouts/index.js +0 -3
  226. package/dist/mobjects/graph/layouts/tree.d.ts +0 -9
  227. package/dist/mobjects/graph/layouts/tree.js +0 -99
  228. package/dist/mobjects/graph/types.d.ts +0 -35
  229. package/dist/mobjects/graph/types.js +0 -0
  230. package/dist/mobjects/index.d.ts +0 -6
  231. package/dist/mobjects/index.js +0 -6
  232. package/dist/mobjects/text/Glyph.d.ts +0 -11
  233. package/dist/mobjects/text/Glyph.js +0 -72
  234. package/dist/mobjects/text/Text.d.ts +0 -19
  235. package/dist/mobjects/text/Text.js +0 -76
  236. package/dist/mobjects/text/index.d.ts +0 -4
  237. package/dist/mobjects/text/index.js +0 -3
  238. package/dist/mobjects/text/types.d.ts +0 -12
  239. package/dist/mobjects/text/types.js +0 -8
@@ -1,25 +0,0 @@
1
- /**
2
- * Registry for custom easing functions.
3
- * Allows users to register and retrieve custom easings by name.
4
- */
5
- const easingRegistry = new Map();
6
- /** @throws Error if an easing with the given name already exists. */
7
- export function registerEasing(name, fn) {
8
- if (easingRegistry.has(name)) {
9
- throw new Error(`Easing "${name}" is already registered.`);
10
- }
11
- easingRegistry.set(name, fn);
12
- }
13
- export function getEasing(name) {
14
- return easingRegistry.get(name);
15
- }
16
- export function hasEasing(name) {
17
- return easingRegistry.has(name);
18
- }
19
- export function unregisterEasing(name) {
20
- return easingRegistry.delete(name);
21
- }
22
- /** Clears all registered custom easings (useful for testing). */
23
- export function clearRegistry() {
24
- easingRegistry.clear();
25
- }
@@ -1,113 +0,0 @@
1
- import type { EasingFunction } from './types';
2
- /**
3
- * Linear easing (no easing, constant speed).
4
- */
5
- export declare const linear: EasingFunction;
6
- /**
7
- * Quadratic ease-in: slow start, accelerating.
8
- */
9
- export declare const easeInQuad: EasingFunction;
10
- /**
11
- * Quadratic ease-out: fast start, decelerating.
12
- */
13
- export declare const easeOutQuad: EasingFunction;
14
- /**
15
- * Quadratic ease-in-out: slow start and end.
16
- */
17
- export declare const easeInOutQuad: EasingFunction;
18
- /**
19
- * Cubic ease-in: slow start, accelerating.
20
- */
21
- export declare const easeInCubic: EasingFunction;
22
- /**
23
- * Cubic ease-out: fast start, decelerating.
24
- */
25
- export declare const easeOutCubic: EasingFunction;
26
- /**
27
- * Cubic ease-in-out: slow start and end.
28
- */
29
- export declare const easeInOutCubic: EasingFunction;
30
- /**
31
- * Quartic ease-in: slow start, accelerating.
32
- */
33
- export declare const easeInQuart: EasingFunction;
34
- /**
35
- * Quartic ease-out: fast start, decelerating.
36
- */
37
- export declare const easeOutQuart: EasingFunction;
38
- /**
39
- * Quartic ease-in-out: slow start and end.
40
- */
41
- export declare const easeInOutQuart: EasingFunction;
42
- /**
43
- * Quintic ease-in: slow start, accelerating.
44
- */
45
- export declare const easeInQuint: EasingFunction;
46
- /**
47
- * Quintic ease-out: fast start, decelerating.
48
- */
49
- export declare const easeOutQuint: EasingFunction;
50
- /**
51
- * Quintic ease-in-out: slow start and end.
52
- */
53
- export declare const easeInOutQuint: EasingFunction;
54
- /**
55
- * Sinusoidal ease-in: uses sine curve for smooth acceleration.
56
- */
57
- export declare const easeInSine: EasingFunction;
58
- /**
59
- * Sinusoidal ease-out: uses sine curve for smooth deceleration.
60
- */
61
- export declare const easeOutSine: EasingFunction;
62
- /**
63
- * Sinusoidal ease-in-out: smooth S-curve using sine.
64
- */
65
- export declare const easeInOutSine: EasingFunction;
66
- /**
67
- * Exponential ease-in: dramatic acceleration.
68
- */
69
- export declare const easeInExpo: EasingFunction;
70
- /**
71
- * Exponential ease-out: dramatic deceleration.
72
- */
73
- export declare const easeOutExpo: EasingFunction;
74
- /**
75
- * Exponential ease-in-out: dramatic S-curve.
76
- */
77
- export declare const easeInOutExpo: EasingFunction;
78
- /**
79
- * Circular ease-in: quarter circle acceleration.
80
- */
81
- export declare const easeInCirc: EasingFunction;
82
- /**
83
- * Circular ease-out: quarter circle deceleration.
84
- */
85
- export declare const easeOutCirc: EasingFunction;
86
- /**
87
- * Circular ease-in-out: half circle S-curve.
88
- */
89
- export declare const easeInOutCirc: EasingFunction;
90
- /**
91
- * Back ease-in: pulls back before accelerating forward.
92
- */
93
- export declare const easeInBack: EasingFunction;
94
- /**
95
- * Back ease-out: overshoots then settles.
96
- */
97
- export declare const easeOutBack: EasingFunction;
98
- /**
99
- * Back ease-in-out: pulls back, overshoots, then settles.
100
- */
101
- export declare const easeInOutBack: EasingFunction;
102
- /**
103
- * Elastic ease-in: builds up elastic energy.
104
- */
105
- export declare const easeInElastic: EasingFunction;
106
- /**
107
- * Elastic ease-out: releases elastic energy with overshoot oscillation.
108
- */
109
- export declare const easeOutElastic: EasingFunction;
110
- /**
111
- * Elastic ease-in-out: elastic effect on both ends.
112
- */
113
- export declare const easeInOutElastic: EasingFunction;
@@ -1,151 +0,0 @@
1
- /**
2
- * Linear easing (no easing, constant speed).
3
- */
4
- export const linear = (t) => t;
5
- // --- Quadratic ---
6
- /**
7
- * Quadratic ease-in: slow start, accelerating.
8
- */
9
- export const easeInQuad = (t) => t * t;
10
- /**
11
- * Quadratic ease-out: fast start, decelerating.
12
- */
13
- export const easeOutQuad = (t) => 1 - (1 - t) * (1 - t);
14
- /**
15
- * Quadratic ease-in-out: slow start and end.
16
- */
17
- export const easeInOutQuad = (t) => t < 0.5 ? 2 * t * t : 1 - Math.pow(-2 * t + 2, 2) / 2;
18
- // --- Cubic ---
19
- /**
20
- * Cubic ease-in: slow start, accelerating.
21
- */
22
- export const easeInCubic = (t) => t * t * t;
23
- /**
24
- * Cubic ease-out: fast start, decelerating.
25
- */
26
- export const easeOutCubic = (t) => 1 - Math.pow(1 - t, 3);
27
- /**
28
- * Cubic ease-in-out: slow start and end.
29
- */
30
- export const easeInOutCubic = (t) => t < 0.5 ? 4 * t * t * t : 1 - Math.pow(-2 * t + 2, 3) / 2;
31
- // --- Quartic ---
32
- /**
33
- * Quartic ease-in: slow start, accelerating.
34
- */
35
- export const easeInQuart = (t) => t * t * t * t;
36
- /**
37
- * Quartic ease-out: fast start, decelerating.
38
- */
39
- export const easeOutQuart = (t) => 1 - Math.pow(1 - t, 4);
40
- /**
41
- * Quartic ease-in-out: slow start and end.
42
- */
43
- export const easeInOutQuart = (t) => t < 0.5 ? 8 * t * t * t * t : 1 - Math.pow(-2 * t + 2, 4) / 2;
44
- // --- Quintic ---
45
- /**
46
- * Quintic ease-in: slow start, accelerating.
47
- */
48
- export const easeInQuint = (t) => t * t * t * t * t;
49
- /**
50
- * Quintic ease-out: fast start, decelerating.
51
- */
52
- export const easeOutQuint = (t) => 1 - Math.pow(1 - t, 5);
53
- /**
54
- * Quintic ease-in-out: slow start and end.
55
- */
56
- export const easeInOutQuint = (t) => t < 0.5 ? 16 * t * t * t * t * t : 1 - Math.pow(-2 * t + 2, 5) / 2;
57
- // --- Sinusoidal ---
58
- /**
59
- * Sinusoidal ease-in: uses sine curve for smooth acceleration.
60
- */
61
- export const easeInSine = (t) => 1 - Math.cos((t * Math.PI) / 2);
62
- /**
63
- * Sinusoidal ease-out: uses sine curve for smooth deceleration.
64
- */
65
- export const easeOutSine = (t) => Math.sin((t * Math.PI) / 2);
66
- /**
67
- * Sinusoidal ease-in-out: smooth S-curve using sine.
68
- */
69
- export const easeInOutSine = (t) => -(Math.cos(Math.PI * t) - 1) / 2;
70
- // --- Exponential ---
71
- /**
72
- * Exponential ease-in: dramatic acceleration.
73
- */
74
- export const easeInExpo = (t) => t === 0 ? 0 : Math.pow(2, 10 * t - 10);
75
- /**
76
- * Exponential ease-out: dramatic deceleration.
77
- */
78
- export const easeOutExpo = (t) => t === 1 ? 1 : 1 - Math.pow(2, -10 * t);
79
- /**
80
- * Exponential ease-in-out: dramatic S-curve.
81
- */
82
- export const easeInOutExpo = (t) => t === 0
83
- ? 0
84
- : t === 1
85
- ? 1
86
- : t < 0.5
87
- ? Math.pow(2, 20 * t - 10) / 2
88
- : (2 - Math.pow(2, -20 * t + 10)) / 2;
89
- // --- Circular ---
90
- /**
91
- * Circular ease-in: quarter circle acceleration.
92
- */
93
- export const easeInCirc = (t) => 1 - Math.sqrt(1 - t * t);
94
- /**
95
- * Circular ease-out: quarter circle deceleration.
96
- */
97
- export const easeOutCirc = (t) => Math.sqrt(1 - Math.pow(t - 1, 2));
98
- /**
99
- * Circular ease-in-out: half circle S-curve.
100
- */
101
- export const easeInOutCirc = (t) => t < 0.5
102
- ? (1 - Math.sqrt(1 - Math.pow(2 * t, 2))) / 2
103
- : (Math.sqrt(1 - Math.pow(-2 * t + 2, 2)) + 1) / 2;
104
- // --- Back (overshoots) ---
105
- const BACK_C1 = 1.70158;
106
- const BACK_C2 = BACK_C1 * 1.525;
107
- const BACK_C3 = BACK_C1 + 1;
108
- /**
109
- * Back ease-in: pulls back before accelerating forward.
110
- */
111
- export const easeInBack = (t) => BACK_C3 * t * t * t - BACK_C1 * t * t;
112
- /**
113
- * Back ease-out: overshoots then settles.
114
- */
115
- export const easeOutBack = (t) => 1 + BACK_C3 * Math.pow(t - 1, 3) + BACK_C1 * Math.pow(t - 1, 2);
116
- /**
117
- * Back ease-in-out: pulls back, overshoots, then settles.
118
- */
119
- export const easeInOutBack = (t) => t < 0.5
120
- ? (Math.pow(2 * t, 2) * ((BACK_C2 + 1) * 2 * t - BACK_C2)) / 2
121
- : (Math.pow(2 * t - 2, 2) * ((BACK_C2 + 1) * (t * 2 - 2) + BACK_C2) + 2) /
122
- 2;
123
- // --- Elastic ---
124
- const ELASTIC_C4 = (2 * Math.PI) / 3;
125
- const ELASTIC_C5 = (2 * Math.PI) / 4.5;
126
- /**
127
- * Elastic ease-in: builds up elastic energy.
128
- */
129
- export const easeInElastic = (t) => t === 0
130
- ? 0
131
- : t === 1
132
- ? 1
133
- : -Math.pow(2, 10 * t - 10) * Math.sin((t * 10 - 10.75) * ELASTIC_C4);
134
- /**
135
- * Elastic ease-out: releases elastic energy with overshoot oscillation.
136
- */
137
- export const easeOutElastic = (t) => t === 0
138
- ? 0
139
- : t === 1
140
- ? 1
141
- : Math.pow(2, -10 * t) * Math.sin((t * 10 - 0.75) * ELASTIC_C4) + 1;
142
- /**
143
- * Elastic ease-in-out: elastic effect on both ends.
144
- */
145
- export const easeInOutElastic = (t) => t === 0
146
- ? 0
147
- : t === 1
148
- ? 1
149
- : t < 0.5
150
- ? -(Math.pow(2, 20 * t - 10) * Math.sin((20 * t - 11.125) * ELASTIC_C5)) / 2
151
- : (Math.pow(2, -20 * t + 10) * Math.sin((20 * t - 11.125) * ELASTIC_C5)) / 2 + 1;
@@ -1,6 +0,0 @@
1
- /**
2
- * Type signature for an easing function.
3
- * Maps a progress value t ∈ [0, 1] to an eased value.
4
- * Must satisfy: f(0) = 0 and f(1) = 1
5
- */
6
- export type EasingFunction = (t: number) => number;
File without changes
@@ -1,17 +0,0 @@
1
- import { IntroductoryAnimation } from '../categories';
2
- import type { Mobject } from '../../../mobjects/Mobject';
3
- /**
4
- * Animation that fades a Mobject in by increasing its opacity from 0 to 1.
5
- *
6
- * This is an introductory animation - it auto-registers the target with the scene.
7
- * You do not need to call scene.add() before using FadeIn.
8
- *
9
- * @example
10
- * const circle = new Circle(1);
11
- * scene.play(new FadeIn(circle)); // Circle is auto-registered and faded in
12
- */
13
- export declare class FadeIn<T extends Mobject = Mobject> extends IntroductoryAnimation<T> {
14
- private readonly startOpacity;
15
- constructor(target: T);
16
- interpolate(progress: number): void;
17
- }
@@ -1,22 +0,0 @@
1
- import { IntroductoryAnimation } from '../categories';
2
- /**
3
- * Animation that fades a Mobject in by increasing its opacity from 0 to 1.
4
- *
5
- * This is an introductory animation - it auto-registers the target with the scene.
6
- * You do not need to call scene.add() before using FadeIn.
7
- *
8
- * @example
9
- * const circle = new Circle(1);
10
- * scene.play(new FadeIn(circle)); // Circle is auto-registered and faded in
11
- */
12
- export class FadeIn extends IntroductoryAnimation {
13
- startOpacity;
14
- constructor(target) {
15
- super(target);
16
- this.startOpacity = target.opacity;
17
- }
18
- interpolate(progress) {
19
- const newOpacity = this.startOpacity + (1 - this.startOpacity) * progress;
20
- this.target.setOpacity(newOpacity);
21
- }
22
- }
@@ -1,17 +0,0 @@
1
- import { ExitAnimation } from '../categories';
2
- import type { Mobject } from '../../../mobjects/Mobject';
3
- /**
4
- * Animation that fades a Mobject out by decreasing its opacity to 0.
5
- *
6
- * This is an exit animation - the target must already be in the scene.
7
- * The starting opacity is captured when the animation first runs,
8
- * not when it's constructed, so it correctly fades from the current opacity.
9
- *
10
- * @example
11
- * scene.add(circle);
12
- * scene.play(new FadeOut(circle)); // Circle fades out
13
- */
14
- export declare class FadeOut<T extends Mobject = Mobject> extends ExitAnimation<T> {
15
- private startOpacity;
16
- interpolate(progress: number): void;
17
- }
@@ -1,23 +0,0 @@
1
- import { ExitAnimation } from '../categories';
2
- /**
3
- * Animation that fades a Mobject out by decreasing its opacity to 0.
4
- *
5
- * This is an exit animation - the target must already be in the scene.
6
- * The starting opacity is captured when the animation first runs,
7
- * not when it's constructed, so it correctly fades from the current opacity.
8
- *
9
- * @example
10
- * scene.add(circle);
11
- * scene.play(new FadeOut(circle)); // Circle fades out
12
- */
13
- export class FadeOut extends ExitAnimation {
14
- startOpacity = null;
15
- interpolate(progress) {
16
- // Capture opacity on first call (when animation actually runs)
17
- if (this.startOpacity === null) {
18
- this.startOpacity = this.target.opacity;
19
- }
20
- const newOpacity = this.startOpacity * (1 - progress);
21
- this.target.setOpacity(newOpacity);
22
- }
23
- }
@@ -1,2 +0,0 @@
1
- export { FadeIn } from './FadeIn';
2
- export { FadeOut } from './FadeOut';
@@ -1,2 +0,0 @@
1
- export { FadeIn } from './FadeIn';
2
- export { FadeOut } from './FadeOut';
@@ -1,11 +0,0 @@
1
- export { Animation } from './Animation';
2
- export { FadeIn, FadeOut } from './fade';
3
- export { MoveTo, Rotate, Scale } from './transform';
4
- export { MorphTo } from './morph';
5
- export { Draw, Write, Unwrite } from './draw';
6
- export { Sequence, Parallel } from './composition';
7
- export { KeyframeTrack, KeyframeAnimation } from './keyframes';
8
- export type { Keyframe } from './keyframes';
9
- export { Follow, Shake } from './camera';
10
- export type { AnimationConfig, FluentConfig, AnimationFactory, QueuedAnimation, QueuedPrebuilt, QueueEntry, } from './types';
11
- export { DEFAULT_DURATION, isPrebuilt } from './types';
@@ -1,17 +0,0 @@
1
- // Animation base class
2
- export { Animation } from './Animation';
3
- // Fade animations
4
- export { FadeIn, FadeOut } from './fade';
5
- // Transform animations
6
- export { MoveTo, Rotate, Scale } from './transform';
7
- // Morph animations
8
- export { MorphTo } from './morph';
9
- // Draw animations
10
- export { Draw, Write, Unwrite } from './draw';
11
- // Composition containers
12
- export { Sequence, Parallel } from './composition';
13
- // Keyframes
14
- export { KeyframeTrack, KeyframeAnimation } from './keyframes';
15
- // Camera animations
16
- export { Follow, Shake } from './camera';
17
- export { DEFAULT_DURATION, isPrebuilt } from './types';
@@ -1,33 +0,0 @@
1
- import { Animation } from '../Animation';
2
- import type { AnimationLifecycle } from '../types';
3
- import type { Mobject } from '../../../mobjects/Mobject';
4
- import { KeyframeTrack } from './KeyframeTrack';
5
- import type { KeyframeValue } from './types';
6
- /**
7
- * Property setter function type for applying values to a Mobject.
8
- */
9
- type PropertySetter<T extends Mobject, V> = (target: T, value: V) => void;
10
- /**
11
- * Animation that interpolates multiple property tracks via keyframes.
12
- * Each track controls a single property and is interpolated independently.
13
- *
14
- * This is a transformative animation - the target must already be in the scene.
15
- */
16
- export declare class KeyframeAnimation<T extends Mobject = Mobject> extends Animation<T> {
17
- private readonly tracks;
18
- readonly lifecycle: AnimationLifecycle;
19
- /**
20
- * Adds a named keyframe track with its property setter.
21
- * The setter is called during interpolation to apply values to the target.
22
- */
23
- addTrack<V extends KeyframeValue>(name: string, track: KeyframeTrack<V>, setter: PropertySetter<T, V>): this;
24
- /** Gets a track by name. */
25
- getTrack<V extends KeyframeValue>(name: string): KeyframeTrack<V> | undefined;
26
- /** All track names. */
27
- getTrackNames(): string[];
28
- /**
29
- * Interpolates all tracks at the given progress and applies values to target.
30
- */
31
- interpolate(progress: number): void;
32
- }
33
- export {};
@@ -1,40 +0,0 @@
1
- import { Animation } from '../Animation';
2
- /**
3
- * Animation that interpolates multiple property tracks via keyframes.
4
- * Each track controls a single property and is interpolated independently.
5
- *
6
- * This is a transformative animation - the target must already be in the scene.
7
- */
8
- export class KeyframeAnimation extends Animation {
9
- tracks = new Map();
10
- lifecycle = 'transformative';
11
- /**
12
- * Adds a named keyframe track with its property setter.
13
- * The setter is called during interpolation to apply values to the target.
14
- */
15
- addTrack(name, track, setter) {
16
- this.tracks.set(name, {
17
- track: track,
18
- setter: setter,
19
- });
20
- return this;
21
- }
22
- /** Gets a track by name. */
23
- getTrack(name) {
24
- const entry = this.tracks.get(name);
25
- return entry?.track;
26
- }
27
- /** All track names. */
28
- getTrackNames() {
29
- return Array.from(this.tracks.keys());
30
- }
31
- /**
32
- * Interpolates all tracks at the given progress and applies values to target.
33
- */
34
- interpolate(progress) {
35
- for (const entry of this.tracks.values()) {
36
- const value = entry.track.getValueAt(progress);
37
- entry.setter(this.target, value);
38
- }
39
- }
40
- }
@@ -1,31 +0,0 @@
1
- import type { EasingFunction } from '../easing';
2
- import type { Keyframe, KeyframeValue, InterpolatorFn } from './types';
3
- /**
4
- * Manages a sequence of keyframes for animating a single property.
5
- * Keyframes are stored sorted by time and interpolated on demand.
6
- */
7
- export declare class KeyframeTrack<T extends KeyframeValue = number> {
8
- private keyframes;
9
- private readonly interpolator;
10
- /**
11
- * Creates a new KeyframeTrack with the specified interpolator.
12
- * Defaults to linear number interpolation.
13
- */
14
- constructor(interpolator?: InterpolatorFn<T>);
15
- /**
16
- * Adds a keyframe at the specified normalized time.
17
- * Time must be in [0, 1]. Replaces existing keyframe at same time.
18
- */
19
- addKeyframe(time: number, value: T, easing?: EasingFunction): this;
20
- removeKeyframe(time: number): boolean;
21
- /**
22
- * Gets the keyframe at the specified time.
23
- * Returns undefined if no keyframe exists at that time.
24
- */
25
- getKeyframe(time: number): Keyframe<T> | undefined;
26
- /** All keyframes sorted by time. */
27
- getKeyframes(): ReadonlyArray<Keyframe<T>>;
28
- /** Interpolated value at normalized time (uses target keyframe easing). */
29
- getValueAt(time: number): T;
30
- getKeyframeCount(): number;
31
- }
@@ -1,83 +0,0 @@
1
- import { linear } from '../easing';
2
- import { lerpNumber } from './types';
3
- /**
4
- * Manages a sequence of keyframes for animating a single property.
5
- * Keyframes are stored sorted by time and interpolated on demand.
6
- */
7
- export class KeyframeTrack {
8
- keyframes = [];
9
- interpolator;
10
- /**
11
- * Creates a new KeyframeTrack with the specified interpolator.
12
- * Defaults to linear number interpolation.
13
- */
14
- constructor(interpolator) {
15
- this.interpolator = interpolator ?? lerpNumber;
16
- }
17
- /**
18
- * Adds a keyframe at the specified normalized time.
19
- * Time must be in [0, 1]. Replaces existing keyframe at same time.
20
- */
21
- addKeyframe(time, value, easing) {
22
- if (time < 0 || time > 1) {
23
- throw new Error('Keyframe time must be in [0, 1]');
24
- }
25
- // Remove existing keyframe at same time
26
- this.keyframes = this.keyframes.filter((kf) => kf.time !== time);
27
- const keyframe = { time, value, easing };
28
- this.keyframes.push(keyframe);
29
- this.keyframes.sort((a, b) => a.time - b.time);
30
- return this;
31
- }
32
- removeKeyframe(time) {
33
- const initialLength = this.keyframes.length;
34
- this.keyframes = this.keyframes.filter((kf) => kf.time !== time);
35
- return this.keyframes.length < initialLength;
36
- }
37
- /**
38
- * Gets the keyframe at the specified time.
39
- * Returns undefined if no keyframe exists at that time.
40
- */
41
- getKeyframe(time) {
42
- return this.keyframes.find((kf) => kf.time === time);
43
- }
44
- /** All keyframes sorted by time. */
45
- getKeyframes() {
46
- return this.keyframes;
47
- }
48
- /** Interpolated value at normalized time (uses target keyframe easing). */
49
- getValueAt(time) {
50
- if (this.keyframes.length === 0) {
51
- throw new Error('KeyframeTrack has no keyframes');
52
- }
53
- const clampedTime = Math.max(0, Math.min(1, time));
54
- // Find keyframes before and after the requested time
55
- let prevKeyframe;
56
- let nextKeyframe;
57
- for (const kf of this.keyframes) {
58
- if (kf.time <= clampedTime) {
59
- prevKeyframe = kf;
60
- }
61
- if (kf.time >= clampedTime && nextKeyframe === undefined) {
62
- nextKeyframe = kf;
63
- }
64
- }
65
- if (prevKeyframe === undefined) {
66
- return this.keyframes[0].value;
67
- }
68
- if (nextKeyframe === undefined) {
69
- return prevKeyframe.value;
70
- }
71
- if (prevKeyframe === nextKeyframe) {
72
- return prevKeyframe.value;
73
- }
74
- const span = nextKeyframe.time - prevKeyframe.time;
75
- const localProgress = (clampedTime - prevKeyframe.time) / span;
76
- const easing = nextKeyframe.easing ?? linear;
77
- const easedProgress = easing(localProgress);
78
- return this.interpolator(prevKeyframe.value, nextKeyframe.value, easedProgress);
79
- }
80
- getKeyframeCount() {
81
- return this.keyframes.length;
82
- }
83
- }
@@ -1,4 +0,0 @@
1
- export type { Keyframe, KeyframeValue, InterpolatorFn } from './types';
2
- export { lerpNumber } from './types';
3
- export { KeyframeTrack } from './KeyframeTrack';
4
- export { KeyframeAnimation } from './KeyframeAnimation';
@@ -1,5 +0,0 @@
1
- export { lerpNumber } from './types';
2
- // Keyframe track
3
- export { KeyframeTrack } from './KeyframeTrack';
4
- // Keyframe animation
5
- export { KeyframeAnimation } from './KeyframeAnimation';
@@ -1,25 +0,0 @@
1
- import type { EasingFunction } from '../easing';
2
- /**
3
- * Supported value types for keyframe interpolation.
4
- */
5
- export type KeyframeValue = number;
6
- /**
7
- * A single keyframe with a normalized time position [0,1] and value.
8
- */
9
- export interface Keyframe<T extends KeyframeValue = KeyframeValue> {
10
- /** Normalized time position in [0, 1]. */
11
- readonly time: number;
12
- /** The value at this keyframe. */
13
- readonly value: T;
14
- /** Optional easing function for interpolation TO this keyframe. */
15
- readonly easing?: EasingFunction;
16
- }
17
- /**
18
- * Interpolation function for a specific value type.
19
- * Takes start value, end value, and progress [0,1], returns interpolated value.
20
- */
21
- export type InterpolatorFn<T> = (start: T, end: T, progress: number) => T;
22
- /**
23
- * Default numeric interpolation (linear).
24
- */
25
- export declare function lerpNumber(a: number, b: number, t: number): number;
@@ -1,6 +0,0 @@
1
- /**
2
- * Default numeric interpolation (linear).
3
- */
4
- export function lerpNumber(a, b, t) {
5
- return a + (b - a) * t;
6
- }