@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
package/dist/index.d.ts
CHANGED
|
@@ -1,18 +1,2086 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
import { Glyph as Glyph$1 } from 'fontkit';
|
|
2
|
+
import { Canvas } from '@napi-rs/canvas';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A class representing a color with Red, Green, Blue, and Alpha components.
|
|
6
|
+
* RGB values are in the range [0, 255].
|
|
7
|
+
* Alpha value is in the range [0, 1].
|
|
8
|
+
*/
|
|
9
|
+
declare class Color {
|
|
10
|
+
readonly r: number;
|
|
11
|
+
readonly g: number;
|
|
12
|
+
readonly b: number;
|
|
13
|
+
readonly a: number;
|
|
14
|
+
constructor(r: number, g: number, b: number, a?: number);
|
|
15
|
+
/**
|
|
16
|
+
* Creates a Color from a hex string.
|
|
17
|
+
* Supports formats: #RRGGBB, #RGB, #RRGGBBAA, #RGBA.
|
|
18
|
+
*/
|
|
19
|
+
static fromHex(hex: string): Color;
|
|
20
|
+
static fromHSL(h: number, s: number, l: number, a?: number): Color;
|
|
21
|
+
toHex(): string;
|
|
22
|
+
toRGBA(): string;
|
|
23
|
+
lerp(other: Color, t: number): Color;
|
|
24
|
+
static readonly WHITE: Color;
|
|
25
|
+
static readonly BLACK: Color;
|
|
26
|
+
static readonly RED: Color;
|
|
27
|
+
static readonly GREEN: Color;
|
|
28
|
+
static readonly BLUE: Color;
|
|
29
|
+
static readonly YELLOW: Color;
|
|
30
|
+
static readonly TRANSPARENT: Color;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* A 2D vector class representing a point or direction in 2D space.
|
|
35
|
+
*/
|
|
36
|
+
declare class Vector2 {
|
|
37
|
+
readonly x: number;
|
|
38
|
+
readonly y: number;
|
|
39
|
+
constructor(x: number, y: number);
|
|
40
|
+
add(other: Vector2): Vector2;
|
|
41
|
+
subtract(other: Vector2): Vector2;
|
|
42
|
+
multiply(scalar: number): Vector2;
|
|
43
|
+
dot(other: Vector2): number;
|
|
44
|
+
/** Magnitude (length) of the vector. */
|
|
45
|
+
length(): number;
|
|
46
|
+
/** Returns a normalized unit vector. Returns ZERO for zero-length vectors. */
|
|
47
|
+
normalize(): Vector2;
|
|
48
|
+
lerp(other: Vector2, t: number): Vector2;
|
|
49
|
+
equals(other: Vector2, tolerance?: number): boolean;
|
|
50
|
+
static readonly ZERO: Vector2;
|
|
51
|
+
static readonly UP: Vector2;
|
|
52
|
+
static readonly DOWN: Vector2;
|
|
53
|
+
static readonly LEFT: Vector2;
|
|
54
|
+
static readonly RIGHT: Vector2;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* A 3x3 matrix class for 2D affine transformations.
|
|
59
|
+
* Stored in row-major order:
|
|
60
|
+
* [ 0 1 2 ]
|
|
61
|
+
* [ 3 4 5 ]
|
|
62
|
+
* [ 6 7 8 ]
|
|
63
|
+
*/
|
|
64
|
+
declare class Matrix3x3 {
|
|
65
|
+
readonly values: Float32Array;
|
|
66
|
+
constructor(values: number[] | Float32Array);
|
|
67
|
+
multiply(other: Matrix3x3): Matrix3x3;
|
|
68
|
+
/** Transforms a Vector2 point (assumes z=1). */
|
|
69
|
+
transformPoint(point: Vector2): Vector2;
|
|
70
|
+
/** @throws Error if the matrix is not invertible. */
|
|
71
|
+
inverse(): Matrix3x3;
|
|
72
|
+
static identity(): Matrix3x3;
|
|
73
|
+
static translation(tx: number, ty: number): Matrix3x3;
|
|
74
|
+
static rotation(angle: number): Matrix3x3;
|
|
75
|
+
static scale(sx: number, sy: number): Matrix3x3;
|
|
76
|
+
static shear(shx: number, shy: number): Matrix3x3;
|
|
77
|
+
static readonly IDENTITY: Matrix3x3;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Type signature for an easing function.
|
|
82
|
+
* Maps a progress value t ∈ [0, 1] to an eased value.
|
|
83
|
+
* Must satisfy: f(0) = 0 and f(1) = 1
|
|
84
|
+
*/
|
|
85
|
+
type EasingFunction = (t: number) => number;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Linear easing (no easing, constant speed).
|
|
89
|
+
*/
|
|
90
|
+
declare const linear: EasingFunction;
|
|
91
|
+
/**
|
|
92
|
+
* Quadratic ease-in: slow start, accelerating.
|
|
93
|
+
*/
|
|
94
|
+
declare const easeInQuad: EasingFunction;
|
|
95
|
+
/**
|
|
96
|
+
* Quadratic ease-out: fast start, decelerating.
|
|
97
|
+
*/
|
|
98
|
+
declare const easeOutQuad: EasingFunction;
|
|
99
|
+
/**
|
|
100
|
+
* Quadratic ease-in-out: slow start and end.
|
|
101
|
+
*/
|
|
102
|
+
declare const easeInOutQuad: EasingFunction;
|
|
103
|
+
/**
|
|
104
|
+
* Cubic ease-in: slow start, accelerating.
|
|
105
|
+
*/
|
|
106
|
+
declare const easeInCubic: EasingFunction;
|
|
107
|
+
/**
|
|
108
|
+
* Cubic ease-out: fast start, decelerating.
|
|
109
|
+
*/
|
|
110
|
+
declare const easeOutCubic: EasingFunction;
|
|
111
|
+
/**
|
|
112
|
+
* Cubic ease-in-out: slow start and end.
|
|
113
|
+
*/
|
|
114
|
+
declare const easeInOutCubic: EasingFunction;
|
|
115
|
+
/**
|
|
116
|
+
* Quartic ease-in: slow start, accelerating.
|
|
117
|
+
*/
|
|
118
|
+
declare const easeInQuart: EasingFunction;
|
|
119
|
+
/**
|
|
120
|
+
* Quartic ease-out: fast start, decelerating.
|
|
121
|
+
*/
|
|
122
|
+
declare const easeOutQuart: EasingFunction;
|
|
123
|
+
/**
|
|
124
|
+
* Quartic ease-in-out: slow start and end.
|
|
125
|
+
*/
|
|
126
|
+
declare const easeInOutQuart: EasingFunction;
|
|
127
|
+
/**
|
|
128
|
+
* Quintic ease-in: slow start, accelerating.
|
|
129
|
+
*/
|
|
130
|
+
declare const easeInQuint: EasingFunction;
|
|
131
|
+
/**
|
|
132
|
+
* Quintic ease-out: fast start, decelerating.
|
|
133
|
+
*/
|
|
134
|
+
declare const easeOutQuint: EasingFunction;
|
|
135
|
+
/**
|
|
136
|
+
* Quintic ease-in-out: slow start and end.
|
|
137
|
+
*/
|
|
138
|
+
declare const easeInOutQuint: EasingFunction;
|
|
139
|
+
/**
|
|
140
|
+
* Sinusoidal ease-in: uses sine curve for smooth acceleration.
|
|
141
|
+
*/
|
|
142
|
+
declare const easeInSine: EasingFunction;
|
|
143
|
+
/**
|
|
144
|
+
* Sinusoidal ease-out: uses sine curve for smooth deceleration.
|
|
145
|
+
*/
|
|
146
|
+
declare const easeOutSine: EasingFunction;
|
|
147
|
+
/**
|
|
148
|
+
* Sinusoidal ease-in-out: smooth S-curve using sine.
|
|
149
|
+
*/
|
|
150
|
+
declare const easeInOutSine: EasingFunction;
|
|
151
|
+
/**
|
|
152
|
+
* Exponential ease-in: dramatic acceleration.
|
|
153
|
+
*/
|
|
154
|
+
declare const easeInExpo: EasingFunction;
|
|
155
|
+
/**
|
|
156
|
+
* Exponential ease-out: dramatic deceleration.
|
|
157
|
+
*/
|
|
158
|
+
declare const easeOutExpo: EasingFunction;
|
|
159
|
+
/**
|
|
160
|
+
* Exponential ease-in-out: dramatic S-curve.
|
|
161
|
+
*/
|
|
162
|
+
declare const easeInOutExpo: EasingFunction;
|
|
163
|
+
/**
|
|
164
|
+
* Circular ease-in: quarter circle acceleration.
|
|
165
|
+
*/
|
|
166
|
+
declare const easeInCirc: EasingFunction;
|
|
167
|
+
/**
|
|
168
|
+
* Circular ease-out: quarter circle deceleration.
|
|
169
|
+
*/
|
|
170
|
+
declare const easeOutCirc: EasingFunction;
|
|
171
|
+
/**
|
|
172
|
+
* Circular ease-in-out: half circle S-curve.
|
|
173
|
+
*/
|
|
174
|
+
declare const easeInOutCirc: EasingFunction;
|
|
175
|
+
/**
|
|
176
|
+
* Back ease-in: pulls back before accelerating forward.
|
|
177
|
+
*/
|
|
178
|
+
declare const easeInBack: EasingFunction;
|
|
179
|
+
/**
|
|
180
|
+
* Back ease-out: overshoots then settles.
|
|
181
|
+
*/
|
|
182
|
+
declare const easeOutBack: EasingFunction;
|
|
183
|
+
/**
|
|
184
|
+
* Back ease-in-out: pulls back, overshoots, then settles.
|
|
185
|
+
*/
|
|
186
|
+
declare const easeInOutBack: EasingFunction;
|
|
187
|
+
/**
|
|
188
|
+
* Elastic ease-in: builds up elastic energy.
|
|
189
|
+
*/
|
|
190
|
+
declare const easeInElastic: EasingFunction;
|
|
191
|
+
/**
|
|
192
|
+
* Elastic ease-out: releases elastic energy with overshoot oscillation.
|
|
193
|
+
*/
|
|
194
|
+
declare const easeOutElastic: EasingFunction;
|
|
195
|
+
/**
|
|
196
|
+
* Elastic ease-in-out: elastic effect on both ends.
|
|
197
|
+
*/
|
|
198
|
+
declare const easeInOutElastic: EasingFunction;
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Bounce ease-in: bounces before settling.
|
|
202
|
+
*/
|
|
203
|
+
declare const easeInBounce: EasingFunction;
|
|
204
|
+
/**
|
|
205
|
+
* Bounce ease-out: bounces at the end.
|
|
206
|
+
*/
|
|
207
|
+
declare const easeOutBounce: EasingFunction;
|
|
208
|
+
/**
|
|
209
|
+
* Bounce ease-in-out: bounces at both ends.
|
|
210
|
+
*/
|
|
211
|
+
declare const easeInOutBounce: EasingFunction;
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Smooth S-curve using cubic smoothstep.
|
|
215
|
+
* This is the DEFAULT easing for all Manim animations.
|
|
216
|
+
* Formula: 3t² - 2t³
|
|
217
|
+
*/
|
|
218
|
+
declare const smooth: EasingFunction;
|
|
219
|
+
/**
|
|
220
|
+
* Applies smooth twice for extra smoothness.
|
|
221
|
+
* Creates an even more gradual transition at the endpoints.
|
|
222
|
+
*/
|
|
223
|
+
declare const doubleSmooth: EasingFunction;
|
|
224
|
+
/**
|
|
225
|
+
* Starts fast, decelerates at end (rush into the destination).
|
|
226
|
+
* Uses sqrt for fast start that slows down.
|
|
227
|
+
*/
|
|
228
|
+
declare const rushInto: EasingFunction;
|
|
229
|
+
/**
|
|
230
|
+
* Slow start, accelerates from beginning (rush from the start).
|
|
231
|
+
* Uses quadratic for slow start that speeds up.
|
|
232
|
+
*/
|
|
233
|
+
declare const rushFrom: EasingFunction;
|
|
234
|
+
/**
|
|
235
|
+
* Starts normal, slows into the end.
|
|
236
|
+
*/
|
|
237
|
+
declare const slowInto: EasingFunction;
|
|
238
|
+
/**
|
|
239
|
+
* Goes from 0 to 1 and back to 0.
|
|
240
|
+
* Useful for temporary effects.
|
|
241
|
+
*/
|
|
242
|
+
declare const thereAndBack: EasingFunction;
|
|
243
|
+
/** Goes from 0 to 1 and back to 0 with a pause at the peak. */
|
|
244
|
+
declare function thereAndBackWithPause(pauseRatio?: number): EasingFunction;
|
|
245
|
+
/** Overshoots slightly then settles (like a running start). */
|
|
246
|
+
declare function runningStart(pullFactor?: number): EasingFunction;
|
|
247
|
+
/**
|
|
248
|
+
* Oscillates back and forth (wiggle/shake effect).
|
|
249
|
+
* Creates a wobbling motion that ends at 1.
|
|
250
|
+
*/
|
|
251
|
+
declare const wiggle: EasingFunction;
|
|
252
|
+
/** Approaches but doesn't quite reach 1 (asymptotic approach). */
|
|
253
|
+
declare function notQuiteThere(proportion?: number): EasingFunction;
|
|
254
|
+
/** Reaches the destination early and stays there. */
|
|
255
|
+
declare function lingering(proportion?: number): EasingFunction;
|
|
256
|
+
/** Asymptotically approaches 1 via exponential decay. */
|
|
257
|
+
declare function exponentialDecay(halfLife?: number): EasingFunction;
|
|
258
|
+
|
|
259
|
+
/** @throws Error if an easing with the given name already exists. */
|
|
260
|
+
declare function registerEasing(name: string, fn: EasingFunction): void;
|
|
261
|
+
declare function getEasing(name: string): EasingFunction | undefined;
|
|
262
|
+
declare function hasEasing(name: string): boolean;
|
|
263
|
+
declare function unregisterEasing(name: string): boolean;
|
|
264
|
+
/** Clears all registered custom easings (useful for testing). */
|
|
265
|
+
declare function clearRegistry(): void;
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* Manages a queue of animations for fluent chaining.
|
|
269
|
+
* This is an internal implementation detail of Mobject's fluent API.
|
|
270
|
+
*/
|
|
271
|
+
declare class AnimationQueue {
|
|
272
|
+
private readonly target;
|
|
273
|
+
private readonly queue;
|
|
274
|
+
constructor(target: Mobject);
|
|
275
|
+
enqueueAnimation(animation: Animation<Mobject>): void;
|
|
276
|
+
setLastDuration(seconds: number): void;
|
|
277
|
+
setLastEasing(easing: EasingFunction): void;
|
|
278
|
+
isEmpty(): boolean;
|
|
279
|
+
popLastAnimation(): Animation<Mobject> | null;
|
|
280
|
+
toAnimation(): Animation<Mobject>;
|
|
281
|
+
getTotalDuration(): number;
|
|
282
|
+
}
|
|
283
|
+
interface MobjectState {
|
|
284
|
+
position: Vector2;
|
|
285
|
+
scale: Vector2;
|
|
286
|
+
rotation: number;
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Base class for all mathematical objects.
|
|
290
|
+
* Manages position, rotation, scale, and opacity via a local transformation matrix.
|
|
291
|
+
* Includes fluent animation API for chainable animations.
|
|
292
|
+
*/
|
|
293
|
+
declare class Mobject {
|
|
294
|
+
protected localMatrix: Matrix3x3;
|
|
295
|
+
protected opacityValue: number;
|
|
296
|
+
protected animQueue: AnimationQueue | null;
|
|
297
|
+
private savedStates;
|
|
298
|
+
parent: Mobject | null;
|
|
299
|
+
constructor();
|
|
300
|
+
protected getQueue(): AnimationQueue;
|
|
301
|
+
get matrix(): Matrix3x3;
|
|
302
|
+
getWorldMatrix(): Matrix3x3;
|
|
303
|
+
get position(): Vector2;
|
|
304
|
+
get rotation(): number;
|
|
305
|
+
get scale(): Vector2;
|
|
306
|
+
get opacity(): number;
|
|
307
|
+
pos(x: number, y: number): this;
|
|
308
|
+
show(): this;
|
|
309
|
+
hide(): this;
|
|
310
|
+
setOpacity(value: number): this;
|
|
311
|
+
setRotation(angle: number): this;
|
|
312
|
+
setScale(sx: number, sy: number): this;
|
|
313
|
+
applyMatrix(m: Matrix3x3): this;
|
|
314
|
+
saveState(): this;
|
|
315
|
+
getSavedState(): MobjectState | undefined;
|
|
316
|
+
clearSavedStates(): this;
|
|
317
|
+
/**
|
|
318
|
+
* Animates back to the last saved state.
|
|
319
|
+
* Pops the saved state from the stack.
|
|
320
|
+
* @throws Error if no state was previously saved
|
|
321
|
+
*/
|
|
322
|
+
restore(durationSeconds?: number): this & {
|
|
323
|
+
toAnimation(): Animation<Mobject>;
|
|
324
|
+
};
|
|
325
|
+
private createAnimation;
|
|
326
|
+
fadeIn(durationSeconds?: number): this & {
|
|
327
|
+
toAnimation(): Animation<Mobject>;
|
|
328
|
+
};
|
|
329
|
+
fadeOut(durationSeconds?: number): this & {
|
|
330
|
+
toAnimation(): Animation<Mobject>;
|
|
331
|
+
};
|
|
332
|
+
moveTo(x: number, y: number, durationSeconds?: number): this & {
|
|
333
|
+
toAnimation(): Animation<Mobject>;
|
|
334
|
+
};
|
|
335
|
+
rotate(angle: number, durationSeconds?: number): this & {
|
|
336
|
+
toAnimation(): Animation<Mobject>;
|
|
337
|
+
};
|
|
338
|
+
scaleTo(factor: number, durationSeconds?: number): this & {
|
|
339
|
+
toAnimation(): Animation<Mobject>;
|
|
340
|
+
};
|
|
341
|
+
scaleToXY(factorX: number, factorY: number, durationSeconds?: number): this & {
|
|
342
|
+
toAnimation(): Animation<Mobject>;
|
|
343
|
+
};
|
|
344
|
+
duration(seconds: number): this;
|
|
345
|
+
ease(easing: EasingFunction): this;
|
|
346
|
+
toAnimation(): Animation<Mobject>;
|
|
347
|
+
getQueuedDuration(): number;
|
|
348
|
+
hasQueuedAnimations(): boolean;
|
|
349
|
+
/**
|
|
350
|
+
* Queues multiple animations to run in parallel (simultaneously).
|
|
351
|
+
* Automatically handles both Animation objects and mobject method calls.
|
|
352
|
+
* @example
|
|
353
|
+
* circle.fadeIn(1).parallel(
|
|
354
|
+
* circle.moveTo(100, 50),
|
|
355
|
+
* circle.rotate(Math.PI)
|
|
356
|
+
* ).fadeOut(1);
|
|
357
|
+
*/
|
|
358
|
+
parallel(...items: (Animation<Mobject> | Mobject)[]): this;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* Configuration options for animations.
|
|
363
|
+
*/
|
|
364
|
+
interface AnimationConfig {
|
|
365
|
+
/** Duration of the animation in seconds. Default: 1 */
|
|
366
|
+
readonly durationSeconds: number;
|
|
367
|
+
/** Easing function to apply. Default: smooth */
|
|
368
|
+
readonly easing: EasingFunction;
|
|
369
|
+
/** Delay before animation starts in seconds. Default: 0 */
|
|
370
|
+
readonly delaySeconds: number;
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* Animation lifecycle category determines how Scene.play() handles the target.
|
|
374
|
+
* - 'introductory': Auto-registers target with scene (FadeIn, Create, Draw, Write)
|
|
375
|
+
* - 'transformative': Requires target to already be in scene (MoveTo, Rotate, Scale)
|
|
376
|
+
* - 'exit': Requires target in scene, may auto-remove after (FadeOut)
|
|
377
|
+
*/
|
|
378
|
+
type AnimationLifecycle = 'introductory' | 'transformative' | 'exit';
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* Abstract base class for all animations.
|
|
382
|
+
* Provides configuration for duration, easing, and delay.
|
|
383
|
+
* Subclasses must specify their lifecycle category.
|
|
384
|
+
*/
|
|
385
|
+
declare abstract class Animation<T extends Mobject = Mobject> {
|
|
386
|
+
protected readonly target: T;
|
|
387
|
+
protected durationSeconds: number;
|
|
388
|
+
protected easingFn: EasingFunction;
|
|
389
|
+
protected delaySeconds: number;
|
|
390
|
+
/**
|
|
391
|
+
* The lifecycle category of this animation.
|
|
392
|
+
* Determines how Scene.play() handles scene registration and validation.
|
|
393
|
+
*/
|
|
394
|
+
abstract readonly lifecycle: AnimationLifecycle;
|
|
395
|
+
constructor(target: T);
|
|
396
|
+
duration(seconds: number): this;
|
|
397
|
+
ease(easing: EasingFunction): this;
|
|
398
|
+
delay(seconds: number): this;
|
|
399
|
+
getDuration(): number;
|
|
400
|
+
getDelay(): number;
|
|
401
|
+
getEasing(): EasingFunction;
|
|
402
|
+
getTarget(): T;
|
|
403
|
+
getConfig(): AnimationConfig;
|
|
404
|
+
abstract interpolate(progress: number): void;
|
|
405
|
+
/**
|
|
406
|
+
* Ensures the animation is initialized before interpolation.
|
|
407
|
+
* Called before first update to capture start state.
|
|
408
|
+
* Default: no-op. Override in subclasses that need lazy initialization.
|
|
409
|
+
*/
|
|
410
|
+
ensureInitialized(): void;
|
|
411
|
+
/**
|
|
412
|
+
* Resets the animation to its uninitialized state.
|
|
413
|
+
* Allows animations to be replayed or looped.
|
|
414
|
+
*/
|
|
415
|
+
reset(): void;
|
|
416
|
+
update(progress: number): void;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
/**
|
|
420
|
+
* Represents an animation scheduled at a specific time on the Timeline.
|
|
421
|
+
*/
|
|
422
|
+
interface ScheduledAnimation {
|
|
423
|
+
/** The animation to play */
|
|
424
|
+
readonly animation: Animation;
|
|
425
|
+
/** Start time in seconds from timeline beginning */
|
|
426
|
+
readonly startTime: number;
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* Configuration options for Timeline.
|
|
430
|
+
*/
|
|
431
|
+
interface TimelineConfig {
|
|
432
|
+
/** Whether the timeline loops. Default: false */
|
|
433
|
+
readonly loop?: boolean;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* Timeline schedules and controls playback of animations.
|
|
438
|
+
* Animations can be scheduled at specific times and the timeline
|
|
439
|
+
* provides seek/state access for non-linear playback.
|
|
440
|
+
*/
|
|
441
|
+
declare class Timeline {
|
|
442
|
+
private readonly scheduled;
|
|
443
|
+
private readonly config;
|
|
444
|
+
private currentTime;
|
|
445
|
+
constructor(config?: TimelineConfig);
|
|
446
|
+
/**
|
|
447
|
+
* Schedule an animation to start at a specific time.
|
|
448
|
+
* @param animation The animation to schedule
|
|
449
|
+
* @param startTime Start time in seconds (default: 0)
|
|
450
|
+
*/
|
|
451
|
+
schedule(animation: Animation, startTime?: number): this;
|
|
452
|
+
/**
|
|
453
|
+
* Schedule multiple animations to play in sequence.
|
|
454
|
+
* First animation starts at the given startTime, subsequent
|
|
455
|
+
* animations start after the previous one ends.
|
|
456
|
+
* @param animations Animations to schedule sequentially
|
|
457
|
+
* @param startTime Start time for the first animation (default: 0)
|
|
458
|
+
*/
|
|
459
|
+
scheduleSequence(animations: Animation[], startTime?: number): this;
|
|
460
|
+
/**
|
|
461
|
+
* Schedule multiple animations to play in parallel.
|
|
462
|
+
* All animations start at the same time.
|
|
463
|
+
* @param animations Animations to schedule in parallel
|
|
464
|
+
* @param startTime Start time for all animations (default: 0)
|
|
465
|
+
*/
|
|
466
|
+
scheduleParallel(animations: Animation[], startTime?: number): this;
|
|
467
|
+
/**
|
|
468
|
+
* Get all scheduled animations with resolved timing information.
|
|
469
|
+
*/
|
|
470
|
+
private getResolved;
|
|
471
|
+
/**
|
|
472
|
+
* Get total duration of the timeline.
|
|
473
|
+
* Returns the end time of the last animation to finish.
|
|
474
|
+
*/
|
|
475
|
+
getTotalDuration(): number;
|
|
476
|
+
/**
|
|
477
|
+
* Seek to a specific time and update all animations.
|
|
478
|
+
* @param time Time in seconds to seek to
|
|
479
|
+
*/
|
|
480
|
+
seek(time: number): void;
|
|
481
|
+
/**
|
|
482
|
+
* Get the timeline state at a specific time without modifying the
|
|
483
|
+
* current playhead position.
|
|
484
|
+
* @param time Time in seconds
|
|
485
|
+
*/
|
|
486
|
+
getStateAt(time: number): void;
|
|
487
|
+
/**
|
|
488
|
+
* Get the current time of the timeline.
|
|
489
|
+
*/
|
|
490
|
+
getCurrentTime(): number;
|
|
491
|
+
/**
|
|
492
|
+
* Get all scheduled animations.
|
|
493
|
+
*/
|
|
494
|
+
getScheduled(): readonly ScheduledAnimation[];
|
|
495
|
+
/**
|
|
496
|
+
* Check if timeline is configured to loop.
|
|
497
|
+
*/
|
|
498
|
+
isLooping(): boolean;
|
|
499
|
+
/**
|
|
500
|
+
* Clear all scheduled animations.
|
|
501
|
+
*/
|
|
502
|
+
clear(): void;
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
/**
|
|
506
|
+
* Executes animations in sequence, one after another.
|
|
507
|
+
* Total duration equals the sum of all child animation durations.
|
|
508
|
+
*
|
|
509
|
+
* This is a composition animation - its lifecycle is determined by its children.
|
|
510
|
+
* Only the first child is initialized when the sequence starts; subsequent
|
|
511
|
+
* children are initialized when they become active.
|
|
512
|
+
*/
|
|
513
|
+
declare class Sequence extends Animation<Mobject> {
|
|
514
|
+
private readonly children;
|
|
515
|
+
private readonly childDurations;
|
|
516
|
+
private readonly totalChildDuration;
|
|
517
|
+
/**
|
|
518
|
+
* The lifecycle of Sequence is determined by its FIRST child animation.
|
|
519
|
+
* If the first animation is introductory, it will register the target,
|
|
520
|
+
* allowing subsequent transformative animations to work.
|
|
521
|
+
*/
|
|
522
|
+
readonly lifecycle: AnimationLifecycle;
|
|
523
|
+
constructor(animations: Animation[]);
|
|
524
|
+
getDuration(): number;
|
|
525
|
+
getChildren(): readonly Animation[];
|
|
526
|
+
/**
|
|
527
|
+
* Initializes only the first child.
|
|
528
|
+
* Later children are initialized when they become active in interpolate().
|
|
529
|
+
*/
|
|
530
|
+
ensureInitialized(): void;
|
|
531
|
+
reset(): void;
|
|
532
|
+
/**
|
|
533
|
+
* Interpolates the sequence at the given progress.
|
|
534
|
+
* Maps global progress to the correct child animation.
|
|
535
|
+
*
|
|
536
|
+
* IMPORTANT: We only update children that have started or completed.
|
|
537
|
+
* Children that haven't started yet are NOT updated to avoid
|
|
538
|
+
* premature initialization with incorrect state.
|
|
539
|
+
*/
|
|
540
|
+
interpolate(progress: number): void;
|
|
541
|
+
update(progress: number): void;
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
/**
|
|
545
|
+
* Executes animations in parallel, all starting at the same time.
|
|
546
|
+
* Total duration equals the maximum of all child animation durations.
|
|
547
|
+
*
|
|
548
|
+
* This is a composition animation - its lifecycle is determined by its children.
|
|
549
|
+
* By default, uses 'transformative' lifecycle if children are mixed.
|
|
550
|
+
*
|
|
551
|
+
* All children are initialized together before any interpolation begins,
|
|
552
|
+
* ensuring they all capture state at the same moment.
|
|
553
|
+
*/
|
|
554
|
+
declare class Parallel extends Animation<Mobject> {
|
|
555
|
+
private readonly children;
|
|
556
|
+
private readonly maxChildDuration;
|
|
557
|
+
/**
|
|
558
|
+
* The lifecycle of Parallel is 'introductory' only if ALL children are introductory.
|
|
559
|
+
* Otherwise, it defaults to 'transformative'.
|
|
560
|
+
*/
|
|
561
|
+
readonly lifecycle: AnimationLifecycle;
|
|
562
|
+
constructor(animations: Animation[]);
|
|
563
|
+
getDuration(): number;
|
|
564
|
+
getChildren(): readonly Animation[];
|
|
565
|
+
/**
|
|
566
|
+
* Ensures all children are initialized together.
|
|
567
|
+
* This captures start state for all parallel animations at the same moment.
|
|
568
|
+
*/
|
|
569
|
+
ensureInitialized(): void;
|
|
570
|
+
reset(): void;
|
|
571
|
+
/**
|
|
572
|
+
* Interpolates all child animations at the given progress.
|
|
573
|
+
* Each child's progress is scaled based on its duration relative to the container.
|
|
574
|
+
*/
|
|
575
|
+
interpolate(progress: number): void;
|
|
576
|
+
update(progress: number): void;
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
/**
|
|
580
|
+
* Configuration options for CameraFrame.
|
|
581
|
+
*/
|
|
582
|
+
interface CameraFrameConfig {
|
|
583
|
+
/** Width of the viewport in pixels. Defaults to 1920. */
|
|
584
|
+
pixelWidth?: number;
|
|
585
|
+
/** Height of the viewport in pixels. Defaults to 1080. */
|
|
586
|
+
pixelHeight?: number;
|
|
587
|
+
}
|
|
588
|
+
/**
|
|
589
|
+
* Camera bounds that limit how far the camera can pan.
|
|
590
|
+
*/
|
|
591
|
+
interface Bounds {
|
|
592
|
+
minX: number;
|
|
593
|
+
maxX: number;
|
|
594
|
+
minY: number;
|
|
595
|
+
maxY: number;
|
|
596
|
+
}
|
|
597
|
+
/**
|
|
598
|
+
* CameraFrame represents the viewport window in world space.
|
|
599
|
+
* Extends Mobject (not VMobject - no visual representation).
|
|
600
|
+
* Its transform properties define what the camera shows:
|
|
601
|
+
* - scale(2) = zoom OUT (larger frame = see more)
|
|
602
|
+
* - scale(0.5) = zoom IN (smaller frame = see less)
|
|
603
|
+
*
|
|
604
|
+
* The CameraFrame is the primary way to control camera animations in Anima.
|
|
605
|
+
* Access it via `scene.frame` or `scene.camera.frame`.
|
|
606
|
+
*
|
|
607
|
+
* @example
|
|
608
|
+
* // Zoom in over 1 second
|
|
609
|
+
* this.play(this.frame.zoomIn(2).duration(1));
|
|
610
|
+
*
|
|
611
|
+
* @example
|
|
612
|
+
* // Pan to center on an object
|
|
613
|
+
* this.play(this.frame.centerOn(circle).duration(0.5));
|
|
614
|
+
*
|
|
615
|
+
* @example
|
|
616
|
+
* // Fit multiple objects in view
|
|
617
|
+
* this.play(this.frame.fitTo([obj1, obj2, obj3]).duration(1));
|
|
618
|
+
*/
|
|
619
|
+
declare class CameraFrame extends Mobject {
|
|
620
|
+
private readonly baseWidth;
|
|
621
|
+
private readonly baseHeight;
|
|
622
|
+
private bounds?;
|
|
623
|
+
/**
|
|
624
|
+
* Creates a new CameraFrame with the specified viewport dimensions.
|
|
625
|
+
*
|
|
626
|
+
* @param config - Configuration options
|
|
627
|
+
* @param config.pixelWidth - Width of the viewport in pixels (default: 1920)
|
|
628
|
+
* @param config.pixelHeight - Height of the viewport in pixels (default: 1080)
|
|
629
|
+
*
|
|
630
|
+
* @example
|
|
631
|
+
* const frame = new CameraFrame({ pixelWidth: 1920, pixelHeight: 1080 });
|
|
632
|
+
*/
|
|
633
|
+
constructor(config?: CameraFrameConfig);
|
|
634
|
+
/**
|
|
635
|
+
* The current width of the frame in world units, accounting for scale.
|
|
636
|
+
* @returns The frame width multiplied by the current scale.x
|
|
637
|
+
*/
|
|
638
|
+
get width(): number;
|
|
639
|
+
/**
|
|
640
|
+
* The current height of the frame in world units, accounting for scale.
|
|
641
|
+
* @returns The frame height multiplied by the current scale.y
|
|
642
|
+
*/
|
|
643
|
+
get height(): number;
|
|
644
|
+
/**
|
|
645
|
+
* Sets the scale of the camera frame.
|
|
646
|
+
* Overrides Mobject.setScale to prevent zero or negative scales.
|
|
647
|
+
*
|
|
648
|
+
* @param sx - Scale factor for the x-axis (must be positive)
|
|
649
|
+
* @param sy - Scale factor for the y-axis (must be positive)
|
|
650
|
+
* @returns This CameraFrame for method chaining
|
|
651
|
+
* @throws Error if sx or sy is zero or negative
|
|
652
|
+
*
|
|
653
|
+
* @example
|
|
654
|
+
* frame.setScale(2, 2); // Zoom out 2x
|
|
655
|
+
* frame.setScale(0.5, 0.5); // Zoom in 2x
|
|
656
|
+
*/
|
|
657
|
+
setScale(sx: number, sy: number): this;
|
|
658
|
+
/**
|
|
659
|
+
* Sets bounds that limit how far the camera can pan.
|
|
660
|
+
* When bounds are set, the camera position is clamped to stay within them,
|
|
661
|
+
* accounting for the frame size so edges don't go outside bounds.
|
|
662
|
+
*
|
|
663
|
+
* @param minX - Minimum x coordinate
|
|
664
|
+
* @param minY - Minimum y coordinate
|
|
665
|
+
* @param maxX - Maximum x coordinate
|
|
666
|
+
* @param maxY - Maximum y coordinate
|
|
667
|
+
* @returns This CameraFrame for method chaining
|
|
668
|
+
*
|
|
669
|
+
* @example
|
|
670
|
+
* // Limit camera to a 100x100 world area
|
|
671
|
+
* frame.setBounds(0, 0, 100, 100);
|
|
672
|
+
*/
|
|
673
|
+
setBounds(minX: number, minY: number, maxX: number, maxY: number): this;
|
|
674
|
+
/**
|
|
675
|
+
* Removes any bounds restrictions on camera movement.
|
|
676
|
+
*
|
|
677
|
+
* @returns This CameraFrame for method chaining
|
|
678
|
+
*
|
|
679
|
+
* @example
|
|
680
|
+
* frame.clearBounds(); // Camera can now pan freely
|
|
681
|
+
*/
|
|
682
|
+
clearBounds(): this;
|
|
683
|
+
/**
|
|
684
|
+
* Checks if the camera has bounds set.
|
|
685
|
+
*
|
|
686
|
+
* @returns True if bounds are set, false otherwise
|
|
687
|
+
*/
|
|
688
|
+
hasBounds(): boolean;
|
|
689
|
+
/**
|
|
690
|
+
* Gets the current bounds configuration.
|
|
691
|
+
*
|
|
692
|
+
* @returns The bounds object or undefined if no bounds are set
|
|
693
|
+
*/
|
|
694
|
+
getBounds(): Bounds | undefined;
|
|
695
|
+
/**
|
|
696
|
+
* Sets the position of the camera frame.
|
|
697
|
+
* Overrides Mobject.pos to clamp position within bounds if set.
|
|
698
|
+
*
|
|
699
|
+
* @param x - The x coordinate in world space
|
|
700
|
+
* @param y - The y coordinate in world space
|
|
701
|
+
* @returns This CameraFrame for method chaining
|
|
702
|
+
*
|
|
703
|
+
* @example
|
|
704
|
+
* frame.pos(5, 3); // Move camera center to (5, 3)
|
|
705
|
+
*/
|
|
706
|
+
pos(x: number, y: number): this;
|
|
707
|
+
/**
|
|
708
|
+
* Smoothly zoom the camera in by the given factor.
|
|
709
|
+
* Internally scales the frame down, which makes objects appear larger.
|
|
710
|
+
*
|
|
711
|
+
* @param factor - Zoom multiplier. 2 = objects appear 2x larger (default: 2)
|
|
712
|
+
* @returns FluentAnimation that can be chained with .duration() and .ease()
|
|
713
|
+
* @throws Error if factor is zero or negative
|
|
714
|
+
*
|
|
715
|
+
* @example
|
|
716
|
+
* // Zoom in 2x over 1 second
|
|
717
|
+
* this.play(this.frame.zoomIn(2).duration(1));
|
|
718
|
+
*
|
|
719
|
+
* @example
|
|
720
|
+
* // Zoom in 3x with easing
|
|
721
|
+
* this.play(this.frame.zoomIn(3).duration(1.5).ease(easeInOutQuad));
|
|
722
|
+
*/
|
|
723
|
+
zoomIn(factor?: number): this & {
|
|
724
|
+
toAnimation(): Animation<Mobject>;
|
|
725
|
+
};
|
|
726
|
+
/**
|
|
727
|
+
* Smoothly zoom the camera out by the given factor.
|
|
728
|
+
* Internally scales the frame up, which makes objects appear smaller.
|
|
729
|
+
*
|
|
730
|
+
* @param factor - Zoom multiplier. 2 = objects appear 2x smaller (default: 2)
|
|
731
|
+
* @returns FluentAnimation that can be chained with .duration() and .ease()
|
|
732
|
+
* @throws Error if factor is zero or negative
|
|
733
|
+
*
|
|
734
|
+
* @example
|
|
735
|
+
* // Zoom out 2x over 1 second
|
|
736
|
+
* this.play(this.frame.zoomOut(2).duration(1));
|
|
737
|
+
*
|
|
738
|
+
* @example
|
|
739
|
+
* // Zoom out to show more of the scene
|
|
740
|
+
* this.play(this.frame.zoomOut(4).duration(2).ease(easeOutCubic));
|
|
741
|
+
*/
|
|
742
|
+
zoomOut(factor?: number): this & {
|
|
743
|
+
toAnimation(): Animation<Mobject>;
|
|
744
|
+
};
|
|
745
|
+
/**
|
|
746
|
+
* Move the camera to center on a target Mobject.
|
|
747
|
+
* The camera will smoothly pan so the target is at the center of the frame.
|
|
748
|
+
*
|
|
749
|
+
* @param target - The Mobject to center on
|
|
750
|
+
* @returns FluentAnimation that can be chained with .duration() and .ease()
|
|
751
|
+
* @throws Error if target is null or undefined
|
|
752
|
+
*
|
|
753
|
+
* @example
|
|
754
|
+
* // Center on a circle over 0.5 seconds
|
|
755
|
+
* this.play(this.frame.centerOn(circle).duration(0.5));
|
|
756
|
+
*
|
|
757
|
+
* @example
|
|
758
|
+
* // Pan to focus on different objects in sequence
|
|
759
|
+
* await this.play(this.frame.centerOn(obj1).duration(1));
|
|
760
|
+
* await this.play(this.frame.centerOn(obj2).duration(1));
|
|
761
|
+
*/
|
|
762
|
+
centerOn(target: Mobject): this & {
|
|
763
|
+
toAnimation(): Animation<Mobject>;
|
|
764
|
+
};
|
|
765
|
+
/**
|
|
766
|
+
* Zoom in/out while keeping a specific world point fixed on screen.
|
|
767
|
+
* Like pinch-to-zoom behavior where the pinch point stays stationary.
|
|
768
|
+
*
|
|
769
|
+
* Uses the formula: C' = P * (1 - factor) + C * factor
|
|
770
|
+
* Where P = point, C = current center, factor = zoom factor.
|
|
771
|
+
*
|
|
772
|
+
* @param factor - Scale multiplier. Less than 1 for zoom in, greater than 1 for zoom out
|
|
773
|
+
* @param point - World coordinates to keep fixed on screen
|
|
774
|
+
* @returns Parallel animation combining move and scale
|
|
775
|
+
* @throws Error if factor is zero or negative
|
|
776
|
+
*
|
|
777
|
+
* @example
|
|
778
|
+
* // Zoom in 2x on a specific point
|
|
779
|
+
* this.play(frame.zoomToPoint(0.5, { x: 5, y: 5 }).duration(1));
|
|
780
|
+
*
|
|
781
|
+
* @example
|
|
782
|
+
* // Zoom out while keeping an object's position fixed
|
|
783
|
+
* this.play(frame.zoomToPoint(2, circle.position).duration(1));
|
|
784
|
+
*/
|
|
785
|
+
zoomToPoint(factor: number, point: {
|
|
786
|
+
x: number;
|
|
787
|
+
y: number;
|
|
788
|
+
}): Parallel;
|
|
789
|
+
/**
|
|
790
|
+
* Automatically frame one or more objects with optional margin.
|
|
791
|
+
* Calculates the bounding box of all targets and animates the camera
|
|
792
|
+
* to show them all with the specified margin around them.
|
|
793
|
+
*
|
|
794
|
+
* @param targets - Single Mobject or array of Mobjects to frame
|
|
795
|
+
* @param margin - Padding around the objects in world units (default: 0.5)
|
|
796
|
+
* @returns FluentAnimation that can be chained with .duration() and .ease()
|
|
797
|
+
* @throws Error if targets array is empty
|
|
798
|
+
*
|
|
799
|
+
* @example
|
|
800
|
+
* // Fit a single object with default margin
|
|
801
|
+
* this.play(this.frame.fitTo(circle).duration(1));
|
|
802
|
+
*
|
|
803
|
+
* @example
|
|
804
|
+
* // Fit multiple objects with custom margin
|
|
805
|
+
* this.play(this.frame.fitTo([obj1, obj2, obj3], 1.0).duration(1.5));
|
|
806
|
+
*
|
|
807
|
+
* @example
|
|
808
|
+
* // Show all objects in the scene
|
|
809
|
+
* this.play(this.frame.fitTo(allObjects, 0).duration(2));
|
|
810
|
+
*/
|
|
811
|
+
fitTo(targets: Mobject | Mobject[], margin?: number): this & {
|
|
812
|
+
toAnimation(): Animation<Mobject>;
|
|
813
|
+
};
|
|
814
|
+
private calculateBounds;
|
|
815
|
+
private hasGetBoundingBox;
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
/**
|
|
819
|
+
* Configuration options for Camera.
|
|
820
|
+
*/
|
|
821
|
+
interface CameraConfig {
|
|
822
|
+
/** Pixel width for aspect ratio calculation. Default: 1920 */
|
|
823
|
+
readonly pixelWidth?: number;
|
|
824
|
+
/** Pixel height for aspect ratio calculation. Default: 1080 */
|
|
825
|
+
readonly pixelHeight?: number;
|
|
826
|
+
}
|
|
827
|
+
/**
|
|
828
|
+
* Resolved camera configuration with all defaults applied.
|
|
829
|
+
*/
|
|
830
|
+
interface ResolvedCameraConfig {
|
|
831
|
+
readonly pixelWidth: number;
|
|
832
|
+
readonly pixelHeight: number;
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
/**
|
|
836
|
+
* Camera manages the view into the scene.
|
|
837
|
+
* Uses CameraFrame (a Mobject) to store transform state, enabling camera animations.
|
|
838
|
+
*
|
|
839
|
+
* The Camera provides both instant manipulation methods (panTo, zoomTo) and
|
|
840
|
+
* access to the CameraFrame for fluent animation APIs.
|
|
841
|
+
*
|
|
842
|
+
* @example
|
|
843
|
+
* // Instant camera manipulation
|
|
844
|
+
* camera.zoomTo(2);
|
|
845
|
+
* camera.panTo(new Vector2(5, 3));
|
|
846
|
+
*
|
|
847
|
+
* @example
|
|
848
|
+
* // Animated camera movement via frame
|
|
849
|
+
* this.play(this.frame.zoomIn(2).duration(1));
|
|
850
|
+
* this.play(this.frame.centerOn(circle).duration(0.5));
|
|
851
|
+
*/
|
|
852
|
+
declare class Camera {
|
|
853
|
+
private readonly config;
|
|
854
|
+
/** The CameraFrame that stores the camera's transform state. Use this for animations. */
|
|
855
|
+
readonly frame: CameraFrame;
|
|
856
|
+
/**
|
|
857
|
+
* Creates a new Camera with the specified viewport dimensions.
|
|
858
|
+
*
|
|
859
|
+
* @param config - Configuration options
|
|
860
|
+
* @param config.pixelWidth - Width of the viewport in pixels (default: 1920)
|
|
861
|
+
* @param config.pixelHeight - Height of the viewport in pixels (default: 1080)
|
|
862
|
+
*/
|
|
863
|
+
constructor(config?: CameraConfig);
|
|
864
|
+
get frameHeight(): number;
|
|
865
|
+
get frameWidth(): number;
|
|
866
|
+
get frameYRadius(): number;
|
|
867
|
+
get frameXRadius(): number;
|
|
868
|
+
get pixelWidth(): number;
|
|
869
|
+
get pixelHeight(): number;
|
|
870
|
+
get position(): Vector2;
|
|
871
|
+
get zoom(): number;
|
|
872
|
+
get rotation(): number;
|
|
873
|
+
pan(delta: Vector2): this;
|
|
874
|
+
panTo(position: Vector2): this;
|
|
875
|
+
zoomTo(level: number): this;
|
|
876
|
+
rotateTo(angle: number): this;
|
|
877
|
+
getViewMatrix(): Matrix3x3;
|
|
878
|
+
/**
|
|
879
|
+
* Transforms a world-space position to screen-space (pixel) coordinates.
|
|
880
|
+
*
|
|
881
|
+
* Screen coordinates have origin at top-left, with x increasing right
|
|
882
|
+
* and y increasing downward.
|
|
883
|
+
*
|
|
884
|
+
* @param pos - Position in world coordinates
|
|
885
|
+
* @returns Position in screen coordinates (pixels)
|
|
886
|
+
*
|
|
887
|
+
* @example
|
|
888
|
+
* const screenPos = camera.worldToScreen(circle.position);
|
|
889
|
+
* console.log(`Circle is at pixel (${screenPos.x}, ${screenPos.y})`);
|
|
890
|
+
*/
|
|
891
|
+
worldToScreen(pos: Vector2): Vector2;
|
|
892
|
+
/**
|
|
893
|
+
* Transforms a screen-space (pixel) position to world coordinates.
|
|
894
|
+
* This is the inverse of worldToScreen.
|
|
895
|
+
*
|
|
896
|
+
* @param pos - Position in screen coordinates (pixels, origin at top-left)
|
|
897
|
+
* @returns Position in world coordinates
|
|
898
|
+
*
|
|
899
|
+
* @example
|
|
900
|
+
* // Convert a mouse click position to world coordinates
|
|
901
|
+
* const worldPos = camera.screenToWorld(new Vector2(mouseX, mouseY));
|
|
902
|
+
*/
|
|
903
|
+
screenToWorld(pos: Vector2): Vector2;
|
|
904
|
+
/**
|
|
905
|
+
* Checks if a world-space position is currently visible within the camera frame.
|
|
906
|
+
*
|
|
907
|
+
* @param pos - Position in world coordinates to check
|
|
908
|
+
* @returns True if the position is within the visible frame bounds
|
|
909
|
+
*
|
|
910
|
+
* @example
|
|
911
|
+
* if (camera.isInView(object.position)) {
|
|
912
|
+
* console.log('Object is visible');
|
|
913
|
+
* }
|
|
914
|
+
*/
|
|
915
|
+
isInView(pos: Vector2): boolean;
|
|
916
|
+
reset(): this;
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
/**
|
|
920
|
+
* Configuration options for Scene.
|
|
921
|
+
*/
|
|
922
|
+
interface SceneConfig {
|
|
923
|
+
/** Pixel width of the scene. Default: 1920 */
|
|
924
|
+
readonly width?: number;
|
|
925
|
+
/** Pixel height of the scene. Default: 1080 */
|
|
926
|
+
readonly height?: number;
|
|
927
|
+
/** Background color. Default: BLACK */
|
|
928
|
+
readonly backgroundColor?: Color;
|
|
929
|
+
/** Frames per second. Default: 60 */
|
|
930
|
+
readonly frameRate?: number;
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
/**
|
|
934
|
+
* Scene is the core container that manages Mobjects and coordinates animations.
|
|
935
|
+
* It provides both a simple API for playing animations and access to the
|
|
936
|
+
* underlying Timeline and Camera for advanced control.
|
|
937
|
+
*/
|
|
938
|
+
declare class Scene {
|
|
939
|
+
private readonly config;
|
|
940
|
+
private readonly mobjects;
|
|
941
|
+
private readonly timeline;
|
|
942
|
+
private readonly _camera;
|
|
943
|
+
private playheadTime;
|
|
944
|
+
constructor(config?: SceneConfig);
|
|
945
|
+
get camera(): Camera;
|
|
946
|
+
get frame(): CameraFrame;
|
|
947
|
+
/** Get scene width in pixels. */
|
|
948
|
+
getWidth(): number;
|
|
949
|
+
/** Get scene height in pixels. */
|
|
950
|
+
getHeight(): number;
|
|
951
|
+
/** Get scene background color. */
|
|
952
|
+
getBackgroundColor(): Color;
|
|
953
|
+
/** Get scene frame rate. */
|
|
954
|
+
getFrameRate(): number;
|
|
955
|
+
/**
|
|
956
|
+
* Add mobjects to the scene and make them immediately visible.
|
|
957
|
+
* Use this for static elements or backgrounds that should be visible
|
|
958
|
+
* before any animations begin.
|
|
959
|
+
*/
|
|
960
|
+
add(...mobjects: Mobject[]): this;
|
|
961
|
+
/**
|
|
962
|
+
* Remove mobjects from the scene.
|
|
963
|
+
*/
|
|
964
|
+
remove(...mobjects: Mobject[]): this;
|
|
965
|
+
/**
|
|
966
|
+
* Check if a mobject is registered with this scene.
|
|
967
|
+
*/
|
|
968
|
+
has(mobject: Mobject): boolean;
|
|
969
|
+
/**
|
|
970
|
+
* Get all mobjects in the scene.
|
|
971
|
+
*/
|
|
972
|
+
getMobjects(): readonly Mobject[];
|
|
973
|
+
/**
|
|
974
|
+
* Schedule animations to play at the current playhead position.
|
|
975
|
+
*
|
|
976
|
+
* Accepts either Animation objects or Mobjects with queued fluent animations.
|
|
977
|
+
* When a Mobject is passed, its queued animation chain is automatically extracted.
|
|
978
|
+
*
|
|
979
|
+
* - Introductory animations (FadeIn, Create, Draw, Write) auto-register
|
|
980
|
+
* their targets with the scene if not already present.
|
|
981
|
+
* - Transformative animations (MoveTo, Rotate, Scale) require the target
|
|
982
|
+
* to already be in the scene, otherwise an error is thrown.
|
|
983
|
+
*
|
|
984
|
+
* @example
|
|
985
|
+
* // ProAPI style
|
|
986
|
+
* this.play(new FadeIn(circle), new MoveTo(rect, 2, 0));
|
|
987
|
+
*
|
|
988
|
+
* // FluentAPI style
|
|
989
|
+
* circle.fadeIn(1).moveTo(2, 0, 1);
|
|
990
|
+
* this.play(circle);
|
|
991
|
+
*
|
|
992
|
+
* // Mixed
|
|
993
|
+
* circle.fadeIn(1);
|
|
994
|
+
* this.play(circle, new FadeIn(rect));
|
|
995
|
+
*/
|
|
996
|
+
play(...items: Array<Animation | Mobject>): this;
|
|
997
|
+
/**
|
|
998
|
+
* Add a delay before the next play() call.
|
|
999
|
+
* @param seconds Number of seconds to wait
|
|
1000
|
+
*/
|
|
1001
|
+
wait(seconds: number): this;
|
|
1002
|
+
/**
|
|
1003
|
+
* Get the current playhead time.
|
|
1004
|
+
*/
|
|
1005
|
+
getCurrentTime(): number;
|
|
1006
|
+
/**
|
|
1007
|
+
* Get the total duration of all scheduled animations.
|
|
1008
|
+
*/
|
|
1009
|
+
getTotalDuration(): number;
|
|
1010
|
+
/**
|
|
1011
|
+
* Get the underlying Timeline for advanced control.
|
|
1012
|
+
* Use this for direct manipulation of animation timing.
|
|
1013
|
+
*/
|
|
1014
|
+
getTimeline(): Timeline;
|
|
1015
|
+
/**
|
|
1016
|
+
* Get the Camera for view control and frame dimensions.
|
|
1017
|
+
* Camera calculates Manim-compatible frame dimensions from pixel resolution.
|
|
1018
|
+
*/
|
|
1019
|
+
getCamera(): Camera;
|
|
1020
|
+
/**
|
|
1021
|
+
* Validates and registers animation targets based on lifecycle.
|
|
1022
|
+
* Handles composition animations (Sequence, Parallel) by processing children.
|
|
1023
|
+
*/
|
|
1024
|
+
private validateAndRegisterAnimation;
|
|
1025
|
+
/**
|
|
1026
|
+
* Gets children of composition animations (Sequence, Parallel).
|
|
1027
|
+
* Returns empty array for non-composition animations.
|
|
1028
|
+
*/
|
|
1029
|
+
private getAnimationChildren;
|
|
1030
|
+
}
|
|
1031
|
+
|
|
1032
|
+
type PathCommandType = 'Move' | 'Line' | 'Quadratic' | 'Cubic' | 'Close';
|
|
1033
|
+
interface PathCommand {
|
|
1034
|
+
type: PathCommandType;
|
|
1035
|
+
end: Vector2;
|
|
1036
|
+
control1?: Vector2;
|
|
1037
|
+
control2?: Vector2;
|
|
1038
|
+
}
|
|
1039
|
+
|
|
1040
|
+
/**
|
|
1041
|
+
* A class representing a Bezier path, capable of storing standard path commands
|
|
1042
|
+
* (move, line, quadratic curve, cubic curve, close).
|
|
1043
|
+
*/
|
|
1044
|
+
declare class BezierPath {
|
|
1045
|
+
private commands;
|
|
1046
|
+
private currentPoint;
|
|
1047
|
+
private startPoint;
|
|
1048
|
+
private cachedLength;
|
|
1049
|
+
private segmentLengths;
|
|
1050
|
+
private segmentCDF;
|
|
1051
|
+
/** Invalidates the cached length data. Called after any path modification. */
|
|
1052
|
+
private invalidateCache;
|
|
1053
|
+
/** Builds the cache if not already valid. */
|
|
1054
|
+
private ensureCache;
|
|
1055
|
+
/** Starts a new subpath at the specified point. */
|
|
1056
|
+
moveTo(point: Vector2): void;
|
|
1057
|
+
lineTo(point: Vector2): void;
|
|
1058
|
+
quadraticTo(control: Vector2, end: Vector2): void;
|
|
1059
|
+
cubicTo(control1: Vector2, control2: Vector2, end: Vector2): void;
|
|
1060
|
+
closePath(): void;
|
|
1061
|
+
getCommands(): PathCommand[];
|
|
1062
|
+
getLength(): number;
|
|
1063
|
+
/** Returns the point on the path at the normalized position t (0-1). */
|
|
1064
|
+
getPointAt(t: number): Vector2;
|
|
1065
|
+
getTangentAt(t: number): Vector2;
|
|
1066
|
+
getPoints(count: number): Vector2[];
|
|
1067
|
+
getPointCount(): number;
|
|
1068
|
+
clone(): BezierPath;
|
|
1069
|
+
/** Returns a new BezierPath where all segments are converted to Cubic curves. */
|
|
1070
|
+
toCubic(): BezierPath;
|
|
1071
|
+
static interpolate(path1: BezierPath, path2: BezierPath, t: number): BezierPath;
|
|
1072
|
+
/** Matches the number of points/commands in two paths for morphing. */
|
|
1073
|
+
static matchPoints(path1: BezierPath, path2: BezierPath): [BezierPath, BezierPath];
|
|
1074
|
+
private static fromCommands;
|
|
1075
|
+
}
|
|
1076
|
+
|
|
1077
|
+
/**
|
|
1078
|
+
* A Mobject that is defined by one or more BezierPaths.
|
|
1079
|
+
* Supports stroke and fill styling, plus VMobject-specific fluent animations.
|
|
1080
|
+
*
|
|
1081
|
+
* Default behavior: visible with white stroke, no fill.
|
|
1082
|
+
* - Stroke: white, width 2 (visible by default)
|
|
1083
|
+
* - Fill: not rendered by default (fillOpacity = 0)
|
|
1084
|
+
*
|
|
1085
|
+
* When .fill(color) is called, the default stroke is disabled unless
|
|
1086
|
+
* .stroke(color, width) was called explicitly.
|
|
1087
|
+
*
|
|
1088
|
+
* Use .stroke(color, width) to add a stroke.
|
|
1089
|
+
* Use .fill(color) to add a fill (opacity defaults to 1).
|
|
1090
|
+
*/
|
|
1091
|
+
declare class VMobject extends Mobject {
|
|
1092
|
+
protected pathList: BezierPath[];
|
|
1093
|
+
/** Stroke color. Only rendered if strokeWidth > 0. */
|
|
1094
|
+
protected strokeColor: Color;
|
|
1095
|
+
/** Stroke width. Default 2 for visibility. */
|
|
1096
|
+
protected strokeWidth: number;
|
|
1097
|
+
/** Fill color. Only rendered if fillOpacity > 0. */
|
|
1098
|
+
protected fillColor: Color;
|
|
1099
|
+
/** Fill opacity. Default 0 means no fill is rendered. */
|
|
1100
|
+
protected fillOpacity: number;
|
|
1101
|
+
/** Tracks whether stroke() was explicitly called. */
|
|
1102
|
+
protected strokeExplicitlySet: boolean;
|
|
1103
|
+
constructor();
|
|
1104
|
+
get paths(): BezierPath[];
|
|
1105
|
+
set paths(value: BezierPath[]);
|
|
1106
|
+
/**
|
|
1107
|
+
* Gets the stroke color.
|
|
1108
|
+
*/
|
|
1109
|
+
getStrokeColor(): Color;
|
|
1110
|
+
/**
|
|
1111
|
+
* Gets the stroke width.
|
|
1112
|
+
*/
|
|
1113
|
+
getStrokeWidth(): number;
|
|
1114
|
+
/**
|
|
1115
|
+
* Gets the fill color.
|
|
1116
|
+
*/
|
|
1117
|
+
getFillColor(): Color;
|
|
1118
|
+
/**
|
|
1119
|
+
* Gets the fill opacity.
|
|
1120
|
+
*/
|
|
1121
|
+
getFillOpacity(): number;
|
|
1122
|
+
/**
|
|
1123
|
+
* Adds a new path to the VMobject.
|
|
1124
|
+
* @param path - The BezierPath to add.
|
|
1125
|
+
* @returns this for chaining.
|
|
1126
|
+
*/
|
|
1127
|
+
addPath(path: BezierPath): this;
|
|
1128
|
+
/**
|
|
1129
|
+
* Sets the stroke color and width.
|
|
1130
|
+
* @param color - The stroke color.
|
|
1131
|
+
* @param width - The stroke width. Default is 2.
|
|
1132
|
+
* @returns this for chaining.
|
|
1133
|
+
*/
|
|
1134
|
+
stroke(color: Color, width?: number): this;
|
|
1135
|
+
/**
|
|
1136
|
+
* Sets the fill color and opacity.
|
|
1137
|
+
* If stroke was not explicitly set, the default stroke is disabled.
|
|
1138
|
+
* @param color - The fill color.
|
|
1139
|
+
* @param opacity - The fill opacity. Defaults to the color's alpha value.
|
|
1140
|
+
* @returns this for chaining.
|
|
1141
|
+
*/
|
|
1142
|
+
fill(color: Color, opacity?: number): this;
|
|
1143
|
+
getPoints(): PathCommand[];
|
|
1144
|
+
setPoints(commands: PathCommand[]): this;
|
|
1145
|
+
private getPointsAsVectors;
|
|
1146
|
+
getBoundingBox(): {
|
|
1147
|
+
minX: number;
|
|
1148
|
+
maxX: number;
|
|
1149
|
+
minY: number;
|
|
1150
|
+
maxY: number;
|
|
1151
|
+
};
|
|
1152
|
+
/**
|
|
1153
|
+
* Progressively draws the VMobject's paths from start to end.
|
|
1154
|
+
* Preserves fill throughout the animation.
|
|
1155
|
+
* @param durationSeconds - Animation duration in seconds.
|
|
1156
|
+
* @returns this for chaining.
|
|
1157
|
+
*/
|
|
1158
|
+
write(durationSeconds?: number): this & {
|
|
1159
|
+
toAnimation(): Animation<Mobject>;
|
|
1160
|
+
};
|
|
1161
|
+
/**
|
|
1162
|
+
* Progressively removes the VMobject's paths (reverse of write).
|
|
1163
|
+
* @param durationSeconds - Animation duration in seconds.
|
|
1164
|
+
* @returns this for chaining.
|
|
1165
|
+
*/
|
|
1166
|
+
unwrite(durationSeconds?: number): this & {
|
|
1167
|
+
toAnimation(): Animation<Mobject>;
|
|
1168
|
+
};
|
|
1169
|
+
/**
|
|
1170
|
+
* First draws the stroke progressively (0-50%), then fades in the fill (50-100%).
|
|
1171
|
+
* @param durationSeconds - Animation duration in seconds.
|
|
1172
|
+
* @returns this for chaining.
|
|
1173
|
+
*/
|
|
1174
|
+
draw(durationSeconds?: number): this & {
|
|
1175
|
+
toAnimation(): Animation<Mobject>;
|
|
1176
|
+
};
|
|
1177
|
+
}
|
|
1178
|
+
|
|
1179
|
+
type CornerPosition = 'TOP_LEFT' | 'TOP_RIGHT' | 'BOTTOM_LEFT' | 'BOTTOM_RIGHT';
|
|
1180
|
+
type Direction = 'RIGHT' | 'LEFT' | 'UP' | 'DOWN';
|
|
1181
|
+
type Edge = 'TOP' | 'BOTTOM' | 'LEFT' | 'RIGHT';
|
|
1182
|
+
|
|
1183
|
+
/**
|
|
1184
|
+
* A collection of VMobjects that can be manipulated as a single unit.
|
|
1185
|
+
* Uses Scene Graph hierarchy: transforms on parent are inherited by children
|
|
1186
|
+
* via getWorldMatrix() calculation, not by mutating child matrices.
|
|
1187
|
+
*/
|
|
1188
|
+
declare class VGroup extends VMobject {
|
|
1189
|
+
protected children: VMobject[];
|
|
1190
|
+
constructor(...mobjects: VMobject[]);
|
|
1191
|
+
get length(): number;
|
|
1192
|
+
add(...mobjects: VMobject[]): this;
|
|
1193
|
+
remove(mobject: VMobject): this;
|
|
1194
|
+
clear(): this;
|
|
1195
|
+
getChildren(): VMobject[];
|
|
1196
|
+
get(index: number): VMobject | undefined;
|
|
1197
|
+
pos(x: number, y: number): this;
|
|
1198
|
+
show(): this;
|
|
1199
|
+
hide(): this;
|
|
1200
|
+
/**
|
|
1201
|
+
* Sets the opacity for this VGroup and all children.
|
|
1202
|
+
* @param value - The opacity value (0-1).
|
|
1203
|
+
* @returns this for chaining.
|
|
1204
|
+
*/
|
|
1205
|
+
setOpacity(value: number): this;
|
|
1206
|
+
/**
|
|
1207
|
+
* Sets the stroke color and width for this VGroup and all children.
|
|
1208
|
+
* @param color - The stroke color.
|
|
1209
|
+
* @param width - The stroke width. Default is 2.
|
|
1210
|
+
* @returns this for chaining.
|
|
1211
|
+
*/
|
|
1212
|
+
stroke(color: Color, width?: number): this;
|
|
1213
|
+
/**
|
|
1214
|
+
* Sets the fill color and opacity for this VGroup and all children.
|
|
1215
|
+
* @param color - The fill color.
|
|
1216
|
+
* @param opacity - The fill opacity. Default is 1 (fully opaque).
|
|
1217
|
+
* @returns this for chaining.
|
|
1218
|
+
*/
|
|
1219
|
+
fill(color: Color, opacity?: number): this;
|
|
1220
|
+
getBoundingBox(): {
|
|
1221
|
+
minX: number;
|
|
1222
|
+
maxX: number;
|
|
1223
|
+
minY: number;
|
|
1224
|
+
maxY: number;
|
|
1225
|
+
};
|
|
1226
|
+
center(): this;
|
|
1227
|
+
toCorner(corner: CornerPosition, buff?: number): this;
|
|
1228
|
+
arrange(direction?: Direction, buff?: number, shouldCenter?: boolean): this;
|
|
1229
|
+
alignTo(target: VMobject, edge: Edge): this;
|
|
1230
|
+
}
|
|
1231
|
+
|
|
1232
|
+
declare class Arc extends VMobject {
|
|
1233
|
+
readonly radius: number;
|
|
1234
|
+
readonly startAngle: number;
|
|
1235
|
+
readonly endAngle: number;
|
|
1236
|
+
constructor(radius?: number, startAngle?: number, endAngle?: number);
|
|
1237
|
+
private generatePath;
|
|
1238
|
+
}
|
|
1239
|
+
|
|
1240
|
+
declare class Circle extends Arc {
|
|
1241
|
+
constructor(radius?: number);
|
|
1242
|
+
}
|
|
1243
|
+
|
|
1244
|
+
declare class Line extends VMobject {
|
|
1245
|
+
readonly start: Vector2;
|
|
1246
|
+
readonly end: Vector2;
|
|
1247
|
+
constructor(x1?: number, y1?: number, x2?: number, y2?: number);
|
|
1248
|
+
private generatePath;
|
|
1249
|
+
}
|
|
1250
|
+
|
|
1251
|
+
declare class Point extends Circle {
|
|
1252
|
+
constructor(location?: Vector2);
|
|
1253
|
+
}
|
|
1254
|
+
|
|
1255
|
+
declare class Polygon extends VMobject {
|
|
1256
|
+
readonly vertices: Vector2[];
|
|
1257
|
+
constructor(vertices: Vector2[]);
|
|
1258
|
+
private generatePath;
|
|
1259
|
+
}
|
|
1260
|
+
|
|
1261
|
+
declare class Rectangle extends Polygon {
|
|
1262
|
+
readonly width: number;
|
|
1263
|
+
readonly height: number;
|
|
1264
|
+
constructor(width?: number, height?: number);
|
|
1265
|
+
}
|
|
1266
|
+
|
|
1267
|
+
declare class Arrow extends Line {
|
|
1268
|
+
readonly tipLength: number;
|
|
1269
|
+
readonly tipAngle: number;
|
|
1270
|
+
constructor(x1?: number, y1?: number, x2?: number, y2?: number, tipLength?: number, tipAngle?: number);
|
|
1271
|
+
private addTip;
|
|
1272
|
+
}
|
|
1273
|
+
|
|
1274
|
+
/**
|
|
1275
|
+
* A VMobject representing a single glyph character.
|
|
1276
|
+
* Converts fontkit glyph path to BezierPath for rendering.
|
|
1277
|
+
*/
|
|
1278
|
+
declare class Glyph extends VMobject {
|
|
1279
|
+
readonly character: string;
|
|
1280
|
+
readonly glyphId: number;
|
|
1281
|
+
constructor(fontkitGlyph: Glyph$1, character: string, scale: number, offsetX: number, offsetY: number);
|
|
1282
|
+
}
|
|
1283
|
+
|
|
1284
|
+
/**
|
|
1285
|
+
* Options for configuring Text appearance.
|
|
1286
|
+
*/
|
|
1287
|
+
interface TextStyle {
|
|
1288
|
+
fontSize: number;
|
|
1289
|
+
color: Color;
|
|
1290
|
+
}
|
|
1291
|
+
|
|
1292
|
+
/**
|
|
1293
|
+
* A VGroup of vectorized glyphs created from a text string using fontkit.
|
|
1294
|
+
* Each character becomes a Glyph VMobject that can be individually animated.
|
|
1295
|
+
*/
|
|
1296
|
+
declare class Text extends VGroup {
|
|
1297
|
+
readonly text: string;
|
|
1298
|
+
private style;
|
|
1299
|
+
private fontPath;
|
|
1300
|
+
constructor(text: string, fontPath: string, options?: Partial<TextStyle>);
|
|
1301
|
+
private buildGlyphs;
|
|
1302
|
+
private getCharacterForGlyph;
|
|
1303
|
+
private applyStyle;
|
|
1304
|
+
setStyle(options: Partial<TextStyle>): this;
|
|
1305
|
+
getStyle(): TextStyle;
|
|
1306
|
+
getGlyph(index: number): Glyph | undefined;
|
|
1307
|
+
}
|
|
1308
|
+
|
|
1309
|
+
/** Unique identifier for graph nodes. */
|
|
1310
|
+
type GraphNodeId = string;
|
|
1311
|
+
/** Configuration for creating a graph node. */
|
|
1312
|
+
interface NodeConfig {
|
|
1313
|
+
position?: {
|
|
1314
|
+
x: number;
|
|
1315
|
+
y: number;
|
|
1316
|
+
};
|
|
1317
|
+
radius?: number;
|
|
1318
|
+
strokeColor?: Color;
|
|
1319
|
+
strokeWidth?: number;
|
|
1320
|
+
fillColor?: Color;
|
|
1321
|
+
fillOpacity?: number;
|
|
1322
|
+
}
|
|
1323
|
+
/** Configuration for creating a graph edge. */
|
|
1324
|
+
interface EdgeConfig {
|
|
1325
|
+
strokeColor?: Color;
|
|
1326
|
+
strokeWidth?: number;
|
|
1327
|
+
curved?: boolean;
|
|
1328
|
+
}
|
|
1329
|
+
/** Supported layout algorithms. */
|
|
1330
|
+
type LayoutType = 'force-directed' | 'tree' | 'circular';
|
|
1331
|
+
/** Configuration for graph layout algorithms. */
|
|
1332
|
+
interface LayoutConfig {
|
|
1333
|
+
radius?: number;
|
|
1334
|
+
levelHeight?: number;
|
|
1335
|
+
siblingSpacing?: number;
|
|
1336
|
+
iterations?: number;
|
|
1337
|
+
springLength?: number;
|
|
1338
|
+
repulsion?: number;
|
|
1339
|
+
attraction?: number;
|
|
1340
|
+
damping?: number;
|
|
1341
|
+
minDistance?: number;
|
|
1342
|
+
}
|
|
1343
|
+
|
|
1344
|
+
/**
|
|
1345
|
+
* A graph node represented as a circular VMobject.
|
|
1346
|
+
* Supports customizable radius, stroke, and fill styling.
|
|
1347
|
+
*/
|
|
1348
|
+
declare class GraphNode extends VMobject {
|
|
1349
|
+
readonly id: GraphNodeId;
|
|
1350
|
+
private nodeRadius;
|
|
1351
|
+
constructor(id: GraphNodeId, config?: NodeConfig);
|
|
1352
|
+
get radius(): number;
|
|
1353
|
+
/**
|
|
1354
|
+
* Generates a circular BezierPath approximation using cubic Bezier curves.
|
|
1355
|
+
* Uses the standard 4-point circle approximation with control point factor ~0.5523.
|
|
1356
|
+
*/
|
|
1357
|
+
private generateCirclePath;
|
|
1358
|
+
getCenter(): Vector2;
|
|
1359
|
+
}
|
|
1360
|
+
|
|
1361
|
+
/**
|
|
1362
|
+
* A graph edge represented as a BezierPath connecting two nodes.
|
|
1363
|
+
* Supports straight or curved edges with customizable styling.
|
|
1364
|
+
*/
|
|
1365
|
+
declare class GraphEdge extends VMobject {
|
|
1366
|
+
readonly source: GraphNodeId;
|
|
1367
|
+
readonly target: GraphNodeId;
|
|
1368
|
+
private sourceNode;
|
|
1369
|
+
private targetNode;
|
|
1370
|
+
private curved;
|
|
1371
|
+
constructor(sourceNode: GraphNode, targetNode: GraphNode, config?: EdgeConfig);
|
|
1372
|
+
/**
|
|
1373
|
+
* Recalculates the edge path based on current node positions.
|
|
1374
|
+
* Call this when nodes move to update the edge connection.
|
|
1375
|
+
*/
|
|
1376
|
+
updatePath(): void;
|
|
1377
|
+
getPath(): BezierPath | undefined;
|
|
1378
|
+
/**
|
|
1379
|
+
* Updates node references (used when nodes are replaced).
|
|
1380
|
+
*/
|
|
1381
|
+
setNodes(sourceNode: GraphNode, targetNode: GraphNode): void;
|
|
1382
|
+
}
|
|
1383
|
+
|
|
1384
|
+
/**
|
|
1385
|
+
* A graph structure containing nodes and edges.
|
|
1386
|
+
* Manages nodes as VMobjects and edges as BezierPath curves.
|
|
1387
|
+
* Supports multiple layout algorithms for automatic positioning.
|
|
1388
|
+
*/
|
|
1389
|
+
declare class Graph extends VGroup {
|
|
1390
|
+
private nodes;
|
|
1391
|
+
private edges;
|
|
1392
|
+
constructor();
|
|
1393
|
+
/** Adds a node to the graph. */
|
|
1394
|
+
addNode(id: GraphNodeId, config?: NodeConfig): GraphNode;
|
|
1395
|
+
/** Removes a node and all connected edges from the graph. */
|
|
1396
|
+
removeNode(id: GraphNodeId): this;
|
|
1397
|
+
getNode(id: GraphNodeId): GraphNode | undefined;
|
|
1398
|
+
getNodes(): GraphNode[];
|
|
1399
|
+
addEdge(sourceId: GraphNodeId, targetId: GraphNodeId, config?: EdgeConfig): GraphEdge | undefined;
|
|
1400
|
+
removeEdge(sourceId: GraphNodeId, targetId: GraphNodeId): this;
|
|
1401
|
+
private removeEdgeInternal;
|
|
1402
|
+
getEdgePath(sourceId: GraphNodeId, targetId: GraphNodeId): ReturnType<GraphEdge['getPath']>;
|
|
1403
|
+
getEdges(): GraphEdge[];
|
|
1404
|
+
/** Applies a layout algorithm to reposition all nodes. */
|
|
1405
|
+
layout(type: LayoutType, config?: LayoutConfig): this;
|
|
1406
|
+
updateEdges(): this;
|
|
1407
|
+
}
|
|
1408
|
+
|
|
1409
|
+
/**
|
|
1410
|
+
* Abstract base class for animations that introduce an object to the scene.
|
|
1411
|
+
*
|
|
1412
|
+
* Introductory animations:
|
|
1413
|
+
* - Automatically register the target with the scene if not already present
|
|
1414
|
+
* - Do not require the target to be in the scene beforehand
|
|
1415
|
+
* - Typically animate opacity or drawing from 0 to visible
|
|
1416
|
+
*
|
|
1417
|
+
* Examples: FadeIn, Write, Draw, GrowFromCenter, SpinIn
|
|
1418
|
+
*/
|
|
1419
|
+
declare abstract class IntroductoryAnimation<T extends Mobject = Mobject> extends Animation<T> {
|
|
1420
|
+
readonly lifecycle: AnimationLifecycle;
|
|
1421
|
+
}
|
|
1422
|
+
|
|
1423
|
+
/**
|
|
1424
|
+
* Abstract base class for animations that transform an existing scene object.
|
|
1425
|
+
*
|
|
1426
|
+
* Transformative animations:
|
|
1427
|
+
* - Require the target to already be registered with the scene
|
|
1428
|
+
* - Throw an error if the target is not in the scene
|
|
1429
|
+
* - Operate on objects that are already visible or have been introduced
|
|
1430
|
+
* - Use lazy initialization to capture start state when animation becomes active
|
|
1431
|
+
*
|
|
1432
|
+
* Examples: MoveTo, Rotate, Scale, MorphTo, Transform
|
|
1433
|
+
*/
|
|
1434
|
+
declare abstract class TransformativeAnimation<T extends Mobject = Mobject> extends Animation<T> {
|
|
1435
|
+
readonly lifecycle: AnimationLifecycle;
|
|
1436
|
+
protected initialized: boolean;
|
|
1437
|
+
/**
|
|
1438
|
+
* Captures the start state from the target.
|
|
1439
|
+
* Called once when the animation first becomes active.
|
|
1440
|
+
*/
|
|
1441
|
+
protected abstract captureStartState(): void;
|
|
1442
|
+
ensureInitialized(): void;
|
|
1443
|
+
reset(): void;
|
|
1444
|
+
}
|
|
1445
|
+
|
|
1446
|
+
/**
|
|
1447
|
+
* Abstract base class for animations that exit/remove an object from the scene.
|
|
1448
|
+
*
|
|
1449
|
+
* Exit animations:
|
|
1450
|
+
* - Require the target to already be registered with the scene
|
|
1451
|
+
* - Throw an error if the target is not in the scene
|
|
1452
|
+
* - Typically animate opacity or scale to 0
|
|
1453
|
+
* - May optionally auto-remove the target from the scene after completion
|
|
1454
|
+
*
|
|
1455
|
+
* Examples: FadeOut, ShrinkToCenter, Uncreate
|
|
1456
|
+
*/
|
|
1457
|
+
declare abstract class ExitAnimation<T extends Mobject = Mobject> extends Animation<T> {
|
|
1458
|
+
readonly lifecycle: AnimationLifecycle;
|
|
1459
|
+
}
|
|
1460
|
+
|
|
1461
|
+
/**
|
|
1462
|
+
* Animation that fades a Mobject in by increasing its opacity from 0 to 1.
|
|
1463
|
+
*
|
|
1464
|
+
* This is an introductory animation - it auto-registers the target with the scene.
|
|
1465
|
+
* You do not need to call scene.add() before using FadeIn.
|
|
1466
|
+
*
|
|
1467
|
+
* @example
|
|
1468
|
+
* const circle = new Circle(1);
|
|
1469
|
+
* scene.play(new FadeIn(circle)); // Circle is auto-registered and faded in
|
|
1470
|
+
*/
|
|
1471
|
+
declare class FadeIn<T extends Mobject = Mobject> extends IntroductoryAnimation<T> {
|
|
1472
|
+
private readonly startOpacity;
|
|
1473
|
+
constructor(target: T);
|
|
1474
|
+
interpolate(progress: number): void;
|
|
1475
|
+
}
|
|
1476
|
+
|
|
1477
|
+
/**
|
|
1478
|
+
* Animation that fades a Mobject out by decreasing its opacity to 0.
|
|
1479
|
+
*
|
|
1480
|
+
* This is an exit animation - the target must already be in the scene.
|
|
1481
|
+
* The starting opacity is captured when the animation first runs,
|
|
1482
|
+
* not when it's constructed, so it correctly fades from the current opacity.
|
|
1483
|
+
*
|
|
1484
|
+
* @example
|
|
1485
|
+
* scene.add(circle);
|
|
1486
|
+
* scene.play(new FadeOut(circle)); // Circle fades out
|
|
1487
|
+
*/
|
|
1488
|
+
declare class FadeOut<T extends Mobject = Mobject> extends ExitAnimation<T> {
|
|
1489
|
+
private startOpacity;
|
|
1490
|
+
interpolate(progress: number): void;
|
|
1491
|
+
}
|
|
1492
|
+
|
|
1493
|
+
/**
|
|
1494
|
+
* Animation that moves a Mobject from its current position to a destination.
|
|
1495
|
+
* Uses linear interpolation between start and end positions.
|
|
1496
|
+
*
|
|
1497
|
+
* This is a transformative animation - the target must already be in the scene.
|
|
1498
|
+
* Start position is captured lazily when animation becomes active.
|
|
1499
|
+
*
|
|
1500
|
+
* @example
|
|
1501
|
+
* scene.add(circle); // or use FadeIn first
|
|
1502
|
+
* scene.play(new MoveTo(circle, 2, 0)); // Move to (2, 0)
|
|
1503
|
+
*/
|
|
1504
|
+
declare class MoveTo<T extends Mobject = Mobject> extends TransformativeAnimation<T> {
|
|
1505
|
+
private startPosition;
|
|
1506
|
+
private readonly endPosition;
|
|
1507
|
+
constructor(target: T, destination: Vector2);
|
|
1508
|
+
constructor(target: T, x: number, y: number);
|
|
1509
|
+
protected captureStartState(): void;
|
|
1510
|
+
interpolate(progress: number): void;
|
|
1511
|
+
/** Returns the target position of the move animation. */
|
|
1512
|
+
getDestination(): Vector2;
|
|
1513
|
+
}
|
|
1514
|
+
|
|
1515
|
+
/**
|
|
1516
|
+
* Animation that rotates a Mobject by a specified angle.
|
|
1517
|
+
* Uses linear interpolation between start and end rotation.
|
|
1518
|
+
*
|
|
1519
|
+
* This is a transformative animation - the target must already be in the scene.
|
|
1520
|
+
* Start rotation is captured lazily when animation becomes active.
|
|
1521
|
+
*
|
|
1522
|
+
* @example
|
|
1523
|
+
* scene.add(square);
|
|
1524
|
+
* scene.play(new Rotate(square, Math.PI / 4)); // Rotate 45 degrees
|
|
1525
|
+
*/
|
|
1526
|
+
declare class Rotate<T extends Mobject = Mobject> extends TransformativeAnimation<T> {
|
|
1527
|
+
private startRotation;
|
|
1528
|
+
private endRotation;
|
|
1529
|
+
private readonly angle;
|
|
1530
|
+
constructor(target: T, angle: number);
|
|
1531
|
+
protected captureStartState(): void;
|
|
1532
|
+
interpolate(progress: number): void;
|
|
1533
|
+
/** Returns the total rotation angle in radians. */
|
|
1534
|
+
getAngle(): number;
|
|
1535
|
+
}
|
|
1536
|
+
|
|
1537
|
+
/**
|
|
1538
|
+
* Animation that scales a Mobject to a target scale factor.
|
|
1539
|
+
* Uses linear interpolation between start and end scale.
|
|
1540
|
+
*
|
|
1541
|
+
* This is a transformative animation - the target must already be in the scene.
|
|
1542
|
+
* Start scale is captured lazily when animation becomes active.
|
|
1543
|
+
*
|
|
1544
|
+
* @example
|
|
1545
|
+
* scene.add(circle);
|
|
1546
|
+
* scene.play(new Scale(circle, 2)); // Scale to 2x
|
|
1547
|
+
*/
|
|
1548
|
+
declare class Scale<T extends Mobject = Mobject> extends TransformativeAnimation<T> {
|
|
1549
|
+
private startScale;
|
|
1550
|
+
private readonly endScale;
|
|
1551
|
+
constructor(target: T, factor: number);
|
|
1552
|
+
constructor(target: T, factorX: number, factorY: number);
|
|
1553
|
+
protected captureStartState(): void;
|
|
1554
|
+
interpolate(progress: number): void;
|
|
1555
|
+
/** Returns the scale factor. */
|
|
1556
|
+
getFactor(): number;
|
|
1557
|
+
}
|
|
1558
|
+
|
|
1559
|
+
/**
|
|
1560
|
+
* Animation that morphs a VMobject from its current shape to a target shape.
|
|
1561
|
+
* Uses BezierPath interpolation for smooth path transitions.
|
|
1562
|
+
*
|
|
1563
|
+
* This is a transformative animation - the source must already be in the scene.
|
|
1564
|
+
* The target VMobject is used only as a shape template and is NOT added to the scene.
|
|
1565
|
+
* Source paths are captured lazily when animation becomes active.
|
|
1566
|
+
*
|
|
1567
|
+
* @example
|
|
1568
|
+
* scene.add(circle);
|
|
1569
|
+
* scene.play(new MorphTo(circle, square)); // circle morphs into square's shape
|
|
1570
|
+
*/
|
|
1571
|
+
declare class MorphTo<T extends VMobject = VMobject> extends TransformativeAnimation<T> {
|
|
1572
|
+
private sourcePaths;
|
|
1573
|
+
private readonly targetPaths;
|
|
1574
|
+
constructor(source: T, target: VMobject);
|
|
1575
|
+
protected captureStartState(): void;
|
|
1576
|
+
interpolate(progress: number): void;
|
|
1577
|
+
private getEmptyPath;
|
|
1578
|
+
}
|
|
1579
|
+
|
|
1580
|
+
/**
|
|
1581
|
+
* Animation that first draws the border progressively, then fills the shape.
|
|
1582
|
+
* The first 50% of the animation draws the stroke, the second 50% fades in the fill.
|
|
1583
|
+
*
|
|
1584
|
+
* Supports VGroup (including Text): animates each child's paths progressively.
|
|
1585
|
+
*
|
|
1586
|
+
* This is an introductory animation - it auto-registers the target with the scene.
|
|
1587
|
+
*
|
|
1588
|
+
* @example
|
|
1589
|
+
* const rect = new Rectangle(2, 1);
|
|
1590
|
+
* scene.play(new Draw(rect)); // Border draws, then fill fades in
|
|
1591
|
+
*/
|
|
1592
|
+
declare class Draw<T extends VMobject = VMobject> extends IntroductoryAnimation<T> {
|
|
1593
|
+
private readonly isVGroup;
|
|
1594
|
+
/** For non-VGroup targets: original paths on the target itself. */
|
|
1595
|
+
private readonly originalPaths;
|
|
1596
|
+
private readonly originalFillOpacity;
|
|
1597
|
+
private readonly originalOpacity;
|
|
1598
|
+
/** For VGroup targets: original state of each child. */
|
|
1599
|
+
private readonly childStates;
|
|
1600
|
+
constructor(target: T);
|
|
1601
|
+
/** Interpolates stroke drawing (0-0.5) and then fill fade (0.5-1). */
|
|
1602
|
+
interpolate(progress: number): void;
|
|
1603
|
+
/** Interpolates a single VMobject (non-VGroup). */
|
|
1604
|
+
private interpolateVMobject;
|
|
1605
|
+
/** Interpolates a VGroup by animating each child's paths. */
|
|
1606
|
+
private interpolateVGroup;
|
|
1607
|
+
}
|
|
1608
|
+
|
|
1609
|
+
/**
|
|
1610
|
+
* Animation that progressively draws a VMobject's paths from start to end.
|
|
1611
|
+
* Preserves both stroke and fill properties - the complete object is visible at the end.
|
|
1612
|
+
*
|
|
1613
|
+
* This is the canonical animation for progressive path drawing.
|
|
1614
|
+
* At progress 0, nothing is shown. At progress 1, the complete path is shown.
|
|
1615
|
+
*
|
|
1616
|
+
* Supports VGroup (including Text): animates each child's paths progressively.
|
|
1617
|
+
*
|
|
1618
|
+
* This is an introductory animation - it auto-registers the target with the scene.
|
|
1619
|
+
*
|
|
1620
|
+
* @example
|
|
1621
|
+
* const circle = new Circle(1);
|
|
1622
|
+
* scene.play(new Write(circle)); // Circle is drawn progressively
|
|
1623
|
+
*
|
|
1624
|
+
* const text = new Text('Hello');
|
|
1625
|
+
* scene.play(new Write(text)); // Text is written progressively
|
|
1626
|
+
*/
|
|
1627
|
+
declare class Write<T extends VMobject = VMobject> extends IntroductoryAnimation<T> {
|
|
1628
|
+
private readonly isVGroup;
|
|
1629
|
+
/** For non-VGroup targets: original paths on the target itself. */
|
|
1630
|
+
private readonly originalPaths;
|
|
1631
|
+
private readonly originalOpacity;
|
|
1632
|
+
private readonly originalFillOpacity;
|
|
1633
|
+
/** For VGroup targets: original state of each child. */
|
|
1634
|
+
private readonly childStates;
|
|
1635
|
+
constructor(target: T);
|
|
1636
|
+
interpolate(progress: number): void;
|
|
1637
|
+
/** Interpolates a single VMobject (non-VGroup). */
|
|
1638
|
+
private interpolateVMobject;
|
|
1639
|
+
/** Interpolates a VGroup by animating each child's paths. */
|
|
1640
|
+
private interpolateVGroup;
|
|
1641
|
+
}
|
|
1642
|
+
|
|
1643
|
+
/**
|
|
1644
|
+
* Animation that progressively removes a VMobject by erasing the path.
|
|
1645
|
+
* Reverse of Write animation - at progress 0, full object is visible;
|
|
1646
|
+
* at progress 1, nothing is visible.
|
|
1647
|
+
*
|
|
1648
|
+
* Supports VGroup (including Text): animates each child's paths progressively.
|
|
1649
|
+
*
|
|
1650
|
+
* This is an exit animation - the target must already be in the scene.
|
|
1651
|
+
*
|
|
1652
|
+
* @example
|
|
1653
|
+
* scene.play(new Write(text));
|
|
1654
|
+
* scene.play(new Unwrite(text)); // Text is erased progressively
|
|
1655
|
+
*/
|
|
1656
|
+
declare class Unwrite<T extends VMobject = VMobject> extends ExitAnimation<T> {
|
|
1657
|
+
private readonly isVGroup;
|
|
1658
|
+
/** For non-VGroup targets: original paths on the target itself. */
|
|
1659
|
+
private readonly originalPaths;
|
|
1660
|
+
private readonly originalOpacity;
|
|
1661
|
+
private readonly originalFillOpacity;
|
|
1662
|
+
/** For VGroup targets: original state of each child. */
|
|
1663
|
+
private readonly childStates;
|
|
1664
|
+
constructor(target: T);
|
|
1665
|
+
interpolate(progress: number): void;
|
|
1666
|
+
/** Interpolates a single VMobject (non-VGroup). */
|
|
1667
|
+
private interpolateVMobject;
|
|
1668
|
+
/** Interpolates a VGroup by animating each child's paths. */
|
|
1669
|
+
private interpolateVGroup;
|
|
1670
|
+
}
|
|
1671
|
+
|
|
1672
|
+
/**
|
|
1673
|
+
* Supported value types for keyframe interpolation.
|
|
1674
|
+
*/
|
|
1675
|
+
type KeyframeValue = number;
|
|
1676
|
+
/**
|
|
1677
|
+
* A single keyframe with a normalized time position [0,1] and value.
|
|
1678
|
+
*/
|
|
1679
|
+
interface Keyframe<T extends KeyframeValue = KeyframeValue> {
|
|
1680
|
+
/** Normalized time position in [0, 1]. */
|
|
1681
|
+
readonly time: number;
|
|
1682
|
+
/** The value at this keyframe. */
|
|
1683
|
+
readonly value: T;
|
|
1684
|
+
/** Optional easing function for interpolation TO this keyframe. */
|
|
1685
|
+
readonly easing?: EasingFunction;
|
|
1686
|
+
}
|
|
1687
|
+
/**
|
|
1688
|
+
* Interpolation function for a specific value type.
|
|
1689
|
+
* Takes start value, end value, and progress [0,1], returns interpolated value.
|
|
1690
|
+
*/
|
|
1691
|
+
type InterpolatorFn<T> = (start: T, end: T, progress: number) => T;
|
|
1692
|
+
|
|
1693
|
+
/**
|
|
1694
|
+
* Manages a sequence of keyframes for animating a single property.
|
|
1695
|
+
* Keyframes are stored sorted by time and interpolated on demand.
|
|
1696
|
+
*/
|
|
1697
|
+
declare class KeyframeTrack<T extends KeyframeValue = number> {
|
|
1698
|
+
private keyframes;
|
|
1699
|
+
private readonly interpolator;
|
|
1700
|
+
/**
|
|
1701
|
+
* Creates a new KeyframeTrack with the specified interpolator.
|
|
1702
|
+
* Defaults to linear number interpolation.
|
|
1703
|
+
*/
|
|
1704
|
+
constructor(interpolator?: InterpolatorFn<T>);
|
|
1705
|
+
/**
|
|
1706
|
+
* Adds a keyframe at the specified normalized time.
|
|
1707
|
+
* Time must be in [0, 1]. Replaces existing keyframe at same time.
|
|
1708
|
+
*/
|
|
1709
|
+
addKeyframe(time: number, value: T, easing?: EasingFunction): this;
|
|
1710
|
+
removeKeyframe(time: number): boolean;
|
|
1711
|
+
/**
|
|
1712
|
+
* Gets the keyframe at the specified time.
|
|
1713
|
+
* Returns undefined if no keyframe exists at that time.
|
|
1714
|
+
*/
|
|
1715
|
+
getKeyframe(time: number): Keyframe<T> | undefined;
|
|
1716
|
+
/** All keyframes sorted by time. */
|
|
1717
|
+
getKeyframes(): ReadonlyArray<Keyframe<T>>;
|
|
1718
|
+
/** Interpolated value at normalized time (uses target keyframe easing). */
|
|
1719
|
+
getValueAt(time: number): T;
|
|
1720
|
+
getKeyframeCount(): number;
|
|
1721
|
+
}
|
|
1722
|
+
|
|
1723
|
+
/**
|
|
1724
|
+
* Property setter function type for applying values to a Mobject.
|
|
1725
|
+
*/
|
|
1726
|
+
type PropertySetter<T extends Mobject, V> = (target: T, value: V) => void;
|
|
1727
|
+
/**
|
|
1728
|
+
* Animation that interpolates multiple property tracks via keyframes.
|
|
1729
|
+
* Each track controls a single property and is interpolated independently.
|
|
1730
|
+
*
|
|
1731
|
+
* This is a transformative animation - the target must already be in the scene.
|
|
1732
|
+
*/
|
|
1733
|
+
declare class KeyframeAnimation<T extends Mobject = Mobject> extends Animation<T> {
|
|
1734
|
+
private readonly tracks;
|
|
1735
|
+
readonly lifecycle: AnimationLifecycle;
|
|
1736
|
+
/**
|
|
1737
|
+
* Adds a named keyframe track with its property setter.
|
|
1738
|
+
* The setter is called during interpolation to apply values to the target.
|
|
1739
|
+
*/
|
|
1740
|
+
addTrack<V extends KeyframeValue>(name: string, track: KeyframeTrack<V>, setter: PropertySetter<T, V>): this;
|
|
1741
|
+
/** Gets a track by name. */
|
|
1742
|
+
getTrack<V extends KeyframeValue>(name: string): KeyframeTrack<V> | undefined;
|
|
1743
|
+
/** All track names. */
|
|
1744
|
+
getTrackNames(): string[];
|
|
1745
|
+
/**
|
|
1746
|
+
* Interpolates all tracks at the given progress and applies values to target.
|
|
1747
|
+
*/
|
|
1748
|
+
interpolate(progress: number): void;
|
|
1749
|
+
}
|
|
1750
|
+
|
|
1751
|
+
/**
|
|
1752
|
+
* Configuration options for the Follow animation.
|
|
1753
|
+
*/
|
|
1754
|
+
interface FollowConfig {
|
|
1755
|
+
/**
|
|
1756
|
+
* Offset from the target's position. The camera will track
|
|
1757
|
+
* (target.position + offset) instead of the exact target position.
|
|
1758
|
+
* @default Vector2.ZERO
|
|
1759
|
+
*/
|
|
1760
|
+
offset?: Vector2;
|
|
1761
|
+
/**
|
|
1762
|
+
* Damping factor for smooth following (0 to 1).
|
|
1763
|
+
* - 0 = instant snap to target (no smoothing)
|
|
1764
|
+
* - 0.9 = very smooth, slow following
|
|
1765
|
+
* Higher values create a more "laggy" camera that takes longer to catch up.
|
|
1766
|
+
* @default 0
|
|
1767
|
+
*/
|
|
1768
|
+
damping?: number;
|
|
1769
|
+
}
|
|
1770
|
+
/**
|
|
1771
|
+
* Animation that makes a CameraFrame track a target Mobject's position over time.
|
|
1772
|
+
* Unlike MoveTo which captures position once, Follow reads the target position
|
|
1773
|
+
* every frame, allowing the camera to track moving objects.
|
|
1774
|
+
*
|
|
1775
|
+
* @example
|
|
1776
|
+
* // Basic follow - camera snaps to target position
|
|
1777
|
+
* this.play(new Follow(this.frame, movingCircle).duration(5));
|
|
1778
|
+
*
|
|
1779
|
+
* @example
|
|
1780
|
+
* // Smooth follow with damping
|
|
1781
|
+
* this.play(new Follow(this.frame, player, { damping: 0.8 }).duration(10));
|
|
1782
|
+
*
|
|
1783
|
+
* @example
|
|
1784
|
+
* // Follow with offset (camera leads the target)
|
|
1785
|
+
* this.play(new Follow(this.frame, car, {
|
|
1786
|
+
* offset: new Vector2(2, 0), // Camera 2 units ahead
|
|
1787
|
+
* damping: 0.5
|
|
1788
|
+
* }).duration(10));
|
|
1789
|
+
*/
|
|
1790
|
+
declare class Follow extends Animation<CameraFrame> {
|
|
1791
|
+
readonly lifecycle: AnimationLifecycle;
|
|
1792
|
+
private readonly followTarget;
|
|
1793
|
+
private readonly offset;
|
|
1794
|
+
private readonly damping;
|
|
1795
|
+
/**
|
|
1796
|
+
* Creates a new Follow animation.
|
|
1797
|
+
*
|
|
1798
|
+
* @param frame - The CameraFrame to animate
|
|
1799
|
+
* @param target - The Mobject to follow
|
|
1800
|
+
* @param config - Configuration options
|
|
1801
|
+
* @throws Error if frame is null or undefined
|
|
1802
|
+
* @throws Error if target is null or undefined
|
|
1803
|
+
*
|
|
1804
|
+
* @example
|
|
1805
|
+
* const follow = new Follow(scene.frame, player, { damping: 0.7 });
|
|
1806
|
+
* this.play(follow.duration(10));
|
|
1807
|
+
*/
|
|
1808
|
+
constructor(frame: CameraFrame, target: Mobject, config?: FollowConfig);
|
|
1809
|
+
/**
|
|
1810
|
+
* Updates the camera position each frame to track the target.
|
|
1811
|
+
* @param progress - Animation progress (0 to 1)
|
|
1812
|
+
*/
|
|
1813
|
+
interpolate(progress: number): void;
|
|
1814
|
+
}
|
|
1815
|
+
|
|
1816
|
+
/**
|
|
1817
|
+
* Configuration options for the Shake animation.
|
|
1818
|
+
*/
|
|
1819
|
+
interface ShakeConfig {
|
|
1820
|
+
/**
|
|
1821
|
+
* Maximum displacement distance in world units.
|
|
1822
|
+
* Higher values create more violent shaking.
|
|
1823
|
+
* @default 0.2
|
|
1824
|
+
*/
|
|
1825
|
+
intensity?: number;
|
|
1826
|
+
/**
|
|
1827
|
+
* Number of oscillations per second.
|
|
1828
|
+
* Higher values create faster, more frantic shaking.
|
|
1829
|
+
* @default 10
|
|
1830
|
+
*/
|
|
1831
|
+
frequency?: number;
|
|
1832
|
+
/**
|
|
1833
|
+
* Controls how quickly the shake diminishes over time.
|
|
1834
|
+
* - 0 = no decay (constant intensity throughout)
|
|
1835
|
+
* - 1 = linear decay
|
|
1836
|
+
* - Higher values = faster decay (shake fades quickly)
|
|
1837
|
+
* @default 1
|
|
1838
|
+
*/
|
|
1839
|
+
decay?: number;
|
|
1840
|
+
}
|
|
1841
|
+
/**
|
|
1842
|
+
* Camera shake effect animation.
|
|
1843
|
+
* Creates procedural displacement using layered sine waves to simulate
|
|
1844
|
+
* impacts, explosions, or earthquakes.
|
|
1845
|
+
*
|
|
1846
|
+
* The shake automatically returns to the original position when complete.
|
|
1847
|
+
*
|
|
1848
|
+
* @example
|
|
1849
|
+
* // Basic shake effect
|
|
1850
|
+
* this.play(new Shake(this.frame).duration(0.5));
|
|
1851
|
+
*
|
|
1852
|
+
* @example
|
|
1853
|
+
* // Intense explosion shake with quick decay
|
|
1854
|
+
* this.play(new Shake(this.frame, {
|
|
1855
|
+
* intensity: 0.5,
|
|
1856
|
+
* frequency: 20,
|
|
1857
|
+
* decay: 2
|
|
1858
|
+
* }).duration(0.3));
|
|
1859
|
+
*
|
|
1860
|
+
* @example
|
|
1861
|
+
* // Subtle earthquake with slow decay
|
|
1862
|
+
* this.play(new Shake(this.frame, {
|
|
1863
|
+
* intensity: 0.1,
|
|
1864
|
+
* frequency: 5,
|
|
1865
|
+
* decay: 0.5
|
|
1866
|
+
* }).duration(3));
|
|
1867
|
+
*/
|
|
1868
|
+
declare class Shake extends TransformativeAnimation<CameraFrame> {
|
|
1869
|
+
private originalPosition;
|
|
1870
|
+
private readonly intensity;
|
|
1871
|
+
private readonly frequency;
|
|
1872
|
+
private readonly decay;
|
|
1873
|
+
private readonly seedX;
|
|
1874
|
+
private readonly seedY;
|
|
1875
|
+
/**
|
|
1876
|
+
* Creates a new Shake animation.
|
|
1877
|
+
*
|
|
1878
|
+
* @param frame - The CameraFrame to shake
|
|
1879
|
+
* @param config - Configuration options for intensity, frequency, and decay
|
|
1880
|
+
*
|
|
1881
|
+
* @example
|
|
1882
|
+
* const shake = new Shake(scene.frame, { intensity: 0.3 });
|
|
1883
|
+
* this.play(shake.duration(0.5));
|
|
1884
|
+
*/
|
|
1885
|
+
constructor(frame: CameraFrame, config?: ShakeConfig);
|
|
1886
|
+
/**
|
|
1887
|
+
* Captures the original position before shake begins.
|
|
1888
|
+
*/
|
|
1889
|
+
protected captureStartState(): void;
|
|
1890
|
+
/**
|
|
1891
|
+
* Applies procedural shake displacement each frame.
|
|
1892
|
+
* @param progress - Animation progress (0 to 1)
|
|
1893
|
+
*/
|
|
1894
|
+
interpolate(progress: number): void;
|
|
1895
|
+
/**
|
|
1896
|
+
* Generates pseudo-random noise using layered sine waves.
|
|
1897
|
+
* @param t - Time value
|
|
1898
|
+
* @param seed - Random seed for variation
|
|
1899
|
+
* @returns Noise value between -1 and 1
|
|
1900
|
+
*/
|
|
1901
|
+
private noise;
|
|
1902
|
+
}
|
|
1903
|
+
|
|
1904
|
+
/**
|
|
1905
|
+
* Scene serialization - the main entry point for serializing/deserializing Scenes.
|
|
1906
|
+
*/
|
|
1907
|
+
|
|
1908
|
+
/**
|
|
1909
|
+
* Serializes a Scene into a JSON-formatted string.
|
|
1910
|
+
*
|
|
1911
|
+
* Useful for saving scene state to a file or transmitting it over a network.
|
|
1912
|
+
*/
|
|
1913
|
+
declare function serialize(scene: Scene): string;
|
|
1914
|
+
/**
|
|
1915
|
+
* Restores a complete Scene from a JSON-formatted string.
|
|
1916
|
+
*/
|
|
1917
|
+
declare function deserialize(json: string): Scene;
|
|
1918
|
+
|
|
1919
|
+
/**
|
|
1920
|
+
* Supported render output formats.
|
|
1921
|
+
* - sprite: PNG sequence (frame_0000.png, frame_0001.png, ...)
|
|
1922
|
+
* - png: Single PNG frame
|
|
1923
|
+
* - mp4: H.264 video (requires FFmpeg - future)
|
|
1924
|
+
* - webp: Animated WebP (requires FFmpeg - future)
|
|
1925
|
+
* - gif: Animated GIF (requires FFmpeg - future)
|
|
1926
|
+
*/
|
|
1927
|
+
type RenderFormat = 'sprite' | 'png' | 'mp4' | 'webp' | 'gif';
|
|
1928
|
+
/**
|
|
1929
|
+
* Quality presets for rendering.
|
|
1930
|
+
* - production: Full resolution, best quality
|
|
1931
|
+
* - preview: Half resolution for faster preview
|
|
1932
|
+
*/
|
|
1933
|
+
type RenderQuality = 'production' | 'preview';
|
|
1934
|
+
/**
|
|
1935
|
+
* Standard resolution presets.
|
|
1936
|
+
*/
|
|
1937
|
+
declare const Resolution: {
|
|
1938
|
+
/** 854x480 (16:9) */
|
|
1939
|
+
readonly p480: {
|
|
1940
|
+
readonly width: 854;
|
|
1941
|
+
readonly height: 480;
|
|
1942
|
+
};
|
|
1943
|
+
/** 1280x720 (16:9) */
|
|
1944
|
+
readonly p720: {
|
|
1945
|
+
readonly width: 1280;
|
|
1946
|
+
readonly height: 720;
|
|
1947
|
+
};
|
|
1948
|
+
/** 1920x1080 (16:9) */
|
|
1949
|
+
readonly p1080: {
|
|
1950
|
+
readonly width: 1920;
|
|
1951
|
+
readonly height: 1080;
|
|
1952
|
+
};
|
|
1953
|
+
/** 3840x2160 (16:9) */
|
|
1954
|
+
readonly p4K: {
|
|
1955
|
+
readonly width: 3840;
|
|
1956
|
+
readonly height: 2160;
|
|
1957
|
+
};
|
|
1958
|
+
};
|
|
1959
|
+
/**
|
|
1960
|
+
* Configuration for rendering.
|
|
1961
|
+
*/
|
|
1962
|
+
interface RenderConfig {
|
|
1963
|
+
/** Output width in pixels. Defaults to scene width. */
|
|
1964
|
+
width?: number;
|
|
1965
|
+
/** Output height in pixels. Defaults to scene height. */
|
|
1966
|
+
height?: number;
|
|
1967
|
+
/** Frames per second. Defaults to scene frame rate. */
|
|
1968
|
+
frameRate?: number;
|
|
1969
|
+
/** Output format. Defaults to 'sprite'. */
|
|
1970
|
+
format?: RenderFormat;
|
|
1971
|
+
/** Quality preset. Defaults to 'production'. */
|
|
1972
|
+
quality?: RenderQuality;
|
|
1973
|
+
/** Progress callback for render updates. */
|
|
1974
|
+
onProgress?: ProgressCallback;
|
|
1975
|
+
}
|
|
1976
|
+
/**
|
|
1977
|
+
* Progress information during rendering.
|
|
1978
|
+
*/
|
|
1979
|
+
interface RenderProgress {
|
|
1980
|
+
/** Current frame being rendered (0-indexed). */
|
|
1981
|
+
currentFrame: number;
|
|
1982
|
+
/** Total number of frames to render. */
|
|
1983
|
+
totalFrames: number;
|
|
1984
|
+
/** Percentage complete (0-100). */
|
|
1985
|
+
percentage: number;
|
|
1986
|
+
/** Elapsed time in milliseconds. */
|
|
1987
|
+
elapsedMs: number;
|
|
1988
|
+
/** Estimated remaining time in milliseconds. */
|
|
1989
|
+
estimatedRemainingMs: number;
|
|
1990
|
+
}
|
|
1991
|
+
/**
|
|
1992
|
+
* Callback for progress updates during rendering.
|
|
1993
|
+
*/
|
|
1994
|
+
type ProgressCallback = (progress: RenderProgress) => void;
|
|
1995
|
+
|
|
1996
|
+
/**
|
|
1997
|
+
* Main renderer for producing output from Scenes.
|
|
1998
|
+
* Supports multiple output formats and provides progress callbacks.
|
|
1999
|
+
*/
|
|
2000
|
+
declare class Renderer {
|
|
2001
|
+
/**
|
|
2002
|
+
* Renders a scene to the specified output.
|
|
2003
|
+
*
|
|
2004
|
+
* @param scene The scene to render
|
|
2005
|
+
* @param outputPath Output file or directory path (depends on format)
|
|
2006
|
+
* @param config Optional render configuration
|
|
2007
|
+
*/
|
|
2008
|
+
render(scene: Scene, outputPath: string, config?: RenderConfig): Promise<void>;
|
|
2009
|
+
/**
|
|
2010
|
+
* Renders only the last frame of a scene as a PNG.
|
|
2011
|
+
*
|
|
2012
|
+
* @param scene The scene to render
|
|
2013
|
+
* @param outputPath Output PNG file path
|
|
2014
|
+
* @param config Optional render configuration
|
|
2015
|
+
*/
|
|
2016
|
+
renderLastFrame(scene: Scene, outputPath: string, config?: RenderConfig): Promise<void>;
|
|
2017
|
+
/**
|
|
2018
|
+
* Resolves partial config with scene defaults.
|
|
2019
|
+
*/
|
|
2020
|
+
private resolveConfig;
|
|
2021
|
+
/**
|
|
2022
|
+
* Ensures the directory exists.
|
|
2023
|
+
*/
|
|
2024
|
+
private ensureDirectory;
|
|
2025
|
+
/**
|
|
2026
|
+
* Renders a single frame (the last frame of the animation).
|
|
2027
|
+
*/
|
|
2028
|
+
private renderSingleFrame;
|
|
2029
|
+
}
|
|
2030
|
+
|
|
2031
|
+
/**
|
|
2032
|
+
* Renders individual frames from a Scene.
|
|
2033
|
+
* Responsible for drawing mobjects to a canvas at a specific point in time.
|
|
2034
|
+
*/
|
|
2035
|
+
declare class FrameRenderer {
|
|
2036
|
+
private readonly scene;
|
|
2037
|
+
private readonly width;
|
|
2038
|
+
private readonly height;
|
|
2039
|
+
constructor(scene: Scene, width: number, height: number);
|
|
2040
|
+
/**
|
|
2041
|
+
* Calculates the matrix that transforms Manim world coordinates to screen pixels.
|
|
2042
|
+
*
|
|
2043
|
+
* Manim coordinate system:
|
|
2044
|
+
* - Origin at center of screen
|
|
2045
|
+
* - Y-axis points up
|
|
2046
|
+
* - frameHeight = 8.0 units
|
|
2047
|
+
*
|
|
2048
|
+
* Screen coordinate system:
|
|
2049
|
+
* - Origin at top-left
|
|
2050
|
+
* - Y-axis points down
|
|
2051
|
+
* - Width x Height pixels
|
|
2052
|
+
*/
|
|
2053
|
+
private calculateWorldToScreenMatrix;
|
|
2054
|
+
/**
|
|
2055
|
+
* Renders a single frame at the specified time.
|
|
2056
|
+
*/
|
|
2057
|
+
renderFrame(time: number): Canvas;
|
|
2058
|
+
/**
|
|
2059
|
+
* Gets the canvas dimensions.
|
|
2060
|
+
*/
|
|
2061
|
+
getDimensions(): {
|
|
2062
|
+
width: number;
|
|
2063
|
+
height: number;
|
|
2064
|
+
};
|
|
2065
|
+
}
|
|
2066
|
+
|
|
2067
|
+
/**
|
|
2068
|
+
* Tracks rendering progress and reports updates via callback.
|
|
2069
|
+
*/
|
|
2070
|
+
declare class ProgressReporter {
|
|
2071
|
+
private readonly totalFrames;
|
|
2072
|
+
private readonly onProgress?;
|
|
2073
|
+
private readonly startTime;
|
|
2074
|
+
private currentFrame;
|
|
2075
|
+
constructor(totalFrames: number, onProgress?: ProgressCallback);
|
|
2076
|
+
/**
|
|
2077
|
+
* Report progress for the current frame.
|
|
2078
|
+
*/
|
|
2079
|
+
reportFrame(frameIndex: number): void;
|
|
2080
|
+
/**
|
|
2081
|
+
* Report rendering complete.
|
|
2082
|
+
*/
|
|
2083
|
+
complete(): void;
|
|
2084
|
+
}
|
|
2085
|
+
|
|
2086
|
+
export { Animation, type AnimationConfig, Arc, Arrow, Camera, type CameraConfig, CameraFrame, Circle, Color, Draw, type EasingFunction, type EdgeConfig, FadeIn, FadeOut, Follow, FrameRenderer, Glyph, Graph, GraphEdge, GraphNode, type GraphNodeId, type Keyframe, KeyframeAnimation, KeyframeTrack, type LayoutConfig, type LayoutType, Line, Mobject, MorphTo, MoveTo, type NodeConfig, Parallel, Point, Polygon, type ProgressCallback, ProgressReporter, Rectangle, type RenderConfig, type RenderFormat, type RenderProgress, type RenderQuality, Renderer, Resolution, type ResolvedCameraConfig, Rotate, Scale, Scene, type SceneConfig, type ScheduledAnimation, Sequence, Shake, Text, type TextStyle, Timeline, type TimelineConfig, Unwrite, VGroup, VMobject, Vector2, Write, clearRegistry, smooth as defaultEasing, deserialize, doubleSmooth, easeInBack, easeInBounce, easeInCirc, easeInCubic, easeInElastic, easeInExpo, easeInOutBack, easeInOutBounce, easeInOutCirc, easeInOutCubic, easeInOutElastic, easeInOutExpo, easeInOutQuad, easeInOutQuart, easeInOutQuint, easeInOutSine, easeInQuad, easeInQuart, easeInQuint, easeInSine, easeOutBack, easeOutBounce, easeOutCirc, easeOutCubic, easeOutElastic, easeOutExpo, easeOutQuad, easeOutQuart, easeOutQuint, easeOutSine, exponentialDecay, getEasing, hasEasing, linear, lingering, notQuiteThere, registerEasing, runningStart, rushFrom, rushInto, serialize, slowInto, smooth, thereAndBack, thereAndBackWithPause, unregisterEasing, wiggle };
|