@redwilly/anima 0.1.0

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/SceneLoader.d.ts +22 -0
  2. package/dist/cli/SceneLoader.js +47 -0
  3. package/dist/cli/commands/export-frame.d.ts +13 -0
  4. package/dist/cli/commands/export-frame.js +60 -0
  5. package/dist/cli/commands/list-scenes.d.ts +5 -0
  6. package/dist/cli/commands/list-scenes.js +22 -0
  7. package/dist/cli/commands/preview.d.ts +5 -0
  8. package/dist/cli/commands/preview.js +11 -0
  9. package/dist/cli/commands/render.d.ts +16 -0
  10. package/dist/cli/commands/render.js +76 -0
  11. package/dist/cli/index.d.ts +2 -0
  12. package/dist/cli/index.js +63 -0
  13. package/dist/core/animations/Animation.d.ts +41 -0
  14. package/dist/core/animations/Animation.js +76 -0
  15. package/dist/core/animations/camera/Follow.d.ts +70 -0
  16. package/dist/core/animations/camera/Follow.js +69 -0
  17. package/dist/core/animations/camera/Shake.d.ts +90 -0
  18. package/dist/core/animations/camera/Shake.js +87 -0
  19. package/dist/core/animations/camera/index.d.ts +2 -0
  20. package/dist/core/animations/camera/index.js +2 -0
  21. package/dist/core/animations/categories/ExitAnimation.d.ts +17 -0
  22. package/dist/core/animations/categories/ExitAnimation.js +15 -0
  23. package/dist/core/animations/categories/IntroductoryAnimation.d.ts +16 -0
  24. package/dist/core/animations/categories/IntroductoryAnimation.js +14 -0
  25. package/dist/core/animations/categories/TransformativeAnimation.d.ts +25 -0
  26. package/dist/core/animations/categories/TransformativeAnimation.js +25 -0
  27. package/dist/core/animations/categories/index.d.ts +3 -0
  28. package/dist/core/animations/categories/index.js +3 -0
  29. package/dist/core/animations/composition/Parallel.d.ts +37 -0
  30. package/dist/core/animations/composition/Parallel.js +79 -0
  31. package/dist/core/animations/composition/Sequence.d.ts +41 -0
  32. package/dist/core/animations/composition/Sequence.js +95 -0
  33. package/dist/core/animations/composition/index.d.ts +2 -0
  34. package/dist/core/animations/composition/index.js +3 -0
  35. package/dist/core/animations/draw/Draw.d.ts +30 -0
  36. package/dist/core/animations/draw/Draw.js +122 -0
  37. package/dist/core/animations/draw/Unwrite.d.ts +30 -0
  38. package/dist/core/animations/draw/Unwrite.js +120 -0
  39. package/dist/core/animations/draw/Write.d.ts +35 -0
  40. package/dist/core/animations/draw/Write.js +119 -0
  41. package/dist/core/animations/draw/index.d.ts +3 -0
  42. package/dist/core/animations/draw/index.js +3 -0
  43. package/dist/core/animations/draw/partialPath.d.ts +6 -0
  44. package/dist/core/animations/draw/partialPath.js +138 -0
  45. package/dist/core/animations/easing/bounce.d.ts +13 -0
  46. package/dist/core/animations/easing/bounce.js +37 -0
  47. package/dist/core/animations/easing/index.d.ts +7 -0
  48. package/dist/core/animations/easing/index.js +11 -0
  49. package/dist/core/animations/easing/manim.d.ts +46 -0
  50. package/dist/core/animations/easing/manim.js +102 -0
  51. package/dist/core/animations/easing/registry.d.ts +8 -0
  52. package/dist/core/animations/easing/registry.js +25 -0
  53. package/dist/core/animations/easing/standard.d.ts +113 -0
  54. package/dist/core/animations/easing/standard.js +151 -0
  55. package/dist/core/animations/easing/types.d.ts +6 -0
  56. package/dist/core/animations/easing/types.js +0 -0
  57. package/dist/core/animations/fade/FadeIn.d.ts +17 -0
  58. package/dist/core/animations/fade/FadeIn.js +22 -0
  59. package/dist/core/animations/fade/FadeOut.d.ts +17 -0
  60. package/dist/core/animations/fade/FadeOut.js +23 -0
  61. package/dist/core/animations/fade/index.d.ts +2 -0
  62. package/dist/core/animations/fade/index.js +2 -0
  63. package/dist/core/animations/index.d.ts +11 -0
  64. package/dist/core/animations/index.js +17 -0
  65. package/dist/core/animations/keyframes/KeyframeAnimation.d.ts +33 -0
  66. package/dist/core/animations/keyframes/KeyframeAnimation.js +40 -0
  67. package/dist/core/animations/keyframes/KeyframeTrack.d.ts +31 -0
  68. package/dist/core/animations/keyframes/KeyframeTrack.js +83 -0
  69. package/dist/core/animations/keyframes/index.d.ts +4 -0
  70. package/dist/core/animations/keyframes/index.js +5 -0
  71. package/dist/core/animations/keyframes/types.d.ts +25 -0
  72. package/dist/core/animations/keyframes/types.js +6 -0
  73. package/dist/core/animations/morph/MorphTo.d.ts +22 -0
  74. package/dist/core/animations/morph/MorphTo.js +42 -0
  75. package/dist/core/animations/morph/index.d.ts +1 -0
  76. package/dist/core/animations/morph/index.js +1 -0
  77. package/dist/core/animations/transform/MoveTo.d.ts +24 -0
  78. package/dist/core/animations/transform/MoveTo.js +38 -0
  79. package/dist/core/animations/transform/Rotate.d.ts +23 -0
  80. package/dist/core/animations/transform/Rotate.js +34 -0
  81. package/dist/core/animations/transform/Scale.d.ts +23 -0
  82. package/dist/core/animations/transform/Scale.js +35 -0
  83. package/dist/core/animations/transform/index.d.ts +3 -0
  84. package/dist/core/animations/transform/index.js +3 -0
  85. package/dist/core/animations/types.d.ts +52 -0
  86. package/dist/core/animations/types.js +6 -0
  87. package/dist/core/camera/Camera.d.ts +87 -0
  88. package/dist/core/camera/Camera.js +175 -0
  89. package/dist/core/camera/CameraFrame.d.ts +242 -0
  90. package/dist/core/camera/CameraFrame.js +322 -0
  91. package/dist/core/camera/index.d.ts +4 -0
  92. package/dist/core/camera/index.js +3 -0
  93. package/dist/core/camera/types.d.ts +17 -0
  94. package/dist/core/camera/types.js +1 -0
  95. package/dist/core/errors/AnimationErrors.d.ts +12 -0
  96. package/dist/core/errors/AnimationErrors.js +37 -0
  97. package/dist/core/errors/index.d.ts +1 -0
  98. package/dist/core/errors/index.js +1 -0
  99. package/dist/core/math/Vector2/Vector2.d.ts +23 -0
  100. package/dist/core/math/Vector2/Vector2.js +46 -0
  101. package/dist/core/math/Vector2/index.d.ts +1 -0
  102. package/dist/core/math/Vector2/index.js +1 -0
  103. package/dist/core/math/bezier/BezierPath.d.ts +38 -0
  104. package/dist/core/math/bezier/BezierPath.js +264 -0
  105. package/dist/core/math/bezier/evaluators.d.ts +9 -0
  106. package/dist/core/math/bezier/evaluators.js +36 -0
  107. package/dist/core/math/bezier/index.d.ts +8 -0
  108. package/dist/core/math/bezier/index.js +6 -0
  109. package/dist/core/math/bezier/length.d.ts +5 -0
  110. package/dist/core/math/bezier/length.js +27 -0
  111. package/dist/core/math/bezier/morphing.d.ts +16 -0
  112. package/dist/core/math/bezier/morphing.js +151 -0
  113. package/dist/core/math/bezier/sampling.d.ts +7 -0
  114. package/dist/core/math/bezier/sampling.js +153 -0
  115. package/dist/core/math/bezier/split.d.ts +19 -0
  116. package/dist/core/math/bezier/split.js +44 -0
  117. package/dist/core/math/bezier/types.d.ts +8 -0
  118. package/dist/core/math/bezier/types.js +0 -0
  119. package/dist/core/math/color/Color.d.ts +28 -0
  120. package/dist/core/math/color/Color.js +60 -0
  121. package/dist/core/math/color/conversions.d.ts +17 -0
  122. package/dist/core/math/color/conversions.js +100 -0
  123. package/dist/core/math/color/index.d.ts +2 -0
  124. package/dist/core/math/color/index.js +2 -0
  125. package/dist/core/math/index.d.ts +4 -0
  126. package/dist/core/math/index.js +5 -0
  127. package/dist/core/math/matrix/Matrix3x3.d.ts +23 -0
  128. package/dist/core/math/matrix/Matrix3x3.js +91 -0
  129. package/dist/core/math/matrix/factories.d.ts +12 -0
  130. package/dist/core/math/matrix/factories.js +44 -0
  131. package/dist/core/math/matrix/index.d.ts +2 -0
  132. package/dist/core/math/matrix/index.js +2 -0
  133. package/dist/core/renderer/FrameRenderer.d.ts +37 -0
  134. package/dist/core/renderer/FrameRenderer.js +75 -0
  135. package/dist/core/renderer/ProgressReporter.d.ts +19 -0
  136. package/dist/core/renderer/ProgressReporter.js +58 -0
  137. package/dist/core/renderer/Renderer.d.ts +36 -0
  138. package/dist/core/renderer/Renderer.js +102 -0
  139. package/dist/core/renderer/drawMobject.d.ts +8 -0
  140. package/dist/core/renderer/drawMobject.js +109 -0
  141. package/dist/core/renderer/formats/index.d.ts +3 -0
  142. package/dist/core/renderer/formats/index.js +3 -0
  143. package/dist/core/renderer/formats/png.d.ts +5 -0
  144. package/dist/core/renderer/formats/png.js +7 -0
  145. package/dist/core/renderer/formats/sprite.d.ts +6 -0
  146. package/dist/core/renderer/formats/sprite.js +24 -0
  147. package/dist/core/renderer/formats/video.d.ts +8 -0
  148. package/dist/core/renderer/formats/video.js +51 -0
  149. package/dist/core/renderer/index.d.ts +7 -0
  150. package/dist/core/renderer/index.js +9 -0
  151. package/dist/core/renderer/types.d.ts +87 -0
  152. package/dist/core/renderer/types.js +13 -0
  153. package/dist/core/scene/Scene.d.ts +104 -0
  154. package/dist/core/scene/Scene.js +225 -0
  155. package/dist/core/scene/index.d.ts +2 -0
  156. package/dist/core/scene/index.js +1 -0
  157. package/dist/core/scene/types.d.ts +23 -0
  158. package/dist/core/scene/types.js +0 -0
  159. package/dist/core/serialization/animation.d.ts +23 -0
  160. package/dist/core/serialization/animation.js +176 -0
  161. package/dist/core/serialization/easingLookup.d.ts +13 -0
  162. package/dist/core/serialization/easingLookup.js +65 -0
  163. package/dist/core/serialization/index.d.ts +23 -0
  164. package/dist/core/serialization/index.js +29 -0
  165. package/dist/core/serialization/mobject.d.ts +23 -0
  166. package/dist/core/serialization/mobject.js +248 -0
  167. package/dist/core/serialization/prettyPrint.d.ts +12 -0
  168. package/dist/core/serialization/prettyPrint.js +16 -0
  169. package/dist/core/serialization/primitives.d.ts +24 -0
  170. package/dist/core/serialization/primitives.js +98 -0
  171. package/dist/core/serialization/registry.d.ts +29 -0
  172. package/dist/core/serialization/registry.js +39 -0
  173. package/dist/core/serialization/scene.d.ts +28 -0
  174. package/dist/core/serialization/scene.js +114 -0
  175. package/dist/core/serialization/types.d.ts +152 -0
  176. package/dist/core/serialization/types.js +6 -0
  177. package/dist/core/timeline/Timeline.d.ts +70 -0
  178. package/dist/core/timeline/Timeline.js +144 -0
  179. package/dist/core/timeline/index.d.ts +5 -0
  180. package/dist/core/timeline/index.js +4 -0
  181. package/dist/core/timeline/types.d.ts +29 -0
  182. package/dist/core/timeline/types.js +0 -0
  183. package/dist/index.d.ts +18 -0
  184. package/dist/index.js +22 -0
  185. package/dist/mobjects/Mobject.d.ts +98 -0
  186. package/dist/mobjects/Mobject.js +343 -0
  187. package/dist/mobjects/VGroup/VGroup.d.ts +51 -0
  188. package/dist/mobjects/VGroup/VGroup.js +142 -0
  189. package/dist/mobjects/VGroup/index.d.ts +3 -0
  190. package/dist/mobjects/VGroup/index.js +2 -0
  191. package/dist/mobjects/VGroup/layout.d.ts +20 -0
  192. package/dist/mobjects/VGroup/layout.js +139 -0
  193. package/dist/mobjects/VMobject.d.ts +106 -0
  194. package/dist/mobjects/VMobject.js +216 -0
  195. package/dist/mobjects/geometry/Arc.d.ts +8 -0
  196. package/dist/mobjects/geometry/Arc.js +46 -0
  197. package/dist/mobjects/geometry/Arrow.d.ts +7 -0
  198. package/dist/mobjects/geometry/Arrow.js +34 -0
  199. package/dist/mobjects/geometry/Circle.d.ts +4 -0
  200. package/dist/mobjects/geometry/Circle.js +10 -0
  201. package/dist/mobjects/geometry/Line.d.ts +8 -0
  202. package/dist/mobjects/geometry/Line.js +19 -0
  203. package/dist/mobjects/geometry/Point.d.ts +5 -0
  204. package/dist/mobjects/geometry/Point.js +11 -0
  205. package/dist/mobjects/geometry/Polygon.d.ts +7 -0
  206. package/dist/mobjects/geometry/Polygon.js +21 -0
  207. package/dist/mobjects/geometry/Rectangle.d.ts +6 -0
  208. package/dist/mobjects/geometry/Rectangle.js +18 -0
  209. package/dist/mobjects/geometry/index.d.ts +7 -0
  210. package/dist/mobjects/geometry/index.js +7 -0
  211. package/dist/mobjects/graph/Graph.d.ts +28 -0
  212. package/dist/mobjects/graph/Graph.js +119 -0
  213. package/dist/mobjects/graph/GraphEdge.d.ts +26 -0
  214. package/dist/mobjects/graph/GraphEdge.js +64 -0
  215. package/dist/mobjects/graph/GraphNode.d.ts +19 -0
  216. package/dist/mobjects/graph/GraphNode.js +63 -0
  217. package/dist/mobjects/graph/index.d.ts +5 -0
  218. package/dist/mobjects/graph/index.js +5 -0
  219. package/dist/mobjects/graph/layouts/circular.d.ts +8 -0
  220. package/dist/mobjects/graph/layouts/circular.js +23 -0
  221. package/dist/mobjects/graph/layouts/forceDirected.d.ts +9 -0
  222. package/dist/mobjects/graph/layouts/forceDirected.js +102 -0
  223. package/dist/mobjects/graph/layouts/index.d.ts +3 -0
  224. package/dist/mobjects/graph/layouts/index.js +3 -0
  225. package/dist/mobjects/graph/layouts/tree.d.ts +9 -0
  226. package/dist/mobjects/graph/layouts/tree.js +99 -0
  227. package/dist/mobjects/graph/types.d.ts +35 -0
  228. package/dist/mobjects/graph/types.js +0 -0
  229. package/dist/mobjects/index.d.ts +6 -0
  230. package/dist/mobjects/index.js +6 -0
  231. package/dist/mobjects/text/Glyph.d.ts +11 -0
  232. package/dist/mobjects/text/Glyph.js +72 -0
  233. package/dist/mobjects/text/Text.d.ts +19 -0
  234. package/dist/mobjects/text/Text.js +76 -0
  235. package/dist/mobjects/text/index.d.ts +4 -0
  236. package/dist/mobjects/text/index.js +3 -0
  237. package/dist/mobjects/text/types.d.ts +12 -0
  238. package/dist/mobjects/text/types.js +8 -0
  239. package/package.json +51 -0
@@ -0,0 +1,46 @@
1
+ import type { EasingFunction } from './types';
2
+ /**
3
+ * Smooth S-curve using cubic smoothstep.
4
+ * This is the DEFAULT easing for all Manim animations.
5
+ * Formula: 3t² - 2t³
6
+ */
7
+ export declare const smooth: EasingFunction;
8
+ /**
9
+ * Applies smooth twice for extra smoothness.
10
+ * Creates an even more gradual transition at the endpoints.
11
+ */
12
+ export declare const doubleSmooth: EasingFunction;
13
+ /**
14
+ * Starts fast, decelerates at end (rush into the destination).
15
+ * Uses sqrt for fast start that slows down.
16
+ */
17
+ export declare const rushInto: EasingFunction;
18
+ /**
19
+ * Slow start, accelerates from beginning (rush from the start).
20
+ * Uses quadratic for slow start that speeds up.
21
+ */
22
+ export declare const rushFrom: EasingFunction;
23
+ /**
24
+ * Starts normal, slows into the end.
25
+ */
26
+ export declare const slowInto: EasingFunction;
27
+ /**
28
+ * Goes from 0 to 1 and back to 0.
29
+ * Useful for temporary effects.
30
+ */
31
+ export declare const thereAndBack: EasingFunction;
32
+ /** Goes from 0 to 1 and back to 0 with a pause at the peak. */
33
+ export declare function thereAndBackWithPause(pauseRatio?: number): EasingFunction;
34
+ /** Overshoots slightly then settles (like a running start). */
35
+ export declare function runningStart(pullFactor?: number): EasingFunction;
36
+ /**
37
+ * Oscillates back and forth (wiggle/shake effect).
38
+ * Creates a wobbling motion that ends at 1.
39
+ */
40
+ export declare const wiggle: EasingFunction;
41
+ /** Approaches but doesn't quite reach 1 (asymptotic approach). */
42
+ export declare function notQuiteThere(proportion?: number): EasingFunction;
43
+ /** Reaches the destination early and stays there. */
44
+ export declare function lingering(proportion?: number): EasingFunction;
45
+ /** Asymptotically approaches 1 via exponential decay. */
46
+ export declare function exponentialDecay(halfLife?: number): EasingFunction;
@@ -0,0 +1,102 @@
1
+ /**
2
+ * Smooth S-curve using cubic smoothstep.
3
+ * This is the DEFAULT easing for all Manim animations.
4
+ * Formula: 3t² - 2t³
5
+ */
6
+ export const smooth = (t) => {
7
+ const s = t * t * (3 - 2 * t);
8
+ return s;
9
+ };
10
+ /**
11
+ * Applies smooth twice for extra smoothness.
12
+ * Creates an even more gradual transition at the endpoints.
13
+ */
14
+ export const doubleSmooth = (t) => smooth(smooth(t));
15
+ /**
16
+ * Starts fast, decelerates at end (rush into the destination).
17
+ * Uses sqrt for fast start that slows down.
18
+ */
19
+ export const rushInto = (t) => {
20
+ return 1 - Math.pow(1 - t, 2);
21
+ };
22
+ /**
23
+ * Slow start, accelerates from beginning (rush from the start).
24
+ * Uses quadratic for slow start that speeds up.
25
+ */
26
+ export const rushFrom = (t) => {
27
+ return Math.pow(t, 2);
28
+ };
29
+ /**
30
+ * Starts normal, slows into the end.
31
+ */
32
+ export const slowInto = (t) => {
33
+ return Math.sqrt(t);
34
+ };
35
+ /**
36
+ * Goes from 0 to 1 and back to 0.
37
+ * Useful for temporary effects.
38
+ */
39
+ export const thereAndBack = (t) => {
40
+ const mapped = 2 * t;
41
+ if (t < 0.5) {
42
+ return smooth(mapped);
43
+ }
44
+ return smooth(2 - mapped);
45
+ };
46
+ /** Goes from 0 to 1 and back to 0 with a pause at the peak. */
47
+ export function thereAndBackWithPause(pauseRatio = 1 / 3) {
48
+ const a = pauseRatio / 2;
49
+ return (t) => {
50
+ if (t < 0.5 - a) {
51
+ return smooth(t / (0.5 - a));
52
+ }
53
+ else if (t < 0.5 + a) {
54
+ return 1;
55
+ }
56
+ else {
57
+ return smooth((1 - t) / (0.5 - a));
58
+ }
59
+ };
60
+ }
61
+ /** Overshoots slightly then settles (like a running start). */
62
+ export function runningStart(pullFactor = 0.2) {
63
+ return (t) => {
64
+ // Cubic bezier from (0,0) to (1,1) with control points for overshoot
65
+ return bezierInterpolate(t, 0, -pullFactor, 1, 1);
66
+ };
67
+ }
68
+ /**
69
+ * Oscillates back and forth (wiggle/shake effect).
70
+ * Creates a wobbling motion that ends at 1.
71
+ */
72
+ export const wiggle = (t) => {
73
+ const wiggles = 2;
74
+ // Damped sine wave that ends at 1
75
+ return t + (1 - t) * Math.sin(wiggles * 2 * Math.PI * t) * 0.3;
76
+ };
77
+ /** Approaches but doesn't quite reach 1 (asymptotic approach). */
78
+ export function notQuiteThere(proportion = 0.7) {
79
+ return (t) => t === 1 ? 1 : proportion * smooth(t);
80
+ }
81
+ /** Reaches the destination early and stays there. */
82
+ export function lingering(proportion = 0.75) {
83
+ return (t) => {
84
+ if (t >= proportion) {
85
+ return 1;
86
+ }
87
+ return smooth(t / proportion);
88
+ };
89
+ }
90
+ /** Asymptotically approaches 1 via exponential decay. */
91
+ export function exponentialDecay(halfLife = 0.1) {
92
+ return (t) => {
93
+ if (t === 1)
94
+ return 1;
95
+ return 1 - Math.exp(-t / halfLife);
96
+ };
97
+ }
98
+ // Helper for cubic bezier interpolation (used by runningStart)
99
+ function bezierInterpolate(t, p0, p1, p2, p3) {
100
+ const u = 1 - t;
101
+ return u * u * u * p0 + 3 * u * u * t * p1 + 3 * u * t * t * p2 + t * t * t * p3;
102
+ }
@@ -0,0 +1,8 @@
1
+ import type { EasingFunction } from './types';
2
+ /** @throws Error if an easing with the given name already exists. */
3
+ export declare function registerEasing(name: string, fn: EasingFunction): void;
4
+ export declare function getEasing(name: string): EasingFunction | undefined;
5
+ export declare function hasEasing(name: string): boolean;
6
+ export declare function unregisterEasing(name: string): boolean;
7
+ /** Clears all registered custom easings (useful for testing). */
8
+ export declare function clearRegistry(): void;
@@ -0,0 +1,25 @@
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
+ }
@@ -0,0 +1,113 @@
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;
@@ -0,0 +1,151 @@
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;
@@ -0,0 +1,6 @@
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
@@ -0,0 +1,17 @@
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
+ }
@@ -0,0 +1,22 @@
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
+ }
@@ -0,0 +1,17 @@
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
+ }
@@ -0,0 +1,23 @@
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
+ }
@@ -0,0 +1,2 @@
1
+ export { FadeIn } from './FadeIn';
2
+ export { FadeOut } from './FadeOut';
@@ -0,0 +1,2 @@
1
+ export { FadeIn } from './FadeIn';
2
+ export { FadeOut } from './FadeOut';
@@ -0,0 +1,11 @@
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';
@@ -0,0 +1,17 @@
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';
@@ -0,0 +1,33 @@
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 {};
@@ -0,0 +1,40 @@
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
+ }