@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.
- package/dist/cli/index.js +203 -57
- package/dist/index.d.ts +2086 -18
- package/dist/index.js +5343 -22
- package/package.json +5 -3
- package/dist/cli/SceneLoader.d.ts +0 -22
- package/dist/cli/SceneLoader.js +0 -47
- package/dist/cli/commands/export-frame.d.ts +0 -13
- package/dist/cli/commands/export-frame.js +0 -60
- package/dist/cli/commands/list-scenes.d.ts +0 -5
- package/dist/cli/commands/list-scenes.js +0 -22
- package/dist/cli/commands/preview.d.ts +0 -5
- package/dist/cli/commands/preview.js +0 -11
- package/dist/cli/commands/render.d.ts +0 -16
- package/dist/cli/commands/render.js +0 -76
- package/dist/cli/index.d.ts +0 -2
- package/dist/core/animations/Animation.d.ts +0 -41
- package/dist/core/animations/Animation.js +0 -76
- package/dist/core/animations/camera/Follow.d.ts +0 -70
- package/dist/core/animations/camera/Follow.js +0 -69
- package/dist/core/animations/camera/Shake.d.ts +0 -90
- package/dist/core/animations/camera/Shake.js +0 -87
- package/dist/core/animations/camera/index.d.ts +0 -2
- package/dist/core/animations/camera/index.js +0 -2
- package/dist/core/animations/categories/ExitAnimation.d.ts +0 -17
- package/dist/core/animations/categories/ExitAnimation.js +0 -15
- package/dist/core/animations/categories/IntroductoryAnimation.d.ts +0 -16
- package/dist/core/animations/categories/IntroductoryAnimation.js +0 -14
- package/dist/core/animations/categories/TransformativeAnimation.d.ts +0 -25
- package/dist/core/animations/categories/TransformativeAnimation.js +0 -25
- package/dist/core/animations/categories/index.d.ts +0 -3
- package/dist/core/animations/categories/index.js +0 -3
- package/dist/core/animations/composition/Parallel.d.ts +0 -37
- package/dist/core/animations/composition/Parallel.js +0 -79
- package/dist/core/animations/composition/Sequence.d.ts +0 -41
- package/dist/core/animations/composition/Sequence.js +0 -95
- package/dist/core/animations/composition/index.d.ts +0 -2
- package/dist/core/animations/composition/index.js +0 -3
- package/dist/core/animations/draw/Draw.d.ts +0 -30
- package/dist/core/animations/draw/Draw.js +0 -122
- package/dist/core/animations/draw/Unwrite.d.ts +0 -30
- package/dist/core/animations/draw/Unwrite.js +0 -120
- package/dist/core/animations/draw/Write.d.ts +0 -35
- package/dist/core/animations/draw/Write.js +0 -119
- package/dist/core/animations/draw/index.d.ts +0 -3
- package/dist/core/animations/draw/index.js +0 -3
- package/dist/core/animations/draw/partialPath.d.ts +0 -6
- package/dist/core/animations/draw/partialPath.js +0 -138
- package/dist/core/animations/easing/bounce.d.ts +0 -13
- package/dist/core/animations/easing/bounce.js +0 -37
- package/dist/core/animations/easing/index.d.ts +0 -7
- package/dist/core/animations/easing/index.js +0 -11
- package/dist/core/animations/easing/manim.d.ts +0 -46
- package/dist/core/animations/easing/manim.js +0 -102
- package/dist/core/animations/easing/registry.d.ts +0 -8
- package/dist/core/animations/easing/registry.js +0 -25
- package/dist/core/animations/easing/standard.d.ts +0 -113
- package/dist/core/animations/easing/standard.js +0 -151
- package/dist/core/animations/easing/types.d.ts +0 -6
- package/dist/core/animations/easing/types.js +0 -0
- package/dist/core/animations/fade/FadeIn.d.ts +0 -17
- package/dist/core/animations/fade/FadeIn.js +0 -22
- package/dist/core/animations/fade/FadeOut.d.ts +0 -17
- package/dist/core/animations/fade/FadeOut.js +0 -23
- package/dist/core/animations/fade/index.d.ts +0 -2
- package/dist/core/animations/fade/index.js +0 -2
- package/dist/core/animations/index.d.ts +0 -11
- package/dist/core/animations/index.js +0 -17
- package/dist/core/animations/keyframes/KeyframeAnimation.d.ts +0 -33
- package/dist/core/animations/keyframes/KeyframeAnimation.js +0 -40
- package/dist/core/animations/keyframes/KeyframeTrack.d.ts +0 -31
- package/dist/core/animations/keyframes/KeyframeTrack.js +0 -83
- package/dist/core/animations/keyframes/index.d.ts +0 -4
- package/dist/core/animations/keyframes/index.js +0 -5
- package/dist/core/animations/keyframes/types.d.ts +0 -25
- package/dist/core/animations/keyframes/types.js +0 -6
- package/dist/core/animations/morph/MorphTo.d.ts +0 -22
- package/dist/core/animations/morph/MorphTo.js +0 -42
- package/dist/core/animations/morph/index.d.ts +0 -1
- package/dist/core/animations/morph/index.js +0 -1
- package/dist/core/animations/transform/MoveTo.d.ts +0 -24
- package/dist/core/animations/transform/MoveTo.js +0 -38
- package/dist/core/animations/transform/Rotate.d.ts +0 -23
- package/dist/core/animations/transform/Rotate.js +0 -34
- package/dist/core/animations/transform/Scale.d.ts +0 -23
- package/dist/core/animations/transform/Scale.js +0 -35
- package/dist/core/animations/transform/index.d.ts +0 -3
- package/dist/core/animations/transform/index.js +0 -3
- package/dist/core/animations/types.d.ts +0 -52
- package/dist/core/animations/types.js +0 -6
- package/dist/core/camera/Camera.d.ts +0 -87
- package/dist/core/camera/Camera.js +0 -175
- package/dist/core/camera/CameraFrame.d.ts +0 -242
- package/dist/core/camera/CameraFrame.js +0 -322
- package/dist/core/camera/index.d.ts +0 -4
- package/dist/core/camera/index.js +0 -3
- package/dist/core/camera/types.d.ts +0 -17
- package/dist/core/camera/types.js +0 -1
- package/dist/core/errors/AnimationErrors.d.ts +0 -12
- package/dist/core/errors/AnimationErrors.js +0 -37
- package/dist/core/errors/index.d.ts +0 -1
- package/dist/core/errors/index.js +0 -1
- package/dist/core/math/Vector2/Vector2.d.ts +0 -23
- package/dist/core/math/Vector2/Vector2.js +0 -46
- package/dist/core/math/Vector2/index.d.ts +0 -1
- package/dist/core/math/Vector2/index.js +0 -1
- package/dist/core/math/bezier/BezierPath.d.ts +0 -38
- package/dist/core/math/bezier/BezierPath.js +0 -264
- package/dist/core/math/bezier/evaluators.d.ts +0 -9
- package/dist/core/math/bezier/evaluators.js +0 -36
- package/dist/core/math/bezier/index.d.ts +0 -8
- package/dist/core/math/bezier/index.js +0 -6
- package/dist/core/math/bezier/length.d.ts +0 -5
- package/dist/core/math/bezier/length.js +0 -27
- package/dist/core/math/bezier/morphing.d.ts +0 -16
- package/dist/core/math/bezier/morphing.js +0 -151
- package/dist/core/math/bezier/sampling.d.ts +0 -7
- package/dist/core/math/bezier/sampling.js +0 -153
- package/dist/core/math/bezier/split.d.ts +0 -19
- package/dist/core/math/bezier/split.js +0 -44
- package/dist/core/math/bezier/types.d.ts +0 -8
- package/dist/core/math/bezier/types.js +0 -0
- package/dist/core/math/color/Color.d.ts +0 -28
- package/dist/core/math/color/Color.js +0 -60
- package/dist/core/math/color/conversions.d.ts +0 -17
- package/dist/core/math/color/conversions.js +0 -100
- package/dist/core/math/color/index.d.ts +0 -2
- package/dist/core/math/color/index.js +0 -2
- package/dist/core/math/index.d.ts +0 -4
- package/dist/core/math/index.js +0 -5
- package/dist/core/math/matrix/Matrix3x3.d.ts +0 -23
- package/dist/core/math/matrix/Matrix3x3.js +0 -91
- package/dist/core/math/matrix/factories.d.ts +0 -12
- package/dist/core/math/matrix/factories.js +0 -44
- package/dist/core/math/matrix/index.d.ts +0 -2
- package/dist/core/math/matrix/index.js +0 -2
- package/dist/core/renderer/FrameRenderer.d.ts +0 -37
- package/dist/core/renderer/FrameRenderer.js +0 -75
- package/dist/core/renderer/ProgressReporter.d.ts +0 -19
- package/dist/core/renderer/ProgressReporter.js +0 -58
- package/dist/core/renderer/Renderer.d.ts +0 -36
- package/dist/core/renderer/Renderer.js +0 -102
- package/dist/core/renderer/drawMobject.d.ts +0 -8
- package/dist/core/renderer/drawMobject.js +0 -109
- package/dist/core/renderer/formats/index.d.ts +0 -3
- package/dist/core/renderer/formats/index.js +0 -3
- package/dist/core/renderer/formats/png.d.ts +0 -5
- package/dist/core/renderer/formats/png.js +0 -7
- package/dist/core/renderer/formats/sprite.d.ts +0 -6
- package/dist/core/renderer/formats/sprite.js +0 -24
- package/dist/core/renderer/formats/video.d.ts +0 -8
- package/dist/core/renderer/formats/video.js +0 -51
- package/dist/core/renderer/index.d.ts +0 -7
- package/dist/core/renderer/index.js +0 -9
- package/dist/core/renderer/types.d.ts +0 -87
- package/dist/core/renderer/types.js +0 -13
- package/dist/core/scene/Scene.d.ts +0 -104
- package/dist/core/scene/Scene.js +0 -225
- package/dist/core/scene/index.d.ts +0 -2
- package/dist/core/scene/index.js +0 -1
- package/dist/core/scene/types.d.ts +0 -23
- package/dist/core/scene/types.js +0 -0
- package/dist/core/serialization/animation.d.ts +0 -23
- package/dist/core/serialization/animation.js +0 -176
- package/dist/core/serialization/easingLookup.d.ts +0 -13
- package/dist/core/serialization/easingLookup.js +0 -65
- package/dist/core/serialization/index.d.ts +0 -23
- package/dist/core/serialization/index.js +0 -29
- package/dist/core/serialization/mobject.d.ts +0 -23
- package/dist/core/serialization/mobject.js +0 -248
- package/dist/core/serialization/prettyPrint.d.ts +0 -12
- package/dist/core/serialization/prettyPrint.js +0 -16
- package/dist/core/serialization/primitives.d.ts +0 -24
- package/dist/core/serialization/primitives.js +0 -98
- package/dist/core/serialization/registry.d.ts +0 -29
- package/dist/core/serialization/registry.js +0 -39
- package/dist/core/serialization/scene.d.ts +0 -28
- package/dist/core/serialization/scene.js +0 -114
- package/dist/core/serialization/types.d.ts +0 -152
- package/dist/core/serialization/types.js +0 -6
- package/dist/core/timeline/Timeline.d.ts +0 -70
- package/dist/core/timeline/Timeline.js +0 -144
- package/dist/core/timeline/index.d.ts +0 -5
- package/dist/core/timeline/index.js +0 -4
- package/dist/core/timeline/types.d.ts +0 -29
- package/dist/core/timeline/types.js +0 -0
- package/dist/mobjects/Mobject.d.ts +0 -98
- package/dist/mobjects/Mobject.js +0 -343
- package/dist/mobjects/VGroup/VGroup.d.ts +0 -51
- package/dist/mobjects/VGroup/VGroup.js +0 -142
- package/dist/mobjects/VGroup/index.d.ts +0 -3
- package/dist/mobjects/VGroup/index.js +0 -2
- package/dist/mobjects/VGroup/layout.d.ts +0 -20
- package/dist/mobjects/VGroup/layout.js +0 -139
- package/dist/mobjects/VMobject.d.ts +0 -106
- package/dist/mobjects/VMobject.js +0 -216
- package/dist/mobjects/geometry/Arc.d.ts +0 -8
- package/dist/mobjects/geometry/Arc.js +0 -46
- package/dist/mobjects/geometry/Arrow.d.ts +0 -7
- package/dist/mobjects/geometry/Arrow.js +0 -34
- package/dist/mobjects/geometry/Circle.d.ts +0 -4
- package/dist/mobjects/geometry/Circle.js +0 -10
- package/dist/mobjects/geometry/Line.d.ts +0 -8
- package/dist/mobjects/geometry/Line.js +0 -19
- package/dist/mobjects/geometry/Point.d.ts +0 -5
- package/dist/mobjects/geometry/Point.js +0 -11
- package/dist/mobjects/geometry/Polygon.d.ts +0 -7
- package/dist/mobjects/geometry/Polygon.js +0 -21
- package/dist/mobjects/geometry/Rectangle.d.ts +0 -6
- package/dist/mobjects/geometry/Rectangle.js +0 -18
- package/dist/mobjects/geometry/index.d.ts +0 -7
- package/dist/mobjects/geometry/index.js +0 -7
- package/dist/mobjects/graph/Graph.d.ts +0 -28
- package/dist/mobjects/graph/Graph.js +0 -119
- package/dist/mobjects/graph/GraphEdge.d.ts +0 -26
- package/dist/mobjects/graph/GraphEdge.js +0 -64
- package/dist/mobjects/graph/GraphNode.d.ts +0 -19
- package/dist/mobjects/graph/GraphNode.js +0 -63
- package/dist/mobjects/graph/index.d.ts +0 -5
- package/dist/mobjects/graph/index.js +0 -5
- package/dist/mobjects/graph/layouts/circular.d.ts +0 -8
- package/dist/mobjects/graph/layouts/circular.js +0 -23
- package/dist/mobjects/graph/layouts/forceDirected.d.ts +0 -9
- package/dist/mobjects/graph/layouts/forceDirected.js +0 -102
- package/dist/mobjects/graph/layouts/index.d.ts +0 -3
- package/dist/mobjects/graph/layouts/index.js +0 -3
- package/dist/mobjects/graph/layouts/tree.d.ts +0 -9
- package/dist/mobjects/graph/layouts/tree.js +0 -99
- package/dist/mobjects/graph/types.d.ts +0 -35
- package/dist/mobjects/graph/types.js +0 -0
- package/dist/mobjects/index.d.ts +0 -6
- package/dist/mobjects/index.js +0 -6
- package/dist/mobjects/text/Glyph.d.ts +0 -11
- package/dist/mobjects/text/Glyph.js +0 -72
- package/dist/mobjects/text/Text.d.ts +0 -19
- package/dist/mobjects/text/Text.js +0 -76
- package/dist/mobjects/text/index.d.ts +0 -4
- package/dist/mobjects/text/index.js +0 -3
- package/dist/mobjects/text/types.d.ts +0 -12
- package/dist/mobjects/text/types.js +0 -8
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import { ExitAnimation } from '../categories';
|
|
2
|
-
import { getPartialPath } from './partialPath';
|
|
3
|
-
/**
|
|
4
|
-
* Checks if a VMobject is a VGroup (has getChildren method).
|
|
5
|
-
* Uses duck-typing to avoid circular dependency with VGroup import.
|
|
6
|
-
*/
|
|
7
|
-
function isVGroup(target) {
|
|
8
|
-
return typeof target.getChildren === 'function';
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Animation that progressively removes a VMobject by erasing the path.
|
|
12
|
-
* Reverse of Write animation - at progress 0, full object is visible;
|
|
13
|
-
* at progress 1, nothing is visible.
|
|
14
|
-
*
|
|
15
|
-
* Supports VGroup (including Text): animates each child's paths progressively.
|
|
16
|
-
*
|
|
17
|
-
* This is an exit animation - the target must already be in the scene.
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* scene.play(new Write(text));
|
|
21
|
-
* scene.play(new Unwrite(text)); // Text is erased progressively
|
|
22
|
-
*/
|
|
23
|
-
export class Unwrite extends ExitAnimation {
|
|
24
|
-
isVGroup;
|
|
25
|
-
/** For non-VGroup targets: original paths on the target itself. */
|
|
26
|
-
originalPaths;
|
|
27
|
-
originalOpacity;
|
|
28
|
-
originalFillOpacity;
|
|
29
|
-
/** For VGroup targets: original state of each child. */
|
|
30
|
-
childStates;
|
|
31
|
-
constructor(target) {
|
|
32
|
-
super(target);
|
|
33
|
-
this.isVGroup = isVGroup(target);
|
|
34
|
-
this.originalOpacity = target.opacity;
|
|
35
|
-
this.originalFillOpacity = target.getFillOpacity();
|
|
36
|
-
if (this.isVGroup && isVGroup(target)) {
|
|
37
|
-
// Store original state for each child
|
|
38
|
-
this.originalPaths = [];
|
|
39
|
-
this.childStates = [];
|
|
40
|
-
for (const child of target.getChildren()) {
|
|
41
|
-
this.childStates.push({
|
|
42
|
-
child,
|
|
43
|
-
originalPaths: child.paths.map((p) => p.clone()),
|
|
44
|
-
originalOpacity: child.opacity,
|
|
45
|
-
originalFillOpacity: child.getFillOpacity(),
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
// Store original paths on the target itself
|
|
51
|
-
this.originalPaths = target.paths.map(p => p.clone());
|
|
52
|
-
this.childStates = [];
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
interpolate(progress) {
|
|
56
|
-
if (this.isVGroup) {
|
|
57
|
-
this.interpolateVGroup(progress);
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
this.interpolateVMobject(progress);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
/** Interpolates a single VMobject (non-VGroup). */
|
|
64
|
-
interpolateVMobject(progress) {
|
|
65
|
-
if (progress >= 1) {
|
|
66
|
-
this.target.paths = [];
|
|
67
|
-
this.target.setOpacity(0);
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
if (progress <= 0) {
|
|
71
|
-
this.target.paths = this.originalPaths.map(p => p.clone());
|
|
72
|
-
const targetOpacity = this.originalOpacity === 0 ? 1 : this.originalOpacity;
|
|
73
|
-
this.target.setOpacity(targetOpacity);
|
|
74
|
-
this.target.fill(this.target.getFillColor(), this.originalFillOpacity);
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
// Show partial paths (reverse progress)
|
|
78
|
-
const reverseProgress = 1 - progress;
|
|
79
|
-
const targetOpacity = this.originalOpacity === 0 ? 1 : this.originalOpacity;
|
|
80
|
-
this.target.setOpacity(targetOpacity);
|
|
81
|
-
this.target.fill(this.target.getFillColor(), this.originalFillOpacity);
|
|
82
|
-
const partialPaths = [];
|
|
83
|
-
for (const originalPath of this.originalPaths) {
|
|
84
|
-
partialPaths.push(getPartialPath(originalPath, reverseProgress));
|
|
85
|
-
}
|
|
86
|
-
this.target.paths = partialPaths;
|
|
87
|
-
}
|
|
88
|
-
/** Interpolates a VGroup by animating each child's paths. */
|
|
89
|
-
interpolateVGroup(progress) {
|
|
90
|
-
if (progress >= 1) {
|
|
91
|
-
this.target.setOpacity(0);
|
|
92
|
-
for (const state of this.childStates) {
|
|
93
|
-
state.child.paths = [];
|
|
94
|
-
state.child.setOpacity(0);
|
|
95
|
-
}
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
const targetOpacity = this.originalOpacity === 0 ? 1 : this.originalOpacity;
|
|
99
|
-
this.target.setOpacity(targetOpacity);
|
|
100
|
-
for (const state of this.childStates) {
|
|
101
|
-
const { child, originalPaths, originalOpacity, originalFillOpacity } = state;
|
|
102
|
-
const childOpacity = originalOpacity === 0 ? 1 : originalOpacity;
|
|
103
|
-
if (progress <= 0) {
|
|
104
|
-
child.paths = originalPaths.map(p => p.clone());
|
|
105
|
-
child.setOpacity(childOpacity);
|
|
106
|
-
child.fill(child.getFillColor(), originalFillOpacity);
|
|
107
|
-
continue;
|
|
108
|
-
}
|
|
109
|
-
// Show partial paths (reverse progress)
|
|
110
|
-
const reverseProgress = 1 - progress;
|
|
111
|
-
child.setOpacity(childOpacity);
|
|
112
|
-
child.fill(child.getFillColor(), originalFillOpacity);
|
|
113
|
-
const partialPaths = [];
|
|
114
|
-
for (const originalPath of originalPaths) {
|
|
115
|
-
partialPaths.push(getPartialPath(originalPath, reverseProgress));
|
|
116
|
-
}
|
|
117
|
-
child.paths = partialPaths;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { IntroductoryAnimation } from '../categories';
|
|
2
|
-
import { VMobject } from '../../../mobjects/VMobject';
|
|
3
|
-
/**
|
|
4
|
-
* Animation that progressively draws a VMobject's paths from start to end.
|
|
5
|
-
* Preserves both stroke and fill properties - the complete object is visible at the end.
|
|
6
|
-
*
|
|
7
|
-
* This is the canonical animation for progressive path drawing.
|
|
8
|
-
* At progress 0, nothing is shown. At progress 1, the complete path is shown.
|
|
9
|
-
*
|
|
10
|
-
* Supports VGroup (including Text): animates each child's paths progressively.
|
|
11
|
-
*
|
|
12
|
-
* This is an introductory animation - it auto-registers the target with the scene.
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* const circle = new Circle(1);
|
|
16
|
-
* scene.play(new Write(circle)); // Circle is drawn progressively
|
|
17
|
-
*
|
|
18
|
-
* const text = new Text('Hello');
|
|
19
|
-
* scene.play(new Write(text)); // Text is written progressively
|
|
20
|
-
*/
|
|
21
|
-
export declare class Write<T extends VMobject = VMobject> extends IntroductoryAnimation<T> {
|
|
22
|
-
private readonly isVGroup;
|
|
23
|
-
/** For non-VGroup targets: original paths on the target itself. */
|
|
24
|
-
private readonly originalPaths;
|
|
25
|
-
private readonly originalOpacity;
|
|
26
|
-
private readonly originalFillOpacity;
|
|
27
|
-
/** For VGroup targets: original state of each child. */
|
|
28
|
-
private readonly childStates;
|
|
29
|
-
constructor(target: T);
|
|
30
|
-
interpolate(progress: number): void;
|
|
31
|
-
/** Interpolates a single VMobject (non-VGroup). */
|
|
32
|
-
private interpolateVMobject;
|
|
33
|
-
/** Interpolates a VGroup by animating each child's paths. */
|
|
34
|
-
private interpolateVGroup;
|
|
35
|
-
}
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import { IntroductoryAnimation } from '../categories';
|
|
2
|
-
import { getPartialPath } from './partialPath';
|
|
3
|
-
/**
|
|
4
|
-
* Checks if a VMobject is a VGroup (has getChildren method).
|
|
5
|
-
* Uses duck-typing to avoid circular dependency with VGroup import.
|
|
6
|
-
*/
|
|
7
|
-
function isVGroup(target) {
|
|
8
|
-
return typeof target.getChildren === 'function';
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Animation that progressively draws a VMobject's paths from start to end.
|
|
12
|
-
* Preserves both stroke and fill properties - the complete object is visible at the end.
|
|
13
|
-
*
|
|
14
|
-
* This is the canonical animation for progressive path drawing.
|
|
15
|
-
* At progress 0, nothing is shown. At progress 1, the complete path is shown.
|
|
16
|
-
*
|
|
17
|
-
* Supports VGroup (including Text): animates each child's paths progressively.
|
|
18
|
-
*
|
|
19
|
-
* This is an introductory animation - it auto-registers the target with the scene.
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* const circle = new Circle(1);
|
|
23
|
-
* scene.play(new Write(circle)); // Circle is drawn progressively
|
|
24
|
-
*
|
|
25
|
-
* const text = new Text('Hello');
|
|
26
|
-
* scene.play(new Write(text)); // Text is written progressively
|
|
27
|
-
*/
|
|
28
|
-
export class Write extends IntroductoryAnimation {
|
|
29
|
-
isVGroup;
|
|
30
|
-
/** For non-VGroup targets: original paths on the target itself. */
|
|
31
|
-
originalPaths;
|
|
32
|
-
originalOpacity;
|
|
33
|
-
originalFillOpacity;
|
|
34
|
-
/** For VGroup targets: original state of each child. */
|
|
35
|
-
childStates;
|
|
36
|
-
constructor(target) {
|
|
37
|
-
super(target);
|
|
38
|
-
this.isVGroup = isVGroup(target);
|
|
39
|
-
this.originalOpacity = target.opacity;
|
|
40
|
-
this.originalFillOpacity = target.getFillOpacity();
|
|
41
|
-
if (this.isVGroup && isVGroup(target)) {
|
|
42
|
-
// Store original state for each child
|
|
43
|
-
this.originalPaths = [];
|
|
44
|
-
this.childStates = [];
|
|
45
|
-
for (const child of target.getChildren()) {
|
|
46
|
-
this.childStates.push({
|
|
47
|
-
child,
|
|
48
|
-
originalPaths: child.paths.map((p) => p.clone()),
|
|
49
|
-
originalOpacity: child.opacity,
|
|
50
|
-
originalFillOpacity: child.getFillOpacity(),
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
// Store original paths on the target itself
|
|
56
|
-
this.originalPaths = target.paths.map(p => p.clone());
|
|
57
|
-
this.childStates = [];
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
interpolate(progress) {
|
|
61
|
-
if (this.isVGroup) {
|
|
62
|
-
this.interpolateVGroup(progress);
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
65
|
-
this.interpolateVMobject(progress);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
/** Interpolates a single VMobject (non-VGroup). */
|
|
69
|
-
interpolateVMobject(progress) {
|
|
70
|
-
if (progress <= 0) {
|
|
71
|
-
this.target.paths = [];
|
|
72
|
-
this.target.setOpacity(0);
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
// Make visible and preserve original fill opacity
|
|
76
|
-
const targetOpacity = this.originalOpacity === 0 ? 1 : this.originalOpacity;
|
|
77
|
-
this.target.setOpacity(targetOpacity);
|
|
78
|
-
this.target.fill(this.target.getFillColor(), this.originalFillOpacity);
|
|
79
|
-
if (progress >= 1) {
|
|
80
|
-
this.target.paths = this.originalPaths.map(p => p.clone());
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
// Show partial paths
|
|
84
|
-
const partialPaths = [];
|
|
85
|
-
for (const originalPath of this.originalPaths) {
|
|
86
|
-
partialPaths.push(getPartialPath(originalPath, progress));
|
|
87
|
-
}
|
|
88
|
-
this.target.paths = partialPaths;
|
|
89
|
-
}
|
|
90
|
-
/** Interpolates a VGroup by animating each child's paths. */
|
|
91
|
-
interpolateVGroup(progress) {
|
|
92
|
-
// Set parent VGroup opacity
|
|
93
|
-
const targetOpacity = this.originalOpacity === 0 ? 1 : this.originalOpacity;
|
|
94
|
-
this.target.setOpacity(progress <= 0 ? 0 : targetOpacity);
|
|
95
|
-
// Animate each child
|
|
96
|
-
for (const state of this.childStates) {
|
|
97
|
-
const { child, originalPaths, originalOpacity, originalFillOpacity } = state;
|
|
98
|
-
if (progress <= 0) {
|
|
99
|
-
child.paths = [];
|
|
100
|
-
child.setOpacity(0);
|
|
101
|
-
continue;
|
|
102
|
-
}
|
|
103
|
-
// Make child visible
|
|
104
|
-
const childOpacity = originalOpacity === 0 ? 1 : originalOpacity;
|
|
105
|
-
child.setOpacity(childOpacity);
|
|
106
|
-
child.fill(child.getFillColor(), originalFillOpacity);
|
|
107
|
-
if (progress >= 1) {
|
|
108
|
-
child.paths = originalPaths.map(p => p.clone());
|
|
109
|
-
continue;
|
|
110
|
-
}
|
|
111
|
-
// Show partial paths for this child
|
|
112
|
-
const partialPaths = [];
|
|
113
|
-
for (const originalPath of originalPaths) {
|
|
114
|
-
partialPaths.push(getPartialPath(originalPath, progress));
|
|
115
|
-
}
|
|
116
|
-
child.paths = partialPaths;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { BezierPath } from '../../math/bezier/BezierPath';
|
|
2
|
-
/**
|
|
3
|
-
* Returns a partial BezierPath from the start up to a given normalized t (0–1).
|
|
4
|
-
* The path is truncated at the exact point corresponding to t * totalLength.
|
|
5
|
-
*/
|
|
6
|
-
export declare function getPartialPath(path: BezierPath, t: number): BezierPath;
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import { BezierPath } from '../../math/bezier/BezierPath';
|
|
2
|
-
import { Vector2 } from '../../math/Vector2/Vector2';
|
|
3
|
-
import { getQuadraticLength, getCubicLength } from '../../math/bezier/length';
|
|
4
|
-
import { evaluateQuadratic } from '../../math/bezier/evaluators';
|
|
5
|
-
import { splitCubicAt } from '../../math/bezier/split';
|
|
6
|
-
/**
|
|
7
|
-
* Returns a partial BezierPath from the start up to a given normalized t (0–1).
|
|
8
|
-
* The path is truncated at the exact point corresponding to t * totalLength.
|
|
9
|
-
*/
|
|
10
|
-
export function getPartialPath(path, t) {
|
|
11
|
-
if (t <= 0) {
|
|
12
|
-
return new BezierPath();
|
|
13
|
-
}
|
|
14
|
-
if (t >= 1) {
|
|
15
|
-
return path.clone();
|
|
16
|
-
}
|
|
17
|
-
const totalLength = path.getLength();
|
|
18
|
-
if (totalLength === 0) {
|
|
19
|
-
return path.clone();
|
|
20
|
-
}
|
|
21
|
-
const targetLength = t * totalLength;
|
|
22
|
-
const commands = path.getCommands();
|
|
23
|
-
const result = new BezierPath();
|
|
24
|
-
let accumulatedLength = 0;
|
|
25
|
-
let cursor = Vector2.ZERO;
|
|
26
|
-
let subpathStart = Vector2.ZERO;
|
|
27
|
-
for (const cmd of commands) {
|
|
28
|
-
const segmentLength = getSegmentLength(cmd, cursor, subpathStart);
|
|
29
|
-
const newAccumulated = accumulatedLength + segmentLength;
|
|
30
|
-
if (newAccumulated <= targetLength) {
|
|
31
|
-
// Include entire segment
|
|
32
|
-
appendCommand(result, cmd, cursor, subpathStart);
|
|
33
|
-
updateCursor(cmd, cursor, subpathStart, (c, s) => {
|
|
34
|
-
cursor = c;
|
|
35
|
-
subpathStart = s;
|
|
36
|
-
});
|
|
37
|
-
accumulatedLength = newAccumulated;
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
// Partial segment needed
|
|
41
|
-
const remaining = targetLength - accumulatedLength;
|
|
42
|
-
const localT = segmentLength > 0 ? remaining / segmentLength : 0;
|
|
43
|
-
appendPartialCommand(result, cmd, cursor, subpathStart, localT);
|
|
44
|
-
break;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
return result;
|
|
48
|
-
}
|
|
49
|
-
function getSegmentLength(cmd, cursor, subpathStart) {
|
|
50
|
-
switch (cmd.type) {
|
|
51
|
-
case 'Move':
|
|
52
|
-
return 0;
|
|
53
|
-
case 'Line':
|
|
54
|
-
return cursor.subtract(cmd.end).length();
|
|
55
|
-
case 'Quadratic':
|
|
56
|
-
if (cmd.control1) {
|
|
57
|
-
return getQuadraticLength(cursor, cmd.control1, cmd.end);
|
|
58
|
-
}
|
|
59
|
-
return 0;
|
|
60
|
-
case 'Cubic':
|
|
61
|
-
if (cmd.control1 && cmd.control2) {
|
|
62
|
-
return getCubicLength(cursor, cmd.control1, cmd.control2, cmd.end);
|
|
63
|
-
}
|
|
64
|
-
return 0;
|
|
65
|
-
case 'Close':
|
|
66
|
-
return cursor.subtract(subpathStart).length();
|
|
67
|
-
default:
|
|
68
|
-
return 0;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
function updateCursor(cmd, _cursor, subpathStart, update) {
|
|
72
|
-
switch (cmd.type) {
|
|
73
|
-
case 'Move':
|
|
74
|
-
update(cmd.end, cmd.end);
|
|
75
|
-
break;
|
|
76
|
-
case 'Close':
|
|
77
|
-
update(subpathStart, subpathStart);
|
|
78
|
-
break;
|
|
79
|
-
default:
|
|
80
|
-
update(cmd.end, subpathStart);
|
|
81
|
-
break;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
function appendCommand(result, cmd, _cursor, _subpathStart) {
|
|
85
|
-
switch (cmd.type) {
|
|
86
|
-
case 'Move':
|
|
87
|
-
result.moveTo(cmd.end);
|
|
88
|
-
break;
|
|
89
|
-
case 'Line':
|
|
90
|
-
result.lineTo(cmd.end);
|
|
91
|
-
break;
|
|
92
|
-
case 'Quadratic':
|
|
93
|
-
if (cmd.control1) {
|
|
94
|
-
result.quadraticTo(cmd.control1, cmd.end);
|
|
95
|
-
}
|
|
96
|
-
break;
|
|
97
|
-
case 'Cubic':
|
|
98
|
-
if (cmd.control1 && cmd.control2) {
|
|
99
|
-
result.cubicTo(cmd.control1, cmd.control2, cmd.end);
|
|
100
|
-
}
|
|
101
|
-
break;
|
|
102
|
-
case 'Close':
|
|
103
|
-
result.closePath();
|
|
104
|
-
break;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
function appendPartialCommand(result, cmd, cursor, subpathStart, localT) {
|
|
108
|
-
switch (cmd.type) {
|
|
109
|
-
case 'Move':
|
|
110
|
-
result.moveTo(cmd.end);
|
|
111
|
-
break;
|
|
112
|
-
case 'Line': {
|
|
113
|
-
const point = cursor.lerp(cmd.end, localT);
|
|
114
|
-
result.lineTo(point);
|
|
115
|
-
break;
|
|
116
|
-
}
|
|
117
|
-
case 'Quadratic': {
|
|
118
|
-
if (cmd.control1) {
|
|
119
|
-
const point = evaluateQuadratic(cursor, cmd.control1, cmd.end, localT);
|
|
120
|
-
// Approximate with line for partial quadratic
|
|
121
|
-
result.lineTo(point);
|
|
122
|
-
}
|
|
123
|
-
break;
|
|
124
|
-
}
|
|
125
|
-
case 'Cubic': {
|
|
126
|
-
if (cmd.control1 && cmd.control2) {
|
|
127
|
-
const [first] = splitCubicAt(cursor, cmd.control1, cmd.control2, cmd.end, localT);
|
|
128
|
-
result.cubicTo(first.control1, first.control2, first.end);
|
|
129
|
-
}
|
|
130
|
-
break;
|
|
131
|
-
}
|
|
132
|
-
case 'Close': {
|
|
133
|
-
const point = cursor.lerp(subpathStart, localT);
|
|
134
|
-
result.lineTo(point);
|
|
135
|
-
break;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { EasingFunction } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* Bounce ease-in: bounces before settling.
|
|
4
|
-
*/
|
|
5
|
-
export declare const easeInBounce: EasingFunction;
|
|
6
|
-
/**
|
|
7
|
-
* Bounce ease-out: bounces at the end.
|
|
8
|
-
*/
|
|
9
|
-
export declare const easeOutBounce: EasingFunction;
|
|
10
|
-
/**
|
|
11
|
-
* Bounce ease-in-out: bounces at both ends.
|
|
12
|
-
*/
|
|
13
|
-
export declare const easeInOutBounce: EasingFunction;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
// --- Bounce helpers ---
|
|
2
|
-
/**
|
|
3
|
-
* Bounce ease-out helper calculation.
|
|
4
|
-
*/
|
|
5
|
-
function bounceOut(t) {
|
|
6
|
-
const n1 = 7.5625;
|
|
7
|
-
const d1 = 2.75;
|
|
8
|
-
if (t < 1 / d1) {
|
|
9
|
-
return n1 * t * t;
|
|
10
|
-
}
|
|
11
|
-
else if (t < 2 / d1) {
|
|
12
|
-
const adjusted = t - 1.5 / d1;
|
|
13
|
-
return n1 * adjusted * adjusted + 0.75;
|
|
14
|
-
}
|
|
15
|
-
else if (t < 2.5 / d1) {
|
|
16
|
-
const adjusted = t - 2.25 / d1;
|
|
17
|
-
return n1 * adjusted * adjusted + 0.9375;
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
const adjusted = t - 2.625 / d1;
|
|
21
|
-
return n1 * adjusted * adjusted + 0.984375;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Bounce ease-in: bounces before settling.
|
|
26
|
-
*/
|
|
27
|
-
export const easeInBounce = (t) => 1 - bounceOut(1 - t);
|
|
28
|
-
/**
|
|
29
|
-
* Bounce ease-out: bounces at the end.
|
|
30
|
-
*/
|
|
31
|
-
export const easeOutBounce = bounceOut;
|
|
32
|
-
/**
|
|
33
|
-
* Bounce ease-in-out: bounces at both ends.
|
|
34
|
-
*/
|
|
35
|
-
export const easeInOutBounce = (t) => t < 0.5
|
|
36
|
-
? (1 - bounceOut(1 - 2 * t)) / 2
|
|
37
|
-
: (1 + bounceOut(2 * t - 1)) / 2;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export type { EasingFunction } from './types';
|
|
2
|
-
export { linear, easeInQuad, easeOutQuad, easeInOutQuad, easeInCubic, easeOutCubic, easeInOutCubic, easeInQuart, easeOutQuart, easeInOutQuart, easeInQuint, easeOutQuint, easeInOutQuint, easeInSine, easeOutSine, easeInOutSine, easeInExpo, easeOutExpo, easeInOutExpo, easeInCirc, easeOutCirc, easeInOutCirc, easeInBack, easeOutBack, easeInOutBack, easeInElastic, easeOutElastic, easeInOutElastic, } from './standard';
|
|
3
|
-
export { easeInBounce, easeOutBounce, easeInOutBounce, } from './bounce';
|
|
4
|
-
export { smooth, doubleSmooth, rushInto, rushFrom, slowInto, thereAndBack, thereAndBackWithPause, runningStart, wiggle, notQuiteThere, lingering, exponentialDecay, } from './manim';
|
|
5
|
-
export { registerEasing, getEasing, hasEasing, unregisterEasing, clearRegistry, } from './registry';
|
|
6
|
-
import { smooth } from './manim';
|
|
7
|
-
export { smooth as defaultEasing };
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
// Standard easing functions
|
|
2
|
-
export { linear, easeInQuad, easeOutQuad, easeInOutQuad, easeInCubic, easeOutCubic, easeInOutCubic, easeInQuart, easeOutQuart, easeInOutQuart, easeInQuint, easeOutQuint, easeInOutQuint, easeInSine, easeOutSine, easeInOutSine, easeInExpo, easeOutExpo, easeInOutExpo, easeInCirc, easeOutCirc, easeInOutCirc, easeInBack, easeOutBack, easeInOutBack, easeInElastic, easeOutElastic, easeInOutElastic, } from './standard';
|
|
3
|
-
// Bounce functions
|
|
4
|
-
export { easeInBounce, easeOutBounce, easeInOutBounce, } from './bounce';
|
|
5
|
-
// Manim-style rate functions
|
|
6
|
-
export { smooth, doubleSmooth, rushInto, rushFrom, slowInto, thereAndBack, thereAndBackWithPause, runningStart, wiggle, notQuiteThere, lingering, exponentialDecay, } from './manim';
|
|
7
|
-
// Custom easing registry
|
|
8
|
-
export { registerEasing, getEasing, hasEasing, unregisterEasing, clearRegistry, } from './registry';
|
|
9
|
-
// Re-export smooth as the default easing
|
|
10
|
-
import { smooth } from './manim';
|
|
11
|
-
export { smooth as defaultEasing };
|
|
@@ -1,46 +0,0 @@
|
|
|
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;
|
|
@@ -1,102 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
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;
|