@redwilly/anima 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/index.js +203 -57
- package/dist/index.d.ts +2086 -18
- package/dist/index.js +5343 -22
- package/package.json +5 -3
- package/dist/cli/SceneLoader.d.ts +0 -22
- package/dist/cli/SceneLoader.js +0 -47
- package/dist/cli/commands/export-frame.d.ts +0 -13
- package/dist/cli/commands/export-frame.js +0 -60
- package/dist/cli/commands/list-scenes.d.ts +0 -5
- package/dist/cli/commands/list-scenes.js +0 -22
- package/dist/cli/commands/preview.d.ts +0 -5
- package/dist/cli/commands/preview.js +0 -11
- package/dist/cli/commands/render.d.ts +0 -16
- package/dist/cli/commands/render.js +0 -76
- package/dist/cli/index.d.ts +0 -2
- package/dist/core/animations/Animation.d.ts +0 -41
- package/dist/core/animations/Animation.js +0 -76
- package/dist/core/animations/camera/Follow.d.ts +0 -70
- package/dist/core/animations/camera/Follow.js +0 -69
- package/dist/core/animations/camera/Shake.d.ts +0 -90
- package/dist/core/animations/camera/Shake.js +0 -87
- package/dist/core/animations/camera/index.d.ts +0 -2
- package/dist/core/animations/camera/index.js +0 -2
- package/dist/core/animations/categories/ExitAnimation.d.ts +0 -17
- package/dist/core/animations/categories/ExitAnimation.js +0 -15
- package/dist/core/animations/categories/IntroductoryAnimation.d.ts +0 -16
- package/dist/core/animations/categories/IntroductoryAnimation.js +0 -14
- package/dist/core/animations/categories/TransformativeAnimation.d.ts +0 -25
- package/dist/core/animations/categories/TransformativeAnimation.js +0 -25
- package/dist/core/animations/categories/index.d.ts +0 -3
- package/dist/core/animations/categories/index.js +0 -3
- package/dist/core/animations/composition/Parallel.d.ts +0 -37
- package/dist/core/animations/composition/Parallel.js +0 -79
- package/dist/core/animations/composition/Sequence.d.ts +0 -41
- package/dist/core/animations/composition/Sequence.js +0 -95
- package/dist/core/animations/composition/index.d.ts +0 -2
- package/dist/core/animations/composition/index.js +0 -3
- package/dist/core/animations/draw/Draw.d.ts +0 -30
- package/dist/core/animations/draw/Draw.js +0 -122
- package/dist/core/animations/draw/Unwrite.d.ts +0 -30
- package/dist/core/animations/draw/Unwrite.js +0 -120
- package/dist/core/animations/draw/Write.d.ts +0 -35
- package/dist/core/animations/draw/Write.js +0 -119
- package/dist/core/animations/draw/index.d.ts +0 -3
- package/dist/core/animations/draw/index.js +0 -3
- package/dist/core/animations/draw/partialPath.d.ts +0 -6
- package/dist/core/animations/draw/partialPath.js +0 -138
- package/dist/core/animations/easing/bounce.d.ts +0 -13
- package/dist/core/animations/easing/bounce.js +0 -37
- package/dist/core/animations/easing/index.d.ts +0 -7
- package/dist/core/animations/easing/index.js +0 -11
- package/dist/core/animations/easing/manim.d.ts +0 -46
- package/dist/core/animations/easing/manim.js +0 -102
- package/dist/core/animations/easing/registry.d.ts +0 -8
- package/dist/core/animations/easing/registry.js +0 -25
- package/dist/core/animations/easing/standard.d.ts +0 -113
- package/dist/core/animations/easing/standard.js +0 -151
- package/dist/core/animations/easing/types.d.ts +0 -6
- package/dist/core/animations/easing/types.js +0 -0
- package/dist/core/animations/fade/FadeIn.d.ts +0 -17
- package/dist/core/animations/fade/FadeIn.js +0 -22
- package/dist/core/animations/fade/FadeOut.d.ts +0 -17
- package/dist/core/animations/fade/FadeOut.js +0 -23
- package/dist/core/animations/fade/index.d.ts +0 -2
- package/dist/core/animations/fade/index.js +0 -2
- package/dist/core/animations/index.d.ts +0 -11
- package/dist/core/animations/index.js +0 -17
- package/dist/core/animations/keyframes/KeyframeAnimation.d.ts +0 -33
- package/dist/core/animations/keyframes/KeyframeAnimation.js +0 -40
- package/dist/core/animations/keyframes/KeyframeTrack.d.ts +0 -31
- package/dist/core/animations/keyframes/KeyframeTrack.js +0 -83
- package/dist/core/animations/keyframes/index.d.ts +0 -4
- package/dist/core/animations/keyframes/index.js +0 -5
- package/dist/core/animations/keyframes/types.d.ts +0 -25
- package/dist/core/animations/keyframes/types.js +0 -6
- package/dist/core/animations/morph/MorphTo.d.ts +0 -22
- package/dist/core/animations/morph/MorphTo.js +0 -42
- package/dist/core/animations/morph/index.d.ts +0 -1
- package/dist/core/animations/morph/index.js +0 -1
- package/dist/core/animations/transform/MoveTo.d.ts +0 -24
- package/dist/core/animations/transform/MoveTo.js +0 -38
- package/dist/core/animations/transform/Rotate.d.ts +0 -23
- package/dist/core/animations/transform/Rotate.js +0 -34
- package/dist/core/animations/transform/Scale.d.ts +0 -23
- package/dist/core/animations/transform/Scale.js +0 -35
- package/dist/core/animations/transform/index.d.ts +0 -3
- package/dist/core/animations/transform/index.js +0 -3
- package/dist/core/animations/types.d.ts +0 -52
- package/dist/core/animations/types.js +0 -6
- package/dist/core/camera/Camera.d.ts +0 -87
- package/dist/core/camera/Camera.js +0 -175
- package/dist/core/camera/CameraFrame.d.ts +0 -242
- package/dist/core/camera/CameraFrame.js +0 -322
- package/dist/core/camera/index.d.ts +0 -4
- package/dist/core/camera/index.js +0 -3
- package/dist/core/camera/types.d.ts +0 -17
- package/dist/core/camera/types.js +0 -1
- package/dist/core/errors/AnimationErrors.d.ts +0 -12
- package/dist/core/errors/AnimationErrors.js +0 -37
- package/dist/core/errors/index.d.ts +0 -1
- package/dist/core/errors/index.js +0 -1
- package/dist/core/math/Vector2/Vector2.d.ts +0 -23
- package/dist/core/math/Vector2/Vector2.js +0 -46
- package/dist/core/math/Vector2/index.d.ts +0 -1
- package/dist/core/math/Vector2/index.js +0 -1
- package/dist/core/math/bezier/BezierPath.d.ts +0 -38
- package/dist/core/math/bezier/BezierPath.js +0 -264
- package/dist/core/math/bezier/evaluators.d.ts +0 -9
- package/dist/core/math/bezier/evaluators.js +0 -36
- package/dist/core/math/bezier/index.d.ts +0 -8
- package/dist/core/math/bezier/index.js +0 -6
- package/dist/core/math/bezier/length.d.ts +0 -5
- package/dist/core/math/bezier/length.js +0 -27
- package/dist/core/math/bezier/morphing.d.ts +0 -16
- package/dist/core/math/bezier/morphing.js +0 -151
- package/dist/core/math/bezier/sampling.d.ts +0 -7
- package/dist/core/math/bezier/sampling.js +0 -153
- package/dist/core/math/bezier/split.d.ts +0 -19
- package/dist/core/math/bezier/split.js +0 -44
- package/dist/core/math/bezier/types.d.ts +0 -8
- package/dist/core/math/bezier/types.js +0 -0
- package/dist/core/math/color/Color.d.ts +0 -28
- package/dist/core/math/color/Color.js +0 -60
- package/dist/core/math/color/conversions.d.ts +0 -17
- package/dist/core/math/color/conversions.js +0 -100
- package/dist/core/math/color/index.d.ts +0 -2
- package/dist/core/math/color/index.js +0 -2
- package/dist/core/math/index.d.ts +0 -4
- package/dist/core/math/index.js +0 -5
- package/dist/core/math/matrix/Matrix3x3.d.ts +0 -23
- package/dist/core/math/matrix/Matrix3x3.js +0 -91
- package/dist/core/math/matrix/factories.d.ts +0 -12
- package/dist/core/math/matrix/factories.js +0 -44
- package/dist/core/math/matrix/index.d.ts +0 -2
- package/dist/core/math/matrix/index.js +0 -2
- package/dist/core/renderer/FrameRenderer.d.ts +0 -37
- package/dist/core/renderer/FrameRenderer.js +0 -75
- package/dist/core/renderer/ProgressReporter.d.ts +0 -19
- package/dist/core/renderer/ProgressReporter.js +0 -58
- package/dist/core/renderer/Renderer.d.ts +0 -36
- package/dist/core/renderer/Renderer.js +0 -102
- package/dist/core/renderer/drawMobject.d.ts +0 -8
- package/dist/core/renderer/drawMobject.js +0 -109
- package/dist/core/renderer/formats/index.d.ts +0 -3
- package/dist/core/renderer/formats/index.js +0 -3
- package/dist/core/renderer/formats/png.d.ts +0 -5
- package/dist/core/renderer/formats/png.js +0 -7
- package/dist/core/renderer/formats/sprite.d.ts +0 -6
- package/dist/core/renderer/formats/sprite.js +0 -24
- package/dist/core/renderer/formats/video.d.ts +0 -8
- package/dist/core/renderer/formats/video.js +0 -51
- package/dist/core/renderer/index.d.ts +0 -7
- package/dist/core/renderer/index.js +0 -9
- package/dist/core/renderer/types.d.ts +0 -87
- package/dist/core/renderer/types.js +0 -13
- package/dist/core/scene/Scene.d.ts +0 -104
- package/dist/core/scene/Scene.js +0 -225
- package/dist/core/scene/index.d.ts +0 -2
- package/dist/core/scene/index.js +0 -1
- package/dist/core/scene/types.d.ts +0 -23
- package/dist/core/scene/types.js +0 -0
- package/dist/core/serialization/animation.d.ts +0 -23
- package/dist/core/serialization/animation.js +0 -176
- package/dist/core/serialization/easingLookup.d.ts +0 -13
- package/dist/core/serialization/easingLookup.js +0 -65
- package/dist/core/serialization/index.d.ts +0 -23
- package/dist/core/serialization/index.js +0 -29
- package/dist/core/serialization/mobject.d.ts +0 -23
- package/dist/core/serialization/mobject.js +0 -248
- package/dist/core/serialization/prettyPrint.d.ts +0 -12
- package/dist/core/serialization/prettyPrint.js +0 -16
- package/dist/core/serialization/primitives.d.ts +0 -24
- package/dist/core/serialization/primitives.js +0 -98
- package/dist/core/serialization/registry.d.ts +0 -29
- package/dist/core/serialization/registry.js +0 -39
- package/dist/core/serialization/scene.d.ts +0 -28
- package/dist/core/serialization/scene.js +0 -114
- package/dist/core/serialization/types.d.ts +0 -152
- package/dist/core/serialization/types.js +0 -6
- package/dist/core/timeline/Timeline.d.ts +0 -70
- package/dist/core/timeline/Timeline.js +0 -144
- package/dist/core/timeline/index.d.ts +0 -5
- package/dist/core/timeline/index.js +0 -4
- package/dist/core/timeline/types.d.ts +0 -29
- package/dist/core/timeline/types.js +0 -0
- package/dist/mobjects/Mobject.d.ts +0 -98
- package/dist/mobjects/Mobject.js +0 -343
- package/dist/mobjects/VGroup/VGroup.d.ts +0 -51
- package/dist/mobjects/VGroup/VGroup.js +0 -142
- package/dist/mobjects/VGroup/index.d.ts +0 -3
- package/dist/mobjects/VGroup/index.js +0 -2
- package/dist/mobjects/VGroup/layout.d.ts +0 -20
- package/dist/mobjects/VGroup/layout.js +0 -139
- package/dist/mobjects/VMobject.d.ts +0 -106
- package/dist/mobjects/VMobject.js +0 -216
- package/dist/mobjects/geometry/Arc.d.ts +0 -8
- package/dist/mobjects/geometry/Arc.js +0 -46
- package/dist/mobjects/geometry/Arrow.d.ts +0 -7
- package/dist/mobjects/geometry/Arrow.js +0 -34
- package/dist/mobjects/geometry/Circle.d.ts +0 -4
- package/dist/mobjects/geometry/Circle.js +0 -10
- package/dist/mobjects/geometry/Line.d.ts +0 -8
- package/dist/mobjects/geometry/Line.js +0 -19
- package/dist/mobjects/geometry/Point.d.ts +0 -5
- package/dist/mobjects/geometry/Point.js +0 -11
- package/dist/mobjects/geometry/Polygon.d.ts +0 -7
- package/dist/mobjects/geometry/Polygon.js +0 -21
- package/dist/mobjects/geometry/Rectangle.d.ts +0 -6
- package/dist/mobjects/geometry/Rectangle.js +0 -18
- package/dist/mobjects/geometry/index.d.ts +0 -7
- package/dist/mobjects/geometry/index.js +0 -7
- package/dist/mobjects/graph/Graph.d.ts +0 -28
- package/dist/mobjects/graph/Graph.js +0 -119
- package/dist/mobjects/graph/GraphEdge.d.ts +0 -26
- package/dist/mobjects/graph/GraphEdge.js +0 -64
- package/dist/mobjects/graph/GraphNode.d.ts +0 -19
- package/dist/mobjects/graph/GraphNode.js +0 -63
- package/dist/mobjects/graph/index.d.ts +0 -5
- package/dist/mobjects/graph/index.js +0 -5
- package/dist/mobjects/graph/layouts/circular.d.ts +0 -8
- package/dist/mobjects/graph/layouts/circular.js +0 -23
- package/dist/mobjects/graph/layouts/forceDirected.d.ts +0 -9
- package/dist/mobjects/graph/layouts/forceDirected.js +0 -102
- package/dist/mobjects/graph/layouts/index.d.ts +0 -3
- package/dist/mobjects/graph/layouts/index.js +0 -3
- package/dist/mobjects/graph/layouts/tree.d.ts +0 -9
- package/dist/mobjects/graph/layouts/tree.js +0 -99
- package/dist/mobjects/graph/types.d.ts +0 -35
- package/dist/mobjects/graph/types.js +0 -0
- package/dist/mobjects/index.d.ts +0 -6
- package/dist/mobjects/index.js +0 -6
- package/dist/mobjects/text/Glyph.d.ts +0 -11
- package/dist/mobjects/text/Glyph.js +0 -72
- package/dist/mobjects/text/Text.d.ts +0 -19
- package/dist/mobjects/text/Text.js +0 -76
- package/dist/mobjects/text/index.d.ts +0 -4
- package/dist/mobjects/text/index.js +0 -3
- package/dist/mobjects/text/types.d.ts +0 -12
- package/dist/mobjects/text/types.js +0 -8
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { TransformativeAnimation } from '../categories';
|
|
2
|
-
import { VMobject } from '../../../mobjects/VMobject';
|
|
3
|
-
/**
|
|
4
|
-
* Animation that morphs a VMobject from its current shape to a target shape.
|
|
5
|
-
* Uses BezierPath interpolation for smooth path transitions.
|
|
6
|
-
*
|
|
7
|
-
* This is a transformative animation - the source must already be in the scene.
|
|
8
|
-
* The target VMobject is used only as a shape template and is NOT added to the scene.
|
|
9
|
-
* Source paths are captured lazily when animation becomes active.
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* scene.add(circle);
|
|
13
|
-
* scene.play(new MorphTo(circle, square)); // circle morphs into square's shape
|
|
14
|
-
*/
|
|
15
|
-
export declare class MorphTo<T extends VMobject = VMobject> extends TransformativeAnimation<T> {
|
|
16
|
-
private sourcePaths;
|
|
17
|
-
private readonly targetPaths;
|
|
18
|
-
constructor(source: T, target: VMobject);
|
|
19
|
-
protected captureStartState(): void;
|
|
20
|
-
interpolate(progress: number): void;
|
|
21
|
-
private getEmptyPath;
|
|
22
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { TransformativeAnimation } from '../categories';
|
|
2
|
-
import { BezierPath } from '../../math/bezier/BezierPath';
|
|
3
|
-
/**
|
|
4
|
-
* Animation that morphs a VMobject from its current shape to a target shape.
|
|
5
|
-
* Uses BezierPath interpolation for smooth path transitions.
|
|
6
|
-
*
|
|
7
|
-
* This is a transformative animation - the source must already be in the scene.
|
|
8
|
-
* The target VMobject is used only as a shape template and is NOT added to the scene.
|
|
9
|
-
* Source paths are captured lazily when animation becomes active.
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* scene.add(circle);
|
|
13
|
-
* scene.play(new MorphTo(circle, square)); // circle morphs into square's shape
|
|
14
|
-
*/
|
|
15
|
-
export class MorphTo extends TransformativeAnimation {
|
|
16
|
-
sourcePaths;
|
|
17
|
-
targetPaths;
|
|
18
|
-
constructor(source, target) {
|
|
19
|
-
super(source);
|
|
20
|
-
this.targetPaths = target.paths.map(p => p.clone());
|
|
21
|
-
}
|
|
22
|
-
captureStartState() {
|
|
23
|
-
this.sourcePaths = this.target.paths.map(p => p.clone());
|
|
24
|
-
}
|
|
25
|
-
interpolate(progress) {
|
|
26
|
-
this.ensureInitialized();
|
|
27
|
-
const maxPaths = Math.max(this.sourcePaths.length, this.targetPaths.length);
|
|
28
|
-
const newPaths = [];
|
|
29
|
-
for (let i = 0; i < maxPaths; i++) {
|
|
30
|
-
const sourcePath = this.sourcePaths[i] ?? this.getEmptyPath();
|
|
31
|
-
const targetPath = this.targetPaths[i] ?? this.getEmptyPath();
|
|
32
|
-
const interpolated = BezierPath.interpolate(sourcePath, targetPath, progress);
|
|
33
|
-
newPaths.push(interpolated);
|
|
34
|
-
}
|
|
35
|
-
this.target.paths = newPaths;
|
|
36
|
-
}
|
|
37
|
-
getEmptyPath() {
|
|
38
|
-
const path = new BezierPath();
|
|
39
|
-
path.moveTo(this.target.position);
|
|
40
|
-
return path;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { MorphTo } from './MorphTo';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { MorphTo } from './MorphTo';
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { TransformativeAnimation } from '../categories';
|
|
2
|
-
import { Mobject } from '../../../mobjects/Mobject';
|
|
3
|
-
import { Vector2 } from '../../math/Vector2/Vector2';
|
|
4
|
-
/**
|
|
5
|
-
* Animation that moves a Mobject from its current position to a destination.
|
|
6
|
-
* Uses linear interpolation between start and end positions.
|
|
7
|
-
*
|
|
8
|
-
* This is a transformative animation - the target must already be in the scene.
|
|
9
|
-
* Start position is captured lazily when animation becomes active.
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* scene.add(circle); // or use FadeIn first
|
|
13
|
-
* scene.play(new MoveTo(circle, 2, 0)); // Move to (2, 0)
|
|
14
|
-
*/
|
|
15
|
-
export declare class MoveTo<T extends Mobject = Mobject> extends TransformativeAnimation<T> {
|
|
16
|
-
private startPosition;
|
|
17
|
-
private readonly endPosition;
|
|
18
|
-
constructor(target: T, destination: Vector2);
|
|
19
|
-
constructor(target: T, x: number, y: number);
|
|
20
|
-
protected captureStartState(): void;
|
|
21
|
-
interpolate(progress: number): void;
|
|
22
|
-
/** Returns the target position of the move animation. */
|
|
23
|
-
getDestination(): Vector2;
|
|
24
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { TransformativeAnimation } from '../categories';
|
|
2
|
-
import { Vector2 } from '../../math/Vector2/Vector2';
|
|
3
|
-
/**
|
|
4
|
-
* Animation that moves a Mobject from its current position to a destination.
|
|
5
|
-
* Uses linear interpolation between start and end positions.
|
|
6
|
-
*
|
|
7
|
-
* This is a transformative animation - the target must already be in the scene.
|
|
8
|
-
* Start position is captured lazily when animation becomes active.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* scene.add(circle); // or use FadeIn first
|
|
12
|
-
* scene.play(new MoveTo(circle, 2, 0)); // Move to (2, 0)
|
|
13
|
-
*/
|
|
14
|
-
export class MoveTo extends TransformativeAnimation {
|
|
15
|
-
startPosition;
|
|
16
|
-
endPosition;
|
|
17
|
-
constructor(target, xOrDestination, y) {
|
|
18
|
-
super(target);
|
|
19
|
-
if (xOrDestination instanceof Vector2) {
|
|
20
|
-
this.endPosition = xOrDestination;
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
this.endPosition = new Vector2(xOrDestination, y ?? 0);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
captureStartState() {
|
|
27
|
-
this.startPosition = this.target.position;
|
|
28
|
-
}
|
|
29
|
-
interpolate(progress) {
|
|
30
|
-
this.ensureInitialized();
|
|
31
|
-
const newPosition = this.startPosition.lerp(this.endPosition, progress);
|
|
32
|
-
this.target.pos(newPosition.x, newPosition.y);
|
|
33
|
-
}
|
|
34
|
-
/** Returns the target position of the move animation. */
|
|
35
|
-
getDestination() {
|
|
36
|
-
return this.endPosition;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { TransformativeAnimation } from '../categories';
|
|
2
|
-
import type { Mobject } from '../../../mobjects/Mobject';
|
|
3
|
-
/**
|
|
4
|
-
* Animation that rotates a Mobject by a specified angle.
|
|
5
|
-
* Uses linear interpolation between start and end rotation.
|
|
6
|
-
*
|
|
7
|
-
* This is a transformative animation - the target must already be in the scene.
|
|
8
|
-
* Start rotation is captured lazily when animation becomes active.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* scene.add(square);
|
|
12
|
-
* scene.play(new Rotate(square, Math.PI / 4)); // Rotate 45 degrees
|
|
13
|
-
*/
|
|
14
|
-
export declare class Rotate<T extends Mobject = Mobject> extends TransformativeAnimation<T> {
|
|
15
|
-
private startRotation;
|
|
16
|
-
private endRotation;
|
|
17
|
-
private readonly angle;
|
|
18
|
-
constructor(target: T, angle: number);
|
|
19
|
-
protected captureStartState(): void;
|
|
20
|
-
interpolate(progress: number): void;
|
|
21
|
-
/** Returns the total rotation angle in radians. */
|
|
22
|
-
getAngle(): number;
|
|
23
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { TransformativeAnimation } from '../categories';
|
|
2
|
-
/**
|
|
3
|
-
* Animation that rotates a Mobject by a specified angle.
|
|
4
|
-
* Uses linear interpolation between start and end rotation.
|
|
5
|
-
*
|
|
6
|
-
* This is a transformative animation - the target must already be in the scene.
|
|
7
|
-
* Start rotation is captured lazily when animation becomes active.
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* scene.add(square);
|
|
11
|
-
* scene.play(new Rotate(square, Math.PI / 4)); // Rotate 45 degrees
|
|
12
|
-
*/
|
|
13
|
-
export class Rotate extends TransformativeAnimation {
|
|
14
|
-
startRotation;
|
|
15
|
-
endRotation;
|
|
16
|
-
angle;
|
|
17
|
-
constructor(target, angle) {
|
|
18
|
-
super(target);
|
|
19
|
-
this.angle = angle;
|
|
20
|
-
}
|
|
21
|
-
captureStartState() {
|
|
22
|
-
this.startRotation = this.target.rotation;
|
|
23
|
-
this.endRotation = this.startRotation + this.angle;
|
|
24
|
-
}
|
|
25
|
-
interpolate(progress) {
|
|
26
|
-
this.ensureInitialized();
|
|
27
|
-
const newRotation = this.startRotation + (this.endRotation - this.startRotation) * progress;
|
|
28
|
-
this.target.setRotation(newRotation);
|
|
29
|
-
}
|
|
30
|
-
/** Returns the total rotation angle in radians. */
|
|
31
|
-
getAngle() {
|
|
32
|
-
return this.angle;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { TransformativeAnimation } from '../categories';
|
|
2
|
-
import { Mobject } from '../../../mobjects/Mobject';
|
|
3
|
-
/**
|
|
4
|
-
* Animation that scales a Mobject to a target scale factor.
|
|
5
|
-
* Uses linear interpolation between start and end scale.
|
|
6
|
-
*
|
|
7
|
-
* This is a transformative animation - the target must already be in the scene.
|
|
8
|
-
* Start scale is captured lazily when animation becomes active.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* scene.add(circle);
|
|
12
|
-
* scene.play(new Scale(circle, 2)); // Scale to 2x
|
|
13
|
-
*/
|
|
14
|
-
export declare class Scale<T extends Mobject = Mobject> extends TransformativeAnimation<T> {
|
|
15
|
-
private startScale;
|
|
16
|
-
private readonly endScale;
|
|
17
|
-
constructor(target: T, factor: number);
|
|
18
|
-
constructor(target: T, factorX: number, factorY: number);
|
|
19
|
-
protected captureStartState(): void;
|
|
20
|
-
interpolate(progress: number): void;
|
|
21
|
-
/** Returns the scale factor. */
|
|
22
|
-
getFactor(): number;
|
|
23
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { TransformativeAnimation } from '../categories';
|
|
2
|
-
import { Vector2 } from '../../math/Vector2/Vector2';
|
|
3
|
-
/**
|
|
4
|
-
* Animation that scales a Mobject to a target scale factor.
|
|
5
|
-
* Uses linear interpolation between start and end scale.
|
|
6
|
-
*
|
|
7
|
-
* This is a transformative animation - the target must already be in the scene.
|
|
8
|
-
* Start scale is captured lazily when animation becomes active.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* scene.add(circle);
|
|
12
|
-
* scene.play(new Scale(circle, 2)); // Scale to 2x
|
|
13
|
-
*/
|
|
14
|
-
export class Scale extends TransformativeAnimation {
|
|
15
|
-
startScale;
|
|
16
|
-
endScale;
|
|
17
|
-
constructor(target, factorX, factorY) {
|
|
18
|
-
super(target);
|
|
19
|
-
const endX = factorX;
|
|
20
|
-
const endY = factorY ?? factorX;
|
|
21
|
-
this.endScale = new Vector2(endX, endY);
|
|
22
|
-
}
|
|
23
|
-
captureStartState() {
|
|
24
|
-
this.startScale = this.target.scale;
|
|
25
|
-
}
|
|
26
|
-
interpolate(progress) {
|
|
27
|
-
this.ensureInitialized();
|
|
28
|
-
const newScale = this.startScale.lerp(this.endScale, progress);
|
|
29
|
-
this.target.setScale(newScale.x, newScale.y);
|
|
30
|
-
}
|
|
31
|
-
/** Returns the scale factor. */
|
|
32
|
-
getFactor() {
|
|
33
|
-
return this.endScale.x;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import type { EasingFunction } from './easing';
|
|
2
|
-
import type { Animation } from './Animation';
|
|
3
|
-
import type { Mobject } from '../../mobjects/Mobject';
|
|
4
|
-
/**
|
|
5
|
-
* Configuration options for animations.
|
|
6
|
-
*/
|
|
7
|
-
export interface AnimationConfig {
|
|
8
|
-
/** Duration of the animation in seconds. Default: 1 */
|
|
9
|
-
readonly durationSeconds: number;
|
|
10
|
-
/** Easing function to apply. Default: smooth */
|
|
11
|
-
readonly easing: EasingFunction;
|
|
12
|
-
/** Delay before animation starts in seconds. Default: 0 */
|
|
13
|
-
readonly delaySeconds: number;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Animation lifecycle category determines how Scene.play() handles the target.
|
|
17
|
-
* - 'introductory': Auto-registers target with scene (FadeIn, Create, Draw, Write)
|
|
18
|
-
* - 'transformative': Requires target to already be in scene (MoveTo, Rotate, Scale)
|
|
19
|
-
* - 'exit': Requires target in scene, may auto-remove after (FadeOut)
|
|
20
|
-
*/
|
|
21
|
-
export type AnimationLifecycle = 'introductory' | 'transformative' | 'exit';
|
|
22
|
-
/**
|
|
23
|
-
* Configuration for a queued animation in the fluent API.
|
|
24
|
-
*/
|
|
25
|
-
export interface FluentConfig {
|
|
26
|
-
durationSeconds: number;
|
|
27
|
-
easing?: EasingFunction;
|
|
28
|
-
delaySeconds?: number;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Factory function that creates an Animation for a given target.
|
|
32
|
-
*/
|
|
33
|
-
export type AnimationFactory = (target: Mobject) => Animation<Mobject>;
|
|
34
|
-
/**
|
|
35
|
-
* A queued animation descriptor storing the factory and configuration.
|
|
36
|
-
*/
|
|
37
|
-
export interface QueuedAnimation {
|
|
38
|
-
factory: AnimationFactory;
|
|
39
|
-
config: FluentConfig;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* A pre-built animation that's already configured (e.g., from parallel()).
|
|
43
|
-
*/
|
|
44
|
-
export interface QueuedPrebuilt {
|
|
45
|
-
animation: Animation<Mobject>;
|
|
46
|
-
}
|
|
47
|
-
/** Union type for queue entries */
|
|
48
|
-
export type QueueEntry = QueuedAnimation | QueuedPrebuilt;
|
|
49
|
-
/** Type guard to check if entry is a pre-built animation */
|
|
50
|
-
export declare function isPrebuilt(entry: QueueEntry): entry is QueuedPrebuilt;
|
|
51
|
-
/** Default animation duration in seconds. */
|
|
52
|
-
export declare const DEFAULT_DURATION = 1;
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { Vector2 } from '../math/Vector2/Vector2';
|
|
2
|
-
import { Matrix3x3 } from '../math/matrix/Matrix3x3';
|
|
3
|
-
import { CameraFrame } from './CameraFrame';
|
|
4
|
-
import { type CameraConfig } from './types';
|
|
5
|
-
/**
|
|
6
|
-
* Camera manages the view into the scene.
|
|
7
|
-
* Uses CameraFrame (a Mobject) to store transform state, enabling camera animations.
|
|
8
|
-
*
|
|
9
|
-
* The Camera provides both instant manipulation methods (panTo, zoomTo) and
|
|
10
|
-
* access to the CameraFrame for fluent animation APIs.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* // Instant camera manipulation
|
|
14
|
-
* camera.zoomTo(2);
|
|
15
|
-
* camera.panTo(new Vector2(5, 3));
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
* // Animated camera movement via frame
|
|
19
|
-
* this.play(this.frame.zoomIn(2).duration(1));
|
|
20
|
-
* this.play(this.frame.centerOn(circle).duration(0.5));
|
|
21
|
-
*/
|
|
22
|
-
export declare class Camera {
|
|
23
|
-
private readonly config;
|
|
24
|
-
/** The CameraFrame that stores the camera's transform state. Use this for animations. */
|
|
25
|
-
readonly frame: CameraFrame;
|
|
26
|
-
/**
|
|
27
|
-
* Creates a new Camera with the specified viewport dimensions.
|
|
28
|
-
*
|
|
29
|
-
* @param config - Configuration options
|
|
30
|
-
* @param config.pixelWidth - Width of the viewport in pixels (default: 1920)
|
|
31
|
-
* @param config.pixelHeight - Height of the viewport in pixels (default: 1080)
|
|
32
|
-
*/
|
|
33
|
-
constructor(config?: CameraConfig);
|
|
34
|
-
get frameHeight(): number;
|
|
35
|
-
get frameWidth(): number;
|
|
36
|
-
get frameYRadius(): number;
|
|
37
|
-
get frameXRadius(): number;
|
|
38
|
-
get pixelWidth(): number;
|
|
39
|
-
get pixelHeight(): number;
|
|
40
|
-
get position(): Vector2;
|
|
41
|
-
get zoom(): number;
|
|
42
|
-
get rotation(): number;
|
|
43
|
-
pan(delta: Vector2): this;
|
|
44
|
-
panTo(position: Vector2): this;
|
|
45
|
-
zoomTo(level: number): this;
|
|
46
|
-
rotateTo(angle: number): this;
|
|
47
|
-
getViewMatrix(): Matrix3x3;
|
|
48
|
-
/**
|
|
49
|
-
* Transforms a world-space position to screen-space (pixel) coordinates.
|
|
50
|
-
*
|
|
51
|
-
* Screen coordinates have origin at top-left, with x increasing right
|
|
52
|
-
* and y increasing downward.
|
|
53
|
-
*
|
|
54
|
-
* @param pos - Position in world coordinates
|
|
55
|
-
* @returns Position in screen coordinates (pixels)
|
|
56
|
-
*
|
|
57
|
-
* @example
|
|
58
|
-
* const screenPos = camera.worldToScreen(circle.position);
|
|
59
|
-
* console.log(`Circle is at pixel (${screenPos.x}, ${screenPos.y})`);
|
|
60
|
-
*/
|
|
61
|
-
worldToScreen(pos: Vector2): Vector2;
|
|
62
|
-
/**
|
|
63
|
-
* Transforms a screen-space (pixel) position to world coordinates.
|
|
64
|
-
* This is the inverse of worldToScreen.
|
|
65
|
-
*
|
|
66
|
-
* @param pos - Position in screen coordinates (pixels, origin at top-left)
|
|
67
|
-
* @returns Position in world coordinates
|
|
68
|
-
*
|
|
69
|
-
* @example
|
|
70
|
-
* // Convert a mouse click position to world coordinates
|
|
71
|
-
* const worldPos = camera.screenToWorld(new Vector2(mouseX, mouseY));
|
|
72
|
-
*/
|
|
73
|
-
screenToWorld(pos: Vector2): Vector2;
|
|
74
|
-
/**
|
|
75
|
-
* Checks if a world-space position is currently visible within the camera frame.
|
|
76
|
-
*
|
|
77
|
-
* @param pos - Position in world coordinates to check
|
|
78
|
-
* @returns True if the position is within the visible frame bounds
|
|
79
|
-
*
|
|
80
|
-
* @example
|
|
81
|
-
* if (camera.isInView(object.position)) {
|
|
82
|
-
* console.log('Object is visible');
|
|
83
|
-
* }
|
|
84
|
-
*/
|
|
85
|
-
isInView(pos: Vector2): boolean;
|
|
86
|
-
reset(): this;
|
|
87
|
-
}
|
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
import { Vector2 } from '../math/Vector2/Vector2';
|
|
2
|
-
import { Matrix3x3 } from '../math/matrix/Matrix3x3';
|
|
3
|
-
import { CameraFrame } from './CameraFrame';
|
|
4
|
-
import { MANIM_FRAME_HEIGHT } from './types';
|
|
5
|
-
/**
|
|
6
|
-
* Camera manages the view into the scene.
|
|
7
|
-
* Uses CameraFrame (a Mobject) to store transform state, enabling camera animations.
|
|
8
|
-
*
|
|
9
|
-
* The Camera provides both instant manipulation methods (panTo, zoomTo) and
|
|
10
|
-
* access to the CameraFrame for fluent animation APIs.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* // Instant camera manipulation
|
|
14
|
-
* camera.zoomTo(2);
|
|
15
|
-
* camera.panTo(new Vector2(5, 3));
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
* // Animated camera movement via frame
|
|
19
|
-
* this.play(this.frame.zoomIn(2).duration(1));
|
|
20
|
-
* this.play(this.frame.centerOn(circle).duration(0.5));
|
|
21
|
-
*/
|
|
22
|
-
export class Camera {
|
|
23
|
-
config;
|
|
24
|
-
/** The CameraFrame that stores the camera's transform state. Use this for animations. */
|
|
25
|
-
frame;
|
|
26
|
-
/**
|
|
27
|
-
* Creates a new Camera with the specified viewport dimensions.
|
|
28
|
-
*
|
|
29
|
-
* @param config - Configuration options
|
|
30
|
-
* @param config.pixelWidth - Width of the viewport in pixels (default: 1920)
|
|
31
|
-
* @param config.pixelHeight - Height of the viewport in pixels (default: 1080)
|
|
32
|
-
*/
|
|
33
|
-
constructor(config = {}) {
|
|
34
|
-
this.config = {
|
|
35
|
-
pixelWidth: config.pixelWidth ?? 1920,
|
|
36
|
-
pixelHeight: config.pixelHeight ?? 1080,
|
|
37
|
-
};
|
|
38
|
-
this.frame = new CameraFrame({
|
|
39
|
-
pixelWidth: this.config.pixelWidth,
|
|
40
|
-
pixelHeight: this.config.pixelHeight,
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
// ========== Frame Dimensions (Manim-compatible) ==========
|
|
44
|
-
get frameHeight() {
|
|
45
|
-
return MANIM_FRAME_HEIGHT;
|
|
46
|
-
}
|
|
47
|
-
get frameWidth() {
|
|
48
|
-
const aspectRatio = this.config.pixelWidth / this.config.pixelHeight;
|
|
49
|
-
return MANIM_FRAME_HEIGHT * aspectRatio;
|
|
50
|
-
}
|
|
51
|
-
get frameYRadius() {
|
|
52
|
-
return this.frameHeight / 2;
|
|
53
|
-
}
|
|
54
|
-
get frameXRadius() {
|
|
55
|
-
return this.frameWidth / 2;
|
|
56
|
-
}
|
|
57
|
-
// ========== Pixel Dimensions ==========
|
|
58
|
-
get pixelWidth() {
|
|
59
|
-
return this.config.pixelWidth;
|
|
60
|
-
}
|
|
61
|
-
get pixelHeight() {
|
|
62
|
-
return this.config.pixelHeight;
|
|
63
|
-
}
|
|
64
|
-
// ========== Camera Transform Properties (read from frame) ==========
|
|
65
|
-
get position() {
|
|
66
|
-
return this.frame.position;
|
|
67
|
-
}
|
|
68
|
-
get zoom() {
|
|
69
|
-
return 1 / this.frame.scale.x;
|
|
70
|
-
}
|
|
71
|
-
get rotation() {
|
|
72
|
-
return this.frame.rotation;
|
|
73
|
-
}
|
|
74
|
-
// ========== Pan Operations (proxy to frame) ==========
|
|
75
|
-
pan(delta) {
|
|
76
|
-
const current = this.frame.position;
|
|
77
|
-
this.frame.pos(current.x + delta.x, current.y + delta.y);
|
|
78
|
-
return this;
|
|
79
|
-
}
|
|
80
|
-
panTo(position) {
|
|
81
|
-
this.frame.pos(position.x, position.y);
|
|
82
|
-
return this;
|
|
83
|
-
}
|
|
84
|
-
// ========== Zoom Operations (proxy to frame) ==========
|
|
85
|
-
zoomTo(level) {
|
|
86
|
-
if (level <= 0) {
|
|
87
|
-
throw new Error('Zoom level must be positive');
|
|
88
|
-
}
|
|
89
|
-
const frameScale = 1 / level;
|
|
90
|
-
this.frame.setScale(frameScale, frameScale);
|
|
91
|
-
return this;
|
|
92
|
-
}
|
|
93
|
-
// ========== Rotation Operations (proxy to frame) ==========
|
|
94
|
-
rotateTo(angle) {
|
|
95
|
-
this.frame.setRotation(angle);
|
|
96
|
-
return this;
|
|
97
|
-
}
|
|
98
|
-
// ========== View Matrix ==========
|
|
99
|
-
getViewMatrix() {
|
|
100
|
-
const framePos = this.frame.position;
|
|
101
|
-
const frameScale = this.frame.scale;
|
|
102
|
-
const frameRotation = this.frame.rotation;
|
|
103
|
-
const zoomX = 1 / frameScale.x;
|
|
104
|
-
const zoomY = 1 / frameScale.y;
|
|
105
|
-
const translate = Matrix3x3.translation(-framePos.x, -framePos.y);
|
|
106
|
-
const rotate = Matrix3x3.rotation(-frameRotation);
|
|
107
|
-
const scale = Matrix3x3.scale(zoomX, zoomY);
|
|
108
|
-
return scale.multiply(rotate).multiply(translate);
|
|
109
|
-
}
|
|
110
|
-
// ========== Coordinate Transforms ==========
|
|
111
|
-
/**
|
|
112
|
-
* Transforms a world-space position to screen-space (pixel) coordinates.
|
|
113
|
-
*
|
|
114
|
-
* Screen coordinates have origin at top-left, with x increasing right
|
|
115
|
-
* and y increasing downward.
|
|
116
|
-
*
|
|
117
|
-
* @param pos - Position in world coordinates
|
|
118
|
-
* @returns Position in screen coordinates (pixels)
|
|
119
|
-
*
|
|
120
|
-
* @example
|
|
121
|
-
* const screenPos = camera.worldToScreen(circle.position);
|
|
122
|
-
* console.log(`Circle is at pixel (${screenPos.x}, ${screenPos.y})`);
|
|
123
|
-
*/
|
|
124
|
-
worldToScreen(pos) {
|
|
125
|
-
const viewMatrix = this.getViewMatrix();
|
|
126
|
-
const transformed = viewMatrix.transformPoint(pos);
|
|
127
|
-
const screenX = (transformed.x + 1) * 0.5 * this.config.pixelWidth;
|
|
128
|
-
const screenY = (1 - transformed.y) * 0.5 * this.config.pixelHeight;
|
|
129
|
-
return new Vector2(screenX, screenY);
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* Transforms a screen-space (pixel) position to world coordinates.
|
|
133
|
-
* This is the inverse of worldToScreen.
|
|
134
|
-
*
|
|
135
|
-
* @param pos - Position in screen coordinates (pixels, origin at top-left)
|
|
136
|
-
* @returns Position in world coordinates
|
|
137
|
-
*
|
|
138
|
-
* @example
|
|
139
|
-
* // Convert a mouse click position to world coordinates
|
|
140
|
-
* const worldPos = camera.screenToWorld(new Vector2(mouseX, mouseY));
|
|
141
|
-
*/
|
|
142
|
-
screenToWorld(pos) {
|
|
143
|
-
const ndcX = (pos.x / this.config.pixelWidth) * 2 - 1;
|
|
144
|
-
const ndcY = 1 - (pos.y / this.config.pixelHeight) * 2;
|
|
145
|
-
const viewMatrix = this.getViewMatrix();
|
|
146
|
-
const inverseView = viewMatrix.inverse();
|
|
147
|
-
return inverseView.transformPoint(new Vector2(ndcX, ndcY));
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Checks if a world-space position is currently visible within the camera frame.
|
|
151
|
-
*
|
|
152
|
-
* @param pos - Position in world coordinates to check
|
|
153
|
-
* @returns True if the position is within the visible frame bounds
|
|
154
|
-
*
|
|
155
|
-
* @example
|
|
156
|
-
* if (camera.isInView(object.position)) {
|
|
157
|
-
* console.log('Object is visible');
|
|
158
|
-
* }
|
|
159
|
-
*/
|
|
160
|
-
isInView(pos) {
|
|
161
|
-
const framePos = this.frame.position;
|
|
162
|
-
const halfWidth = this.frame.width / 2;
|
|
163
|
-
const halfHeight = this.frame.height / 2;
|
|
164
|
-
return (pos.x >= framePos.x - halfWidth &&
|
|
165
|
-
pos.x <= framePos.x + halfWidth &&
|
|
166
|
-
pos.y >= framePos.y - halfHeight &&
|
|
167
|
-
pos.y <= framePos.y + halfHeight);
|
|
168
|
-
}
|
|
169
|
-
reset() {
|
|
170
|
-
this.frame.pos(0, 0);
|
|
171
|
-
this.frame.setScale(1, 1);
|
|
172
|
-
this.frame.setRotation(0);
|
|
173
|
-
return this;
|
|
174
|
-
}
|
|
175
|
-
}
|