0
# Animation System
1
2
Comprehensive animation framework including creation, transformation, indication, and composition animations with precise timing control and mathematical interpolation. The animation system provides the temporal behavior that brings mathematical objects to life through smooth, mathematically-precise transformations.
3
4
## Capabilities
5
6
### Base Animation
7
8
The fundamental animation class that provides the core timing, interpolation, and rendering coordination for all animation types.
9
10
```python { .api }
11
class Animation:
12
"""
13
Base class for all animations providing timing control and interpolation framework.
14
15
Defines how mobjects change over time with precise mathematical interpolation
16
and customizable rate functions for natural motion.
17
"""
18
19
def __init__(
20
mobject: Mobject = None,
21
run_time: float = 1.0,
22
rate_func: Callable[[float], float] = smooth,
23
lag_ratio: float = 0.0,
24
reverse_rate_function: bool = False,
25
name: str = None,
26
remover: bool = False,
27
suspend_mobject_updating: bool = True,
28
**kwargs
29
) -> None:
30
"""
31
Initialize animation with timing and behavior parameters.
32
33
Parameters:
34
- mobject: The mobject to animate
35
- run_time: Animation duration in seconds
36
- rate_func: Function mapping time progress [0,1] to animation progress [0,1]
37
- lag_ratio: Delay factor for submobject animations (0=simultaneous, 1=sequential)
38
- reverse_rate_function: Whether to reverse the rate function
39
- name: Animation name for debugging and display
40
- remover: Whether to remove mobject from scene after animation
41
- suspend_mobject_updating: Whether to pause mobject updaters during animation
42
"""
43
44
def interpolate(alpha: float) -> None:
45
"""
46
Define the animation at progress alpha ∈ [0,1].
47
48
Parameters:
49
- alpha: Animation progress from 0 (start) to 1 (end)
50
"""
51
52
def update_mobjects(dt: float) -> None:
53
"""Update mobjects for current animation frame."""
54
55
def copy() -> Animation:
56
"""Create a copy of this animation."""
57
58
class Wait(Animation):
59
"""
60
Animation that waits for a specified duration without changing mobjects.
61
62
Used for creating pauses in animation sequences and timing control.
63
"""
64
65
def __init__(
66
duration: float = 1.0,
67
stop_condition: Callable[[], bool] = None,
68
frozen_frame: bool = True,
69
**kwargs
70
) -> None:
71
"""
72
Parameters:
73
- duration: Wait time in seconds
74
- stop_condition: Function to end wait early when it returns True
75
- frozen_frame: Whether to freeze the current frame or continue updating
76
"""
77
```
78
79
### Creation Animations
80
81
Animations that reveal mobjects through various creation effects, simulating drawing, writing, or materialization processes.
82
83
```python { .api }
84
def Create(
85
mobject: VMobject,
86
lag_ratio: float = 0.0,
87
introduce_loop_index: bool = False,
88
**kwargs
89
) -> Animation:
90
"""
91
Incrementally reveal a VMobject by tracing its path from start to end.
92
93
Simulates drawing the mobject's outline progressively, following the
94
natural path structure of the object.
95
96
Parameters:
97
- mobject: VMobject to be created/drawn
98
- lag_ratio: Delay between submobject creation starts
99
- introduce_loop_index: Whether to handle closed path loops specially
100
"""
101
102
def Uncreate(
103
mobject: VMobject,
104
rate_func: Callable = lambda t: smooth(1-t),
105
remover: bool = True,
106
**kwargs
107
) -> Animation:
108
"""
109
Reverse of Create - incrementally hide a VMobject by reversing its path.
110
111
Parameters:
112
- mobject: VMobject to be uncreated
113
- rate_func: Rate function (defaults to reverse of smooth)
114
- remover: Whether to remove mobject after animation
115
"""
116
117
def Write(
118
mobject: VMobject,
119
rate_func: Callable = linear,
120
reverse: bool = False,
121
**kwargs
122
) -> Animation:
123
"""
124
Simulate hand-writing text or hand-drawing a VMobject with natural timing.
125
126
Combines path tracing with stroke drawing to create realistic writing motion,
127
particularly effective for text and mathematical expressions.
128
129
Parameters:
130
- mobject: Text or VMobject to write
131
- rate_func: Rate function controlling writing speed
132
- reverse: Whether to write in reverse order
133
"""
134
135
def Unwrite(
136
mobject: VMobject,
137
rate_func: Callable = lambda t: smooth(1-t),
138
reverse: bool = True,
139
remover: bool = True,
140
**kwargs
141
) -> Animation:
142
"""
143
Reverse of Write - simulate erasing text or drawings.
144
145
Parameters:
146
- mobject: Text or VMobject to unwrite
147
- rate_func: Rate function for erasing motion
148
- reverse: Direction of unwriting
149
- remover: Whether to remove after completion
150
"""
151
152
def DrawBorderThenFill(
153
vmobject: VMobject,
154
run_time: float = 2,
155
rate_func: Callable = double_smooth,
156
stroke_width: float = 2,
157
stroke_color: str = None,
158
draw_border_animation_config: dict = None,
159
fill_animation_config: dict = None,
160
**kwargs
161
) -> Animation:
162
"""
163
First draw the border/outline, then fill the interior of a shape.
164
165
Creates a two-phase animation: first traces the outline, then fills
166
the interior, simulating natural drawing workflow.
167
168
Parameters:
169
- vmobject: VMobject to draw and fill
170
- run_time: Total animation duration
171
- rate_func: Overall timing function
172
- stroke_width: Border line thickness during drawing
173
- stroke_color: Border color during drawing
174
- draw_border_animation_config: Config for border drawing phase
175
- fill_animation_config: Config for filling phase
176
"""
177
178
def ShowIncreasingSubsets(
179
group: Group,
180
suspend_mobject_updating: bool = False,
181
**kwargs
182
) -> Animation:
183
"""
184
Progressively reveal submobjects one by one in sequence.
185
186
Shows first submobject, then first two, then first three, etc.
187
until all submobjects are visible.
188
189
Parameters:
190
- group: Group containing submobjects to reveal
191
- suspend_mobject_updating: Whether to pause updates during animation
192
"""
193
194
def ShowSubmobjectsOneByOne(
195
group: Group,
196
**kwargs
197
) -> Animation:
198
"""
199
Show submobjects one at a time with each fully appearing before the next.
200
201
Each submobject gets its full creation animation before the next begins,
202
creating a sequential presentation effect.
203
204
Parameters:
205
- group: Group containing submobjects to show sequentially
206
"""
207
208
# Text-specific creation animations
209
def AddTextLetterByLetter(
210
text: Text,
211
time_per_char: float = 0.06,
212
**kwargs
213
) -> Animation:
214
"""
215
Reveal text one letter at a time from left to right.
216
217
Parameters:
218
- text: Text object to reveal progressively
219
- time_per_char: Time to spend revealing each character
220
"""
221
222
def AddTextWordByWord(
223
text: Text,
224
time_per_word: float = 0.2,
225
**kwargs
226
) -> Animation:
227
"""
228
Reveal text one word at a time.
229
230
Parameters:
231
- text: Text object to reveal progressively
232
- time_per_word: Time to spend revealing each word
233
"""
234
235
def RemoveTextLetterByLetter(
236
text: Text,
237
time_per_char: float = 0.06,
238
remover: bool = True,
239
**kwargs
240
) -> Animation:
241
"""
242
Remove text one letter at a time from right to left.
243
244
Parameters:
245
- text: Text object to remove progressively
246
- time_per_char: Time to spend removing each character
247
- remover: Whether to remove text after animation
248
"""
249
```
250
251
### Transform Animations
252
253
Animations that morph one mobject into another or apply transformations like scaling, rotation, and position changes.
254
255
```python { .api }
256
def Transform(
257
mobject: Mobject,
258
target_mobject: Mobject,
259
path_func: Callable = None,
260
path_arc: float = 0,
261
path_arc_axis: np.ndarray = OUT,
262
replace_mobject_with_target_in_scene: bool = False,
263
**kwargs
264
) -> Animation:
265
"""
266
Transform one mobject into another by morphing their point structures.
267
268
The original mobject is modified to match the target mobject's shape,
269
position, and properties through smooth interpolation.
270
271
Parameters:
272
- mobject: Mobject to transform (will be modified)
273
- target_mobject: Target shape and properties
274
- path_func: Function defining transformation path for each point
275
- path_arc: Arc angle for circular transformation paths
276
- path_arc_axis: Axis for circular path rotation
277
- replace_mobject_with_target_in_scene: Whether to replace mobject with target
278
"""
279
280
def ReplacementTransform(
281
mobject: Mobject,
282
target_mobject: Mobject,
283
**kwargs
284
) -> Animation:
285
"""
286
Transform mobject into target, replacing the original with the target.
287
288
Unlike Transform, this removes the original mobject and adds the target
289
mobject to the scene after transformation.
290
291
Parameters:
292
- mobject: Mobject to be replaced
293
- target_mobject: Mobject to replace it with
294
"""
295
296
def TransformFromCopy(
297
mobject: Mobject,
298
target_mobject: Mobject,
299
**kwargs
300
) -> Animation:
301
"""
302
Transform a copy of mobject into target, leaving original unchanged.
303
304
Creates transformation animation without modifying the source mobject,
305
useful when the original needs to remain in its current state.
306
307
Parameters:
308
- mobject: Source mobject (unchanged)
309
- target_mobject: Target to transform copy into
310
"""
311
312
def ClockwiseTransform(
313
mobject: Mobject,
314
target_mobject: Mobject,
315
path_arc: float = -np.pi,
316
**kwargs
317
) -> Animation:
318
"""
319
Transform with clockwise rotation path.
320
321
Parameters:
322
- mobject: Mobject to transform
323
- target_mobject: Transformation target
324
- path_arc: Arc angle (negative for clockwise)
325
"""
326
327
def CounterclockwiseTransform(
328
mobject: Mobject,
329
target_mobject: Mobject,
330
path_arc: float = np.pi,
331
**kwargs
332
) -> Animation:
333
"""
334
Transform with counter-clockwise rotation path.
335
336
Parameters:
337
- mobject: Mobject to transform
338
- target_mobject: Transformation target
339
- path_arc: Arc angle (positive for counter-clockwise)
340
"""
341
342
def FadeTransform(
343
mobject: Mobject,
344
target_mobject: Mobject,
345
stretch: bool = True,
346
dim_to_match: int = 1,
347
**kwargs
348
) -> Animation:
349
"""
350
Transform with fade transition between mobjects.
351
352
Combines transformation with opacity changes for smooth transitions
353
when point structures don't align well for direct morphing.
354
355
Parameters:
356
- mobject: Source mobject
357
- target_mobject: Target mobject
358
- stretch: Whether to stretch mobjects for better alignment
359
- dim_to_match: Dimension to match when stretching (0=width, 1=height)
360
"""
361
362
def FadeTransformPieces(
363
mobject: Mobject,
364
target_mobject: Mobject,
365
**kwargs
366
) -> Animation:
367
"""
368
Transform by fading between individual pieces/submobjects.
369
370
Parameters:
371
- mobject: Source mobject with submobjects
372
- target_mobject: Target mobject with submobjects
373
"""
374
375
# Direct mobject method transformations
376
def MoveToTarget(mobject: Mobject, **kwargs) -> Animation:
377
"""
378
Move mobject to its .target attribute position/state.
379
380
Requires mobject to have a .target attribute set beforehand.
381
382
Parameters:
383
- mobject: Mobject with .target attribute
384
"""
385
386
def ApplyMethod(
387
method: Callable,
388
*args,
389
**kwargs
390
) -> Animation:
391
"""
392
Animate the result of calling a method on a mobject.
393
394
Parameters:
395
- method: Bound method to call on mobject
396
- *args: Arguments to pass to method
397
"""
398
399
def ApplyFunction(
400
func: Callable,
401
mobject: Mobject,
402
**kwargs
403
) -> Animation:
404
"""
405
Apply function to mobject's points/properties.
406
407
Parameters:
408
- func: Function to apply to mobject
409
- mobject: Mobject to transform
410
"""
411
412
def ApplyMatrix(
413
matrix: np.ndarray,
414
mobject: Mobject,
415
**kwargs
416
) -> Animation:
417
"""
418
Apply matrix transformation to mobject.
419
420
Parameters:
421
- matrix: Transformation matrix
422
- mobject: Mobject to transform
423
"""
424
425
def ApplyComplexFunction(
426
complex_func: Callable,
427
mobject: Mobject,
428
**kwargs
429
) -> Animation:
430
"""
431
Apply complex function to mobject coordinates.
432
433
Treats mobject points as complex numbers and applies the function.
434
435
Parameters:
436
- complex_func: Function taking complex input
437
- mobject: Mobject to transform
438
"""
439
440
# Specialized transforms
441
def ScaleInPlace(
442
mobject: Mobject,
443
scale_factor: float,
444
**kwargs
445
) -> Animation:
446
"""
447
Scale mobject around its center point.
448
449
Parameters:
450
- mobject: Mobject to scale
451
- scale_factor: Scaling factor
452
"""
453
454
def ShrinkToCenter(
455
mobject: Mobject,
456
**kwargs
457
) -> Animation:
458
"""
459
Shrink mobject to its center point.
460
461
Parameters:
462
- mobject: Mobject to shrink
463
"""
464
465
def Restore(mobject: Mobject, **kwargs) -> Animation:
466
"""
467
Restore mobject to its saved state.
468
469
Requires mobject.save_state() to have been called previously.
470
471
Parameters:
472
- mobject: Mobject with saved state
473
"""
474
475
def Swap(*mobjects: Mobject, **kwargs) -> Animation:
476
"""
477
Swap positions of two mobjects.
478
479
Parameters:
480
- *mobjects: Two mobjects to swap positions
481
"""
482
483
def CyclicReplace(*mobjects: Mobject, **kwargs) -> Animation:
484
"""
485
Cyclically replace mobjects (A→B, B→C, C→A, etc).
486
487
Parameters:
488
- *mobjects: Mobjects to cycle through positions
489
"""
490
```
491
492
### Fading Animations
493
494
Animations that control opacity and visibility of mobjects with smooth fade transitions and directional movement.
495
496
```python { .api }
497
def FadeIn(
498
*mobjects: Mobject,
499
shift: np.ndarray = None,
500
target_position: np.ndarray = None,
501
scale: float = 1,
502
**kwargs
503
) -> Animation:
504
"""
505
Fade mobjects into visibility with optional movement and scaling.
506
507
Parameters:
508
- *mobjects: Mobjects to fade in
509
- shift: Vector displacement during fade-in
510
- target_position: End position for fade-in movement
511
- scale: Scale factor during fade-in
512
"""
513
514
def FadeOut(
515
*mobjects: Mobject,
516
shift: np.ndarray = None,
517
target_position: np.ndarray = None,
518
scale: float = 1,
519
**kwargs
520
) -> Animation:
521
"""
522
Fade mobjects out of visibility with optional movement and scaling.
523
524
Parameters:
525
- *mobjects: Mobjects to fade out
526
- shift: Vector displacement during fade-out
527
- target_position: Target position for fade-out movement
528
- scale: Scale factor during fade-out
529
"""
530
531
def FadeToColor(
532
mobject: Mobject,
533
color: str,
534
**kwargs
535
) -> Animation:
536
"""
537
Animate color change of mobject with smooth transition.
538
539
Parameters:
540
- mobject: Mobject to recolor
541
- color: Target color
542
"""
543
```
544
545
### Growing Animations
546
547
Animations that create mobjects by growing them from specific points or edges with natural scaling effects.
548
549
```python { .api }
550
def GrowFromPoint(
551
mobject: Mobject,
552
point: np.ndarray,
553
**kwargs
554
) -> Animation:
555
"""
556
Grow mobject from a specific point outward.
557
558
Parameters:
559
- mobject: Mobject to grow
560
- point: Point to grow from
561
"""
562
563
def GrowFromCenter(
564
mobject: Mobject,
565
**kwargs
566
) -> Animation:
567
"""
568
Grow mobject from its center outward.
569
570
Parameters:
571
- mobject: Mobject to grow from center
572
"""
573
574
def GrowFromEdge(
575
mobject: Mobject,
576
edge: np.ndarray,
577
**kwargs
578
) -> Animation:
579
"""
580
Grow mobject from one of its edges.
581
582
Parameters:
583
- mobject: Mobject to grow
584
- edge: Edge direction (UP, DOWN, LEFT, RIGHT, etc.)
585
"""
586
587
def GrowArrow(
588
arrow: Arrow,
589
**kwargs
590
) -> Animation:
591
"""
592
Grow arrow from start point to end point.
593
594
Specialized growth animation for arrows that grows along the arrow's direction.
595
596
Parameters:
597
- arrow: Arrow object to grow
598
"""
599
600
def SpinInFromNothing(
601
mobject: Mobject,
602
angle: float = TAU,
603
**kwargs
604
) -> Animation:
605
"""
606
Spin mobject into existence from invisible state.
607
608
Parameters:
609
- mobject: Mobject to spin in
610
- angle: Total rotation angle during appearance
611
"""
612
```
613
614
### Indication Animations
615
616
Animations that draw attention to mobjects through visual emphasis effects like highlighting, flashing, and wiggling.
617
618
```python { .api }
619
def Indicate(
620
mobject: Mobject,
621
scale_factor: float = 1.2,
622
color: str = YELLOW,
623
**kwargs
624
) -> Animation:
625
"""
626
Briefly emphasize mobject by scaling and recoloring.
627
628
Temporarily enlarges and changes color of mobject to draw attention,
629
then returns to original state.
630
631
Parameters:
632
- mobject: Mobject to indicate
633
- scale_factor: Temporary scale multiplier
634
- color: Temporary highlight color
635
"""
636
637
def Flash(
638
point: np.ndarray | Mobject,
639
line_length: float = 0.2,
640
num_lines: int = 12,
641
color: str = YELLOW,
642
flash_radius: float = 0.3,
643
time_width: float = 0.1,
644
**kwargs
645
) -> Animation:
646
"""
647
Create radial flash effect at a point.
648
649
Displays radiating lines that expand outward from a central point,
650
creating an attention-grabbing flash effect.
651
652
Parameters:
653
- point: Center point or mobject center for flash
654
- line_length: Length of flash lines
655
- num_lines: Number of radiating lines
656
- color: Color of flash lines
657
- flash_radius: Radius of flash effect
658
- time_width: Duration of flash peak intensity
659
"""
660
661
def FocusOn(
662
focus_point: np.ndarray | Mobject,
663
opacity: float = 0.2,
664
color: str = GREY,
665
**kwargs
666
) -> Animation:
667
"""
668
Dim everything except focus area to draw attention.
669
670
Creates spotlight effect by dimming the background while highlighting
671
a specific area or mobject.
672
673
Parameters:
674
- focus_point: Point or mobject to focus on
675
- opacity: Background dimming level
676
- color: Background overlay color
677
"""
678
679
def Circumscribe(
680
mobject: Mobject,
681
shape: VMobject = None,
682
fade_in: bool = True,
683
fade_out: bool = True,
684
time_width: float = 0.3,
685
buff: float = 0.1,
686
color: str = YELLOW,
687
**kwargs
688
) -> Animation:
689
"""
690
Draw shape around mobject to highlight it.
691
692
Creates a temporary outline shape (circle, rectangle, etc.) around
693
the mobject to emphasize its boundaries.
694
695
Parameters:
696
- mobject: Mobject to circumscribe
697
- shape: Shape to draw around mobject (auto-detected if None)
698
- fade_in: Whether shape fades in
699
- fade_out: Whether shape fades out
700
- time_width: Duration of full visibility
701
- buff: Buffer space around mobject
702
- color: Circumscription color
703
"""
704
705
def ShowPassingFlash(
706
vmobject: VMobject,
707
time_width: float = 0.1,
708
**kwargs
709
) -> Animation:
710
"""
711
Create passing flash effect along mobject's path.
712
713
A bright highlight travels along the mobject's path from start to end,
714
useful for showing direction or flow.
715
716
Parameters:
717
- vmobject: Path to flash along
718
- time_width: Width of the traveling flash
719
"""
720
721
def ShowPassingFlashWithThinningStrokeWidth(
722
vmobject: VMobject,
723
n_segments: int = 10,
724
time_width: float = 0.1,
725
**kwargs
726
) -> Animation:
727
"""
728
Passing flash with gradually thinning stroke width.
729
730
Similar to ShowPassingFlash but with stroke that thins as it travels,
731
creating a more dynamic visual effect.
732
733
Parameters:
734
- vmobject: Path for flash
735
- n_segments: Number of flash segments
736
- time_width: Width of flash effect
737
"""
738
739
def ApplyWave(
740
mobject: Mobject,
741
direction: np.ndarray = UP,
742
amplitude: float = 0.2,
743
wave_func: Callable = np.sin,
744
**kwargs
745
) -> Animation:
746
"""
747
Apply wave distortion effect to mobject.
748
749
Creates ripple or wave effect that travels across the mobject,
750
temporarily distorting its shape.
751
752
Parameters:
753
- mobject: Mobject to apply wave to
754
- direction: Direction of wave propagation
755
- amplitude: Wave amplitude
756
- wave_func: Function defining wave shape
757
"""
758
759
def Wiggle(
760
mobject: Mobject,
761
scale_value: float = 1.1,
762
rotation_angle: float = 0.01*TAU,
763
n_wiggles: int = 6,
764
**kwargs
765
) -> Animation:
766
"""
767
Make mobject wiggle back and forth.
768
769
Creates attention-grabbing wiggle motion by rapidly alternating
770
small rotations and scale changes.
771
772
Parameters:
773
- mobject: Mobject to wiggle
774
- scale_value: Maximum scale factor during wiggle
775
- rotation_angle: Maximum rotation angle during wiggle
776
- n_wiggles: Number of wiggle cycles
777
"""
778
779
def Blink(
780
mobject: Mobject,
781
**kwargs
782
) -> Animation:
783
"""
784
Make mobject blink by rapidly toggling opacity.
785
786
Creates attention-getting effect by making object flash on and off.
787
788
Parameters:
789
- mobject: Mobject to make blink
790
"""
791
```
792
793
### Movement Animations
794
795
Animations that move mobjects along paths, apply transformations, or create complex motion patterns.
796
797
```python { .api }
798
def MoveAlongPath(
799
mobject: Mobject,
800
path: VMobject,
801
suspend_mobject_updating: bool = False,
802
**kwargs
803
) -> Animation:
804
"""
805
Move mobject along a specified path curve.
806
807
Animates smooth movement following the exact shape of a path,
808
maintaining constant speed or using custom rate functions.
809
810
Parameters:
811
- mobject: Mobject to move along path
812
- path: VMobject defining the movement path
813
- suspend_mobject_updating: Whether to pause mobject updaters during movement
814
"""
815
816
def Homotopy(
817
homotopy_function: Callable,
818
mobject: Mobject,
819
run_time: float = 3.0,
820
apply_function_kwargs: dict = None,
821
**kwargs
822
) -> Animation:
823
"""
824
Apply homotopy transformation function to mobject over time.
825
826
A homotopy smoothly deforms space using a function that varies
827
continuously from identity to target transformation.
828
829
Parameters:
830
- homotopy_function: Function (x, y, z, t) -> (x', y', z') where t ∈ [0,1]
831
- mobject: Mobject to transform via homotopy
832
- run_time: Duration of homotopy transformation
833
- apply_function_kwargs: Additional arguments for transformation function
834
"""
835
836
def SmoothedVectorizedHomotopy(
837
homotopy_function: Callable,
838
mobject: VMobject,
839
**kwargs
840
) -> Animation:
841
"""
842
Smoothed version of homotopy for vectorized mobjects.
843
844
Provides enhanced smoothness for VMobject transformations
845
by considering Bézier curve properties during deformation.
846
847
Parameters:
848
- homotopy_function: Smooth homotopy transformation function
849
- mobject: VMobject to transform smoothly
850
"""
851
852
def ComplexHomotopy(
853
complex_homotopy: Callable,
854
mobject: Mobject,
855
**kwargs
856
) -> Animation:
857
"""
858
Apply complex number homotopy transformation.
859
860
Treats coordinates as complex numbers and applies complex
861
function transformations smoothly over time.
862
863
Parameters:
864
- complex_homotopy: Function (z, t) -> z' for complex coordinates
865
- mobject: Mobject to transform via complex homotopy
866
"""
867
868
def PhaseFlow(
869
function: Callable,
870
mobject: Mobject,
871
virtual_time: float = 1.0,
872
suspend_mobject_updating: bool = False,
873
**kwargs
874
) -> Animation:
875
"""
876
Move mobject according to vector field flow.
877
878
Animates motion following streamlines of a vector field,
879
simulating particle flow in mathematical field visualization.
880
881
Parameters:
882
- function: Vector field function (x, y, z) -> (vx, vy, vz)
883
- mobject: Mobject to move according to field flow
884
- virtual_time: Virtual time parameter for flow simulation
885
- suspend_mobject_updating: Whether to pause mobject updaters during flow
886
"""
887
```
888
889
### Rotation Animations
890
891
Animations for rotating mobjects around axes with precise angular control and continuous rotation effects.
892
893
```python { .api }
894
def Rotate(
895
mobject: Mobject,
896
angle: float,
897
axis: np.ndarray = OUT,
898
about_point: np.ndarray = None,
899
**kwargs
900
) -> Animation:
901
"""
902
Rotate mobject by specified angle around axis.
903
904
Single rotation transformation with precise angular control
905
and customizable rotation center and axis.
906
907
Parameters:
908
- mobject: Mobject to rotate
909
- angle: Rotation angle in radians
910
- axis: Rotation axis vector (default: OUT for 2D rotation)
911
- about_point: Center point for rotation (default: mobject center)
912
"""
913
914
def Rotating(
915
mobject: Mobject,
916
angle: float = TAU,
917
axis: np.ndarray = OUT,
918
about_point: np.ndarray = None,
919
run_time: float = 1.0,
920
rate_func: Callable = linear,
921
**kwargs
922
) -> Animation:
923
"""
924
Continuous rotation animation for specified duration.
925
926
Creates smooth, continuous rotation motion that can represent
927
spinning objects, orbital motion, or other rotational effects.
928
929
Parameters:
930
- mobject: Mobject to rotate continuously
931
- angle: Total rotation angle (default: full rotation)
932
- axis: Rotation axis vector
933
- about_point: Center point for rotation
934
- run_time: Duration of rotation animation
935
- rate_func: Rate function controlling rotation speed variation
936
"""
937
```
938
939
### Number Animations
940
941
Specialized animations for changing numerical values with smooth transitions and mathematical precision.
942
943
```python { .api }
944
def ChangingDecimal(
945
decimal_number_mobject: DecimalNumber,
946
number_update_func: Callable[[float], float],
947
**kwargs
948
) -> Animation:
949
"""
950
Smoothly animate changes in decimal number display.
951
952
Updates decimal number mobject continuously based on a function
953
that maps animation progress to numerical values.
954
955
Parameters:
956
- decimal_number_mobject: DecimalNumber mobject to animate
957
- number_update_func: Function mapping animation progress [0,1] to number values
958
"""
959
960
def ChangeDecimalToValue(
961
decimal_number_mobject: DecimalNumber,
962
target_number: float,
963
**kwargs
964
) -> Animation:
965
"""
966
Animate decimal number to specific target value.
967
968
Smoothly transitions displayed number from current value
969
to target value with interpolated intermediate values.
970
971
Parameters:
972
- decimal_number_mobject: DecimalNumber mobject to change
973
- target_number: Target numerical value to reach
974
"""
975
```
976
977
### Specialized Animations
978
979
Advanced animation effects for specific use cases and complex visual presentations.
980
981
```python { .api }
982
def Broadcast(
983
focal_point: np.ndarray | Mobject,
984
n_mobs: int = 5,
985
lag_ratio: float = 0.2,
986
run_time: float = 3.0,
987
**kwargs
988
) -> AnimationGroup:
989
"""
990
Create expanding broadcast/ripple effect from focal point.
991
992
Generates concentric expanding shapes that simulate broadcasting,
993
sound waves, or signal propagation effects.
994
995
Parameters:
996
- focal_point: Center point or mobject for broadcast origin
997
- n_mobs: Number of expanding broadcast rings
998
- lag_ratio: Delay between successive rings
999
- run_time: Total duration of broadcast effect
1000
"""
1001
1002
def ShowPartial(
1003
mobject: VMobject,
1004
a: float = 0.0,
1005
b: float = 1.0,
1006
**kwargs
1007
) -> Animation:
1008
"""
1009
Show partial rendering of VMobject from fraction a to b.
1010
1011
Reveals portion of path-based mobject, useful for drawing
1012
curves progressively or highlighting specific segments.
1013
1014
Parameters:
1015
- mobject: VMobject to show partially
1016
- a: Starting fraction of path to show [0, 1]
1017
- b: Ending fraction of path to show [0, 1]
1018
"""
1019
1020
def SpiralIn(
1021
mobject: Mobject,
1022
scale_factor: float = 8,
1023
**kwargs
1024
) -> Animation:
1025
"""
1026
Create spiraling appearance animation.
1027
1028
Object appears while following an inward spiral path,
1029
creating dramatic entrance effect.
1030
1031
Parameters:
1032
- mobject: Mobject to spiral in
1033
- scale_factor: Initial spiral radius multiplier
1034
"""
1035
1036
def AnimatedBoundary(
1037
vmobject: VMobject,
1038
boundary_color: str = WHITE,
1039
boundary_width: float = 3,
1040
**kwargs
1041
) -> Animation:
1042
"""
1043
Create animated boundary around VMobject.
1044
1045
Displays moving boundary that traces the perimeter
1046
of the object, useful for emphasis and highlighting.
1047
1048
Parameters:
1049
- vmobject: VMobject to create animated boundary around
1050
- boundary_color: Color of animated boundary
1051
- boundary_width: Width of boundary line
1052
"""
1053
1054
def TracedPath(
1055
mobject: Mobject,
1056
traced_point_func: Callable = None,
1057
stroke_width: float = 2,
1058
stroke_color: str = WHITE,
1059
**kwargs
1060
) -> Animation:
1061
"""
1062
Create trail following mobject's movement path.
1063
1064
Draws persistent trail that shows the path taken by
1065
a moving object, useful for trajectory visualization.
1066
1067
Parameters:
1068
- mobject: Mobject whose path to trace
1069
- traced_point_func: Function determining which point of mobject to trace
1070
- stroke_width: Width of traced path line
1071
- stroke_color: Color of traced path
1072
"""
1073
```
1074
1075
### Animation Composition
1076
1077
Utilities for combining and sequencing multiple animations with precise timing control and coordination.
1078
1079
```python { .api }
1080
def AnimationGroup(
1081
*animations: Animation,
1082
group: Group = None,
1083
run_time: float = None,
1084
rate_func: Callable = None,
1085
lag_ratio: float = 0,
1086
**kwargs
1087
) -> Animation:
1088
"""
1089
Play multiple animations simultaneously with coordinated timing.
1090
1091
All animations start together but can have different durations and
1092
rate functions. The group completes when all animations finish.
1093
1094
Parameters:
1095
- *animations: Animations to play together
1096
- group: Group containing mobjects for all animations
1097
- run_time: Override run time for all animations
1098
- rate_func: Rate function applied to all animations
1099
- lag_ratio: Stagger start times between animations
1100
"""
1101
1102
def Succession(
1103
*animations: Animation,
1104
**kwargs
1105
) -> Animation:
1106
"""
1107
Play animations one after another in sequence.
1108
1109
Each animation completes before the next begins, creating
1110
a linear sequence of animation events.
1111
1112
Parameters:
1113
- *animations: Animations to play in sequence
1114
"""
1115
1116
def LaggedStart(
1117
*animations: Animation,
1118
lag_ratio: float = 0.05,
1119
**kwargs
1120
) -> Animation:
1121
"""
1122
Start animations with staggered delays for cascade effect.
1123
1124
Each subsequent animation starts after a delay, creating
1125
a wave-like or cascade animation pattern.
1126
1127
Parameters:
1128
- *animations: Animations to stagger
1129
- lag_ratio: Delay factor between animation starts
1130
"""
1131
1132
def LaggedStartMap(
1133
AnimationClass: type,
1134
mobjects: list[Mobject],
1135
arg_creator: Callable = None,
1136
run_time: float = 2,
1137
**kwargs
1138
) -> Animation:
1139
"""
1140
Apply same animation type to multiple mobjects with staggered starts.
1141
1142
Convenient way to create coordinated effects across multiple objects
1143
without manually creating individual animations.
1144
1145
Parameters:
1146
- AnimationClass: Type of animation to apply
1147
- mobjects: List of mobjects to animate
1148
- arg_creator: Function to create custom args for each mobject
1149
- run_time: Duration for the complete sequence
1150
"""
1151
```
1152
1153
## Usage Examples
1154
1155
### Basic Animation Sequence
1156
1157
```python
1158
from manim import *
1159
1160
class AnimationExample(Scene):
1161
def construct(self):
1162
circle = Circle()
1163
square = Square()
1164
1165
# Creation animations
1166
self.play(Create(circle))
1167
self.wait(0.5)
1168
1169
# Transform animations
1170
self.play(Transform(circle, square))
1171
self.wait(0.5)
1172
1173
# Indication animations
1174
self.play(Indicate(square, scale_factor=1.5))
1175
self.wait(1)
1176
```
1177
1178
### Animation Composition
1179
1180
```python
1181
class CompositionExample(Scene):
1182
def construct(self):
1183
shapes = VGroup(*[Circle().shift(i*RIGHT) for i in range(5)])
1184
1185
# Simultaneous animations
1186
self.play(
1187
AnimationGroup(
1188
*[Create(shape) for shape in shapes],
1189
lag_ratio=0.1
1190
)
1191
)
1192
1193
# Sequential animations
1194
self.play(
1195
Succession(
1196
*[Indicate(shape) for shape in shapes]
1197
)
1198
)
1199
1200
# Staggered animations
1201
self.play(
1202
LaggedStart(
1203
*[FadeOut(shape) for shape in shapes],
1204
lag_ratio=0.2
1205
)
1206
)
1207
```
1208
1209
### Complex Transformations
1210
1211
```python
1212
class TransformExample(Scene):
1213
def construct(self):
1214
equation1 = MathTex("x^2 + 2x + 1")
1215
equation2 = MathTex("(x + 1)^2")
1216
1217
self.play(Write(equation1))
1218
self.wait(1)
1219
1220
# Transform with custom path
1221
self.play(
1222
ReplacementTransform(
1223
equation1, equation2,
1224
path_arc=PI/2,
1225
run_time=2
1226
)
1227
)
1228
1229
# Apply function transformation
1230
self.play(
1231
ApplyFunction(
1232
lambda mob: mob.scale(2).set_color(RED),
1233
equation2
1234
)
1235
)
1236
```