thanhkt commited on
Commit
6228caa
·
1 Parent(s): 1347fb0

Upload 884 files

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +16 -0
  2. data/rag/manim_docs/.DS_Store +0 -0
  3. data/rag/manim_docs/manim_core/.DS_Store +0 -0
  4. data/rag/manim_docs/manim_core/docs/.DS_Store +0 -0
  5. data/rag/manim_docs/manim_core/docs/examples.md +1776 -0
  6. data/rag/manim_docs/manim_core/docs/guides/.DS_Store +0 -0
  7. data/rag/manim_docs/manim_core/docs/guides/add_voiceovers.md +63 -0
  8. data/rag/manim_docs/manim_core/docs/guides/deep_dive.md +1004 -0
  9. data/rag/manim_docs/manim_core/docs/guides/using_text.md +826 -0
  10. data/rag/manim_docs/manim_core/docs/reference/.DS_Store +0 -0
  11. data/rag/manim_docs/manim_core/docs/reference/manim._config.logger_utils.JSONFormatter.md +45 -0
  12. data/rag/manim_docs/manim_core/docs/reference/manim._config.logger_utils.md +67 -0
  13. data/rag/manim_docs/manim_core/docs/reference/manim._config.md +33 -0
  14. data/rag/manim_docs/manim_core/docs/reference/manim._config.utils.ManimConfig.md +838 -0
  15. data/rag/manim_docs/manim_core/docs/reference/manim._config.utils.ManimFrame.md +40 -0
  16. data/rag/manim_docs/manim_core/docs/reference/manim._config.utils.md +75 -0
  17. data/rag/manim_docs/manim_core/docs/reference/manim.animation.animation.Add.md +206 -0
  18. data/rag/manim_docs/manim_core/docs/reference/manim.animation.animation.Animation.md +400 -0
  19. data/rag/manim_docs/manim_core/docs/reference/manim.animation.animation.Wait.md +105 -0
  20. data/rag/manim_docs/manim_core/docs/reference/manim.animation.animation.md +96 -0
  21. data/rag/manim_docs/manim_core/docs/reference/manim.animation.changing.AnimatedBoundary.md +66 -0
  22. data/rag/manim_docs/manim_core/docs/reference/manim.animation.changing.TracedPath.md +113 -0
  23. data/rag/manim_docs/manim_core/docs/reference/manim.animation.changing.md +9 -0
  24. data/rag/manim_docs/manim_core/docs/reference/manim.animation.composition.AnimationGroup.md +153 -0
  25. data/rag/manim_docs/manim_core/docs/reference/manim.animation.composition.LaggedStart.md +100 -0
  26. data/rag/manim_docs/manim_core/docs/reference/manim.animation.composition.LaggedStartMap.md +88 -0
  27. data/rag/manim_docs/manim_core/docs/reference/manim.animation.composition.Succession.md +160 -0
  28. data/rag/manim_docs/manim_core/docs/reference/manim.animation.composition.md +11 -0
  29. data/rag/manim_docs/manim_core/docs/reference/manim.animation.creation.AddTextLetterByLetter.md +39 -0
  30. data/rag/manim_docs/manim_core/docs/reference/manim.animation.creation.AddTextWordByWord.md +31 -0
  31. data/rag/manim_docs/manim_core/docs/reference/manim.animation.creation.Create.md +62 -0
  32. data/rag/manim_docs/manim_core/docs/reference/manim.animation.creation.DrawBorderThenFill.md +95 -0
  33. data/rag/manim_docs/manim_core/docs/reference/manim.animation.creation.RemoveTextLetterByLetter.md +39 -0
  34. data/rag/manim_docs/manim_core/docs/reference/manim.animation.creation.ShowIncreasingSubsets.md +77 -0
  35. data/rag/manim_docs/manim_core/docs/reference/manim.animation.creation.ShowPartial.md +34 -0
  36. data/rag/manim_docs/manim_core/docs/reference/manim.animation.creation.ShowSubmobjectsOneByOne.md +32 -0
  37. data/rag/manim_docs/manim_core/docs/reference/manim.animation.creation.SpiralIn.md +80 -0
  38. data/rag/manim_docs/manim_core/docs/reference/manim.animation.creation.TypeWithCursor.md +126 -0
  39. data/rag/manim_docs/manim_core/docs/reference/manim.animation.creation.Uncreate.md +59 -0
  40. data/rag/manim_docs/manim_core/docs/reference/manim.animation.creation.UntypeWithCursor.md +85 -0
  41. data/rag/manim_docs/manim_core/docs/reference/manim.animation.creation.Unwrite.md +86 -0
  42. data/rag/manim_docs/manim_core/docs/reference/manim.animation.creation.Write.md +112 -0
  43. data/rag/manim_docs/manim_core/docs/reference/manim.animation.creation.md +29 -0
  44. data/rag/manim_docs/manim_core/docs/reference/manim.animation.fading.FadeIn.md +86 -0
  45. data/rag/manim_docs/manim_core/docs/reference/manim.animation.fading.FadeOut.md +97 -0
  46. data/rag/manim_docs/manim_core/docs/reference/manim.animation.fading.md +40 -0
  47. data/rag/manim_docs/manim_core/docs/reference/manim.animation.growing.GrowArrow.md +66 -0
  48. data/rag/manim_docs/manim_core/docs/reference/manim.animation.growing.GrowFromCenter.md +63 -0
  49. data/rag/manim_docs/manim_core/docs/reference/manim.animation.growing.GrowFromEdge.md +69 -0
  50. data/rag/manim_docs/manim_core/docs/reference/manim.animation.growing.GrowFromPoint.md +77 -0
.gitattributes CHANGED
@@ -34,3 +34,19 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
  task_generator/prompts_raw/__pycache__/__init__.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
  task_generator/prompts_raw/__pycache__/__init__.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
37
+ data/rag/manim_docs/plugin_docs/manim-chemistry/examples/examples_assets/CustomGraphMoleculeAnimation.gif filter=lfs diff=lfs merge=lfs -text
38
+ data/rag/manim_docs/plugin_docs/manim-chemistry/examples/examples_assets/Draw3DMorphine_ManimCE_v0.17.3.png filter=lfs diff=lfs merge=lfs -text
39
+ data/rag/manim_docs/plugin_docs/manim-chemistry/examples/examples_assets/DrawPeriodicTable_ManimCE_v0.17.3.png filter=lfs diff=lfs merge=lfs -text
40
+ data/rag/manim_docs/plugin_docs/manim-chemistry/examples/examples_assets/Fullerene.png filter=lfs diff=lfs merge=lfs -text
41
+ data/rag/manim_docs/plugin_docs/manim-chemistry/examples/examples_assets/TinPhases.png filter=lfs diff=lfs merge=lfs -text
42
+ data/rag/manim_docs/plugin_docs/manim-circuit/examples/all-parts-and-variants/AllPartsAndVariants_ManimCE_v0.18.1.png filter=lfs diff=lfs merge=lfs -text
43
+ data/rag/manim_docs/plugin_docs/manim-ml/examples/media/CNNScene.gif filter=lfs diff=lfs merge=lfs -text
44
+ data/rag/manim_docs/plugin_docs/manim-ml/examples/media/DisentanglementScene.gif filter=lfs diff=lfs merge=lfs -text
45
+ data/rag/manim_docs/plugin_docs/manim-ml/examples/media/GANScene.gif filter=lfs diff=lfs merge=lfs -text
46
+ data/rag/manim_docs/plugin_docs/manim-ml/examples/media/ImageNeuralNetworkScene.gif filter=lfs diff=lfs merge=lfs -text
47
+ data/rag/manim_docs/plugin_docs/manim-ml/examples/media/ManimMLLogo.gif filter=lfs diff=lfs merge=lfs -text
48
+ data/rag/manim_docs/plugin_docs/manim-ml/examples/media/NNImage.png filter=lfs diff=lfs merge=lfs -text
49
+ data/rag/manim_docs/plugin_docs/manim-ml/examples/media/TestNeuralNetworkScene.gif filter=lfs diff=lfs merge=lfs -text
50
+ data/rag/manim_docs/plugin_docs/manim-ml/examples/media/VAEScene.gif filter=lfs diff=lfs merge=lfs -text
51
+ data/rag/manim_docs/plugin_docs/manim-ml/examples/variational_autoencoder/autoencoder_models/data/MNIST/raw/t10k-images-idx3-ubyte filter=lfs diff=lfs merge=lfs -text
52
+ data/rag/manim_docs/plugin_docs/manim-ml/examples/variational_autoencoder/autoencoder_models/data/MNIST/raw/train-images-idx3-ubyte filter=lfs diff=lfs merge=lfs -text
data/rag/manim_docs/.DS_Store ADDED
Binary file (6.15 kB). View file
 
data/rag/manim_docs/manim_core/.DS_Store ADDED
Binary file (6.15 kB). View file
 
data/rag/manim_docs/manim_core/docs/.DS_Store ADDED
Binary file (10.2 kB). View file
 
data/rag/manim_docs/manim_core/docs/examples.md ADDED
@@ -0,0 +1,1776 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Example Gallery
2
+
3
+ This gallery contains a collection of best practice code snippets
4
+ together with their corresponding video/image output, illustrating
5
+ different functionalities all across the library.
6
+ These are all under the MIT license, so feel free to copy & paste them to your projects.
7
+ Enjoy this taste of Manim!
8
+
9
+ ## Basic Concepts
10
+
11
+ <div id="manimcelogo" class="admonition admonition-manim-example">
12
+ <p class="admonition-title">Example: ManimCELogo <a class="headerlink" href="#manimcelogo">¶</a></p>![image](media/images/ManimCELogo-1.png)
13
+ ```python
14
+ from manim import *
15
+
16
+ class ManimCELogo(Scene):
17
+ def construct(self):
18
+ self.camera.background_color = "#ece6e2"
19
+ logo_green = "#87c2a5"
20
+ logo_blue = "#525893"
21
+ logo_red = "#e07a5f"
22
+ logo_black = "#343434"
23
+ ds_m = MathTex(r"\mathbb{M}", fill_color=logo_black).scale(7)
24
+ ds_m.shift(2.25 * LEFT + 1.5 * UP)
25
+ circle = Circle(color=logo_green, fill_opacity=1).shift(LEFT)
26
+ square = Square(color=logo_blue, fill_opacity=1).shift(UP)
27
+ triangle = Triangle(color=logo_red, fill_opacity=1).shift(RIGHT)
28
+ logo = VGroup(triangle, square, circle, ds_m) # order matters
29
+ logo.move_to(ORIGIN)
30
+ self.add(logo)
31
+ ```
32
+
33
+ <pre data-manim-binder data-manim-classname="ManimCELogo">
34
+ class ManimCELogo(Scene):
35
+ def construct(self):
36
+ self.camera.background_color = "#ece6e2"
37
+ logo_green = "#87c2a5"
38
+ logo_blue = "#525893"
39
+ logo_red = "#e07a5f"
40
+ logo_black = "#343434"
41
+ ds_m = MathTex(r"\\mathbb{M}", fill_color=logo_black).scale(7)
42
+ ds_m.shift(2.25 \* LEFT + 1.5 \* UP)
43
+ circle = Circle(color=logo_green, fill_opacity=1).shift(LEFT)
44
+ square = Square(color=logo_blue, fill_opacity=1).shift(UP)
45
+ triangle = Triangle(color=logo_red, fill_opacity=1).shift(RIGHT)
46
+ logo = VGroup(triangle, square, circle, ds_m) # order matters
47
+ logo.move_to(ORIGIN)
48
+ self.add(logo)
49
+
50
+ </pre>
51
+
52
+ References: [`MathTex`](reference/manim.mobject.text.tex_mobject.MathTex.md#manim.mobject.text.tex_mobject.MathTex) [`Circle`](reference/manim.mobject.geometry.arc.Circle.md#manim.mobject.geometry.arc.Circle) [`Square`](reference/manim.mobject.geometry.polygram.Square.md#manim.mobject.geometry.polygram.Square) [`Triangle`](reference/manim.mobject.geometry.polygram.Triangle.md#manim.mobject.geometry.polygram.Triangle)
53
+
54
+ </div><div id="braceannotation" class="admonition admonition-manim-example">
55
+ <p class="admonition-title">Example: BraceAnnotation <a class="headerlink" href="#braceannotation">¶</a></p>![image](media/images/BraceAnnotation-1.png)
56
+ ```python
57
+ from manim import *
58
+
59
+ class BraceAnnotation(Scene):
60
+ def construct(self):
61
+ dot = Dot([-2, -1, 0])
62
+ dot2 = Dot([2, 1, 0])
63
+ line = Line(dot.get_center(), dot2.get_center()).set_color(ORANGE)
64
+ b1 = Brace(line)
65
+ b1text = b1.get_text("Horizontal distance")
66
+ b2 = Brace(line, direction=line.copy().rotate(PI / 2).get_unit_vector())
67
+ b2text = b2.get_tex("x-x_1")
68
+ self.add(line, dot, dot2, b1, b2, b1text, b2text)
69
+ ```
70
+
71
+ <pre data-manim-binder data-manim-classname="BraceAnnotation">
72
+ class BraceAnnotation(Scene):
73
+ def construct(self):
74
+ dot = Dot([-2, -1, 0])
75
+ dot2 = Dot([2, 1, 0])
76
+ line = Line(dot.get_center(), dot2.get_center()).set_color(ORANGE)
77
+ b1 = Brace(line)
78
+ b1text = b1.get_text("Horizontal distance")
79
+ b2 = Brace(line, direction=line.copy().rotate(PI / 2).get_unit_vector())
80
+ b2text = b2.get_tex("x-x_1")
81
+ self.add(line, dot, dot2, b1, b2, b1text, b2text)
82
+
83
+ </pre>
84
+
85
+ References: [`Brace`](reference/manim.mobject.svg.brace.Brace.md#manim.mobject.svg.brace.Brace) [`get_text()`](reference/manim.mobject.svg.brace.Brace.md#manim.mobject.svg.brace.Brace.get_text) [`get_tex()`](reference/manim.mobject.svg.brace.Brace.md#manim.mobject.svg.brace.Brace.get_tex)
86
+
87
+ </div><div id="vectorarrow" class="admonition admonition-manim-example">
88
+ <p class="admonition-title">Example: VectorArrow <a class="headerlink" href="#vectorarrow">¶</a></p>![image](media/images/VectorArrow-1.png)
89
+ ```python
90
+ from manim import *
91
+
92
+ class VectorArrow(Scene):
93
+ def construct(self):
94
+ dot = Dot(ORIGIN)
95
+ arrow = Arrow(ORIGIN, [2, 2, 0], buff=0)
96
+ numberplane = NumberPlane()
97
+ origin_text = Text('(0, 0)').next_to(dot, DOWN)
98
+ tip_text = Text('(2, 2)').next_to(arrow.get_end(), RIGHT)
99
+ self.add(numberplane, dot, arrow, origin_text, tip_text)
100
+ ```
101
+
102
+ <pre data-manim-binder data-manim-classname="VectorArrow">
103
+ class VectorArrow(Scene):
104
+ def construct(self):
105
+ dot = Dot(ORIGIN)
106
+ arrow = Arrow(ORIGIN, [2, 2, 0], buff=0)
107
+ numberplane = NumberPlane()
108
+ origin_text = Text('(0, 0)').next_to(dot, DOWN)
109
+ tip_text = Text('(2, 2)').next_to(arrow.get_end(), RIGHT)
110
+ self.add(numberplane, dot, arrow, origin_text, tip_text)
111
+
112
+ </pre>
113
+
114
+ References: [`Dot`](reference/manim.mobject.geometry.arc.Dot.md#manim.mobject.geometry.arc.Dot) [`Arrow`](reference/manim.mobject.geometry.line.Arrow.md#manim.mobject.geometry.line.Arrow) [`NumberPlane`](reference/manim.mobject.graphing.coordinate_systems.NumberPlane.md#manim.mobject.graphing.coordinate_systems.NumberPlane) [`Text`](reference/manim.mobject.text.text_mobject.Text.md#manim.mobject.text.text_mobject.Text)
115
+
116
+ </div><div id="gradientimagefromarray" class="admonition admonition-manim-example">
117
+ <p class="admonition-title">Example: GradientImageFromArray <a class="headerlink" href="#gradientimagefromarray">¶</a></p>![image](media/images/GradientImageFromArray-1.png)
118
+ ```python
119
+ from manim import *
120
+
121
+ class GradientImageFromArray(Scene):
122
+ def construct(self):
123
+ n = 256
124
+ imageArray = np.uint8(
125
+ [[i * 256 / n for i in range(0, n)] for _ in range(0, n)]
126
+ )
127
+ image = ImageMobject(imageArray).scale(2)
128
+ image.background_rectangle = SurroundingRectangle(image, color=GREEN)
129
+ self.add(image, image.background_rectangle)
130
+ ```
131
+
132
+ <pre data-manim-binder data-manim-classname="GradientImageFromArray">
133
+ class GradientImageFromArray(Scene):
134
+ def construct(self):
135
+ n = 256
136
+ imageArray = np.uint8(
137
+ [[i \* 256 / n for i in range(0, n)] for \_ in range(0, n)]
138
+ )
139
+ image = ImageMobject(imageArray).scale(2)
140
+ image.background_rectangle = SurroundingRectangle(image, color=GREEN)
141
+ self.add(image, image.background_rectangle)
142
+
143
+ </pre>
144
+
145
+ References: [`ImageMobject`](reference/manim.mobject.types.image_mobject.ImageMobject.md#manim.mobject.types.image_mobject.ImageMobject)
146
+
147
+ </div><div id="booleanoperations" class="admonition admonition-manim-example">
148
+ <p class="admonition-title">Example: BooleanOperations <a class="headerlink" href="#booleanoperations">¶</a></p><video
149
+ class="manim-video"
150
+ controls
151
+ loop
152
+ autoplay
153
+ src="./BooleanOperations-1.mp4">
154
+ </video>
155
+ ```python
156
+ from manim import *
157
+
158
+ class BooleanOperations(Scene):
159
+ def construct(self):
160
+ ellipse1 = Ellipse(
161
+ width=4.0, height=5.0, fill_opacity=0.5, color=BLUE, stroke_width=10
162
+ ).move_to(LEFT)
163
+ ellipse2 = ellipse1.copy().set_color(color=RED).move_to(RIGHT)
164
+ bool_ops_text = MarkupText("<u>Boolean Operation</u>").next_to(ellipse1, UP * 3)
165
+ ellipse_group = Group(bool_ops_text, ellipse1, ellipse2).move_to(LEFT * 3)
166
+ self.play(FadeIn(ellipse_group))
167
+
168
+ i = Intersection(ellipse1, ellipse2, color=GREEN, fill_opacity=0.5)
169
+ self.play(i.animate.scale(0.25).move_to(RIGHT * 5 + UP * 2.5))
170
+ intersection_text = Text("Intersection", font_size=23).next_to(i, UP)
171
+ self.play(FadeIn(intersection_text))
172
+
173
+ u = Union(ellipse1, ellipse2, color=ORANGE, fill_opacity=0.5)
174
+ union_text = Text("Union", font_size=23)
175
+ self.play(u.animate.scale(0.3).next_to(i, DOWN, buff=union_text.height * 3))
176
+ union_text.next_to(u, UP)
177
+ self.play(FadeIn(union_text))
178
+
179
+ e = Exclusion(ellipse1, ellipse2, color=YELLOW, fill_opacity=0.5)
180
+ exclusion_text = Text("Exclusion", font_size=23)
181
+ self.play(e.animate.scale(0.3).next_to(u, DOWN, buff=exclusion_text.height * 3.5))
182
+ exclusion_text.next_to(e, UP)
183
+ self.play(FadeIn(exclusion_text))
184
+
185
+ d = Difference(ellipse1, ellipse2, color=PINK, fill_opacity=0.5)
186
+ difference_text = Text("Difference", font_size=23)
187
+ self.play(d.animate.scale(0.3).next_to(u, LEFT, buff=difference_text.height * 3.5))
188
+ difference_text.next_to(d, UP)
189
+ self.play(FadeIn(difference_text))
190
+ ```
191
+
192
+ <pre data-manim-binder data-manim-classname="BooleanOperations">
193
+ class BooleanOperations(Scene):
194
+ def construct(self):
195
+ ellipse1 = Ellipse(
196
+ width=4.0, height=5.0, fill_opacity=0.5, color=BLUE, stroke_width=10
197
+ ).move_to(LEFT)
198
+ ellipse2 = ellipse1.copy().set_color(color=RED).move_to(RIGHT)
199
+ bool_ops_text = MarkupText("<u>Boolean Operation</u>").next_to(ellipse1, UP \* 3)
200
+ ellipse_group = Group(bool_ops_text, ellipse1, ellipse2).move_to(LEFT \* 3)
201
+ self.play(FadeIn(ellipse_group))
202
+
203
+ i = Intersection(ellipse1, ellipse2, color=GREEN, fill_opacity=0.5)
204
+ self.play(i.animate.scale(0.25).move_to(RIGHT \* 5 + UP \* 2.5))
205
+ intersection_text = Text("Intersection", font_size=23).next_to(i, UP)
206
+ self.play(FadeIn(intersection_text))
207
+
208
+ u = Union(ellipse1, ellipse2, color=ORANGE, fill_opacity=0.5)
209
+ union_text = Text("Union", font_size=23)
210
+ self.play(u.animate.scale(0.3).next_to(i, DOWN, buff=union_text.height \* 3))
211
+ union_text.next_to(u, UP)
212
+ self.play(FadeIn(union_text))
213
+
214
+ e = Exclusion(ellipse1, ellipse2, color=YELLOW, fill_opacity=0.5)
215
+ exclusion_text = Text("Exclusion", font_size=23)
216
+ self.play(e.animate.scale(0.3).next_to(u, DOWN, buff=exclusion_text.height \* 3.5))
217
+ exclusion_text.next_to(e, UP)
218
+ self.play(FadeIn(exclusion_text))
219
+
220
+ d = Difference(ellipse1, ellipse2, color=PINK, fill_opacity=0.5)
221
+ difference_text = Text("Difference", font_size=23)
222
+ self.play(d.animate.scale(0.3).next_to(u, LEFT, buff=difference_text.height \* 3.5))
223
+ difference_text.next_to(d, UP)
224
+ self.play(FadeIn(difference_text))
225
+
226
+ </pre>
227
+
228
+ References: [`Union`](reference/manim.mobject.geometry.boolean_ops.Union.md#manim.mobject.geometry.boolean_ops.Union) [`Intersection`](reference/manim.mobject.geometry.boolean_ops.Intersection.md#manim.mobject.geometry.boolean_ops.Intersection) [`Exclusion`](reference/manim.mobject.geometry.boolean_ops.Exclusion.md#manim.mobject.geometry.boolean_ops.Exclusion) [`Difference`](reference/manim.mobject.geometry.boolean_ops.Difference.md#manim.mobject.geometry.boolean_ops.Difference)
229
+
230
+ </div>
231
+
232
+ ## Animations
233
+
234
+ <div id="pointmovingonshapes" class="admonition admonition-manim-example">
235
+ <p class="admonition-title">Example: PointMovingOnShapes <a class="headerlink" href="#pointmovingonshapes">¶</a></p><video
236
+ class="manim-video"
237
+ controls
238
+ loop
239
+ autoplay
240
+ src="./PointMovingOnShapes-1.mp4">
241
+ </video>
242
+ ```python
243
+ from manim import *
244
+
245
+ class PointMovingOnShapes(Scene):
246
+ def construct(self):
247
+ circle = Circle(radius=1, color=BLUE)
248
+ dot = Dot()
249
+ dot2 = dot.copy().shift(RIGHT)
250
+ self.add(dot)
251
+
252
+ line = Line([3, 0, 0], [5, 0, 0])
253
+ self.add(line)
254
+
255
+ self.play(GrowFromCenter(circle))
256
+ self.play(Transform(dot, dot2))
257
+ self.play(MoveAlongPath(dot, circle), run_time=2, rate_func=linear)
258
+ self.play(Rotating(dot, about_point=[2, 0, 0]), run_time=1.5)
259
+ self.wait()
260
+ ```
261
+
262
+ <pre data-manim-binder data-manim-classname="PointMovingOnShapes">
263
+ class PointMovingOnShapes(Scene):
264
+ def construct(self):
265
+ circle = Circle(radius=1, color=BLUE)
266
+ dot = Dot()
267
+ dot2 = dot.copy().shift(RIGHT)
268
+ self.add(dot)
269
+
270
+ line = Line([3, 0, 0], [5, 0, 0])
271
+ self.add(line)
272
+
273
+ self.play(GrowFromCenter(circle))
274
+ self.play(Transform(dot, dot2))
275
+ self.play(MoveAlongPath(dot, circle), run_time=2, rate_func=linear)
276
+ self.play(Rotating(dot, about_point=[2, 0, 0]), run_time=1.5)
277
+ self.wait()
278
+
279
+ </pre>
280
+
281
+ References: [`Circle`](reference/manim.mobject.geometry.arc.Circle.md#manim.mobject.geometry.arc.Circle) [`Dot`](reference/manim.mobject.geometry.arc.Dot.md#manim.mobject.geometry.arc.Dot) [`Line`](reference/manim.mobject.geometry.line.Line.md#manim.mobject.geometry.line.Line) [`GrowFromCenter`](reference/manim.animation.growing.GrowFromCenter.md#manim.animation.growing.GrowFromCenter) [`Transform`](reference/manim.animation.transform.Transform.md#manim.animation.transform.Transform) [`MoveAlongPath`](reference/manim.animation.movement.MoveAlongPath.md#manim.animation.movement.MoveAlongPath) [`Rotating`](reference/manim.animation.rotation.Rotating.md#manim.animation.rotation.Rotating)
282
+
283
+ </div><div id="movingaround" class="admonition admonition-manim-example">
284
+ <p class="admonition-title">Example: MovingAround <a class="headerlink" href="#movingaround">¶</a></p><video
285
+ class="manim-video"
286
+ controls
287
+ loop
288
+ autoplay
289
+ src="./MovingAround-1.mp4">
290
+ </video>
291
+ ```python
292
+ from manim import *
293
+
294
+ class MovingAround(Scene):
295
+ def construct(self):
296
+ square = Square(color=BLUE, fill_opacity=1)
297
+
298
+ self.play(square.animate.shift(LEFT))
299
+ self.play(square.animate.set_fill(ORANGE))
300
+ self.play(square.animate.scale(0.3))
301
+ self.play(square.animate.rotate(0.4))
302
+ ```
303
+
304
+ <pre data-manim-binder data-manim-classname="MovingAround">
305
+ class MovingAround(Scene):
306
+ def construct(self):
307
+ square = Square(color=BLUE, fill_opacity=1)
308
+
309
+ self.play(square.animate.shift(LEFT))
310
+ self.play(square.animate.set_fill(ORANGE))
311
+ self.play(square.animate.scale(0.3))
312
+ self.play(square.animate.rotate(0.4))
313
+
314
+ </pre>
315
+
316
+ References: [`shift()`](reference/manim.mobject.mobject.Mobject.md#manim.mobject.mobject.Mobject.shift) [`set_fill()`](reference/manim.mobject.types.vectorized_mobject.VMobject.md#manim.mobject.types.vectorized_mobject.VMobject.set_fill) [`scale()`](reference/manim.mobject.mobject.Mobject.md#manim.mobject.mobject.Mobject.scale) [`rotate()`](reference/manim.mobject.mobject.Mobject.md#manim.mobject.mobject.Mobject.rotate)
317
+
318
+ </div><div id="movingangle" class="admonition admonition-manim-example">
319
+ <p class="admonition-title">Example: MovingAngle <a class="headerlink" href="#movingangle">¶</a></p><video
320
+ class="manim-video"
321
+ controls
322
+ loop
323
+ autoplay
324
+ src="./MovingAngle-1.mp4">
325
+ </video>
326
+ ```python
327
+ from manim import *
328
+
329
+ class MovingAngle(Scene):
330
+ def construct(self):
331
+ rotation_center = LEFT
332
+
333
+ theta_tracker = ValueTracker(110)
334
+ line1 = Line(LEFT, RIGHT)
335
+ line_moving = Line(LEFT, RIGHT)
336
+ line_ref = line_moving.copy()
337
+ line_moving.rotate(
338
+ theta_tracker.get_value() * DEGREES, about_point=rotation_center
339
+ )
340
+ a = Angle(line1, line_moving, radius=0.5, other_angle=False)
341
+ tex = MathTex(r"\theta").move_to(
342
+ Angle(
343
+ line1, line_moving, radius=0.5 + 3 * SMALL_BUFF, other_angle=False
344
+ ).point_from_proportion(0.5)
345
+ )
346
+
347
+ self.add(line1, line_moving, a, tex)
348
+ self.wait()
349
+
350
+ line_moving.add_updater(
351
+ lambda x: x.become(line_ref.copy()).rotate(
352
+ theta_tracker.get_value() * DEGREES, about_point=rotation_center
353
+ )
354
+ )
355
+
356
+ a.add_updater(
357
+ lambda x: x.become(Angle(line1, line_moving, radius=0.5, other_angle=False))
358
+ )
359
+ tex.add_updater(
360
+ lambda x: x.move_to(
361
+ Angle(
362
+ line1, line_moving, radius=0.5 + 3 * SMALL_BUFF, other_angle=False
363
+ ).point_from_proportion(0.5)
364
+ )
365
+ )
366
+
367
+ self.play(theta_tracker.animate.set_value(40))
368
+ self.play(theta_tracker.animate.increment_value(140))
369
+ self.play(tex.animate.set_color(RED), run_time=0.5)
370
+ self.play(theta_tracker.animate.set_value(350))
371
+ ```
372
+
373
+ <pre data-manim-binder data-manim-classname="MovingAngle">
374
+ class MovingAngle(Scene):
375
+ def construct(self):
376
+ rotation_center = LEFT
377
+
378
+ theta_tracker = ValueTracker(110)
379
+ line1 = Line(LEFT, RIGHT)
380
+ line_moving = Line(LEFT, RIGHT)
381
+ line_ref = line_moving.copy()
382
+ line_moving.rotate(
383
+ theta_tracker.get_value() \* DEGREES, about_point=rotation_center
384
+ )
385
+ a = Angle(line1, line_moving, radius=0.5, other_angle=False)
386
+ tex = MathTex(r"\\theta").move_to(
387
+ Angle(
388
+ line1, line_moving, radius=0.5 + 3 \* SMALL_BUFF, other_angle=False
389
+ ).point_from_proportion(0.5)
390
+ )
391
+
392
+ self.add(line1, line_moving, a, tex)
393
+ self.wait()
394
+
395
+ line_moving.add_updater(
396
+ lambda x: x.become(line_ref.copy()).rotate(
397
+ theta_tracker.get_value() \* DEGREES, about_point=rotation_center
398
+ )
399
+ )
400
+
401
+ a.add_updater(
402
+ lambda x: x.become(Angle(line1, line_moving, radius=0.5, other_angle=False))
403
+ )
404
+ tex.add_updater(
405
+ lambda x: x.move_to(
406
+ Angle(
407
+ line1, line_moving, radius=0.5 + 3 \* SMALL_BUFF, other_angle=False
408
+ ).point_from_proportion(0.5)
409
+ )
410
+ )
411
+
412
+ self.play(theta_tracker.animate.set_value(40))
413
+ self.play(theta_tracker.animate.increment_value(140))
414
+ self.play(tex.animate.set_color(RED), run_time=0.5)
415
+ self.play(theta_tracker.animate.set_value(350))
416
+
417
+ </pre>
418
+
419
+ References: [`Angle`](reference/manim.mobject.geometry.line.Angle.md#manim.mobject.geometry.line.Angle) [`rotate()`](reference/manim.mobject.mobject.Mobject.md#manim.mobject.mobject.Mobject.rotate)
420
+
421
+ </div><div id="movingdots" class="admonition admonition-manim-example">
422
+ <p class="admonition-title">Example: MovingDots <a class="headerlink" href="#movingdots">¶</a></p><video
423
+ class="manim-video"
424
+ controls
425
+ loop
426
+ autoplay
427
+ src="./MovingDots-1.mp4">
428
+ </video>
429
+ ```python
430
+ from manim import *
431
+
432
+ class MovingDots(Scene):
433
+ def construct(self):
434
+ d1,d2=Dot(color=BLUE),Dot(color=GREEN)
435
+ dg=VGroup(d1,d2).arrange(RIGHT,buff=1)
436
+ l1=Line(d1.get_center(),d2.get_center()).set_color(RED)
437
+ x=ValueTracker(0)
438
+ y=ValueTracker(0)
439
+ d1.add_updater(lambda z: z.set_x(x.get_value()))
440
+ d2.add_updater(lambda z: z.set_y(y.get_value()))
441
+ l1.add_updater(lambda z: z.become(Line(d1.get_center(),d2.get_center())))
442
+ self.add(d1,d2,l1)
443
+ self.play(x.animate.set_value(5))
444
+ self.play(y.animate.set_value(4))
445
+ self.wait()
446
+ ```
447
+
448
+ <pre data-manim-binder data-manim-classname="MovingDots">
449
+ class MovingDots(Scene):
450
+ def construct(self):
451
+ d1,d2=Dot(color=BLUE),Dot(color=GREEN)
452
+ dg=VGroup(d1,d2).arrange(RIGHT,buff=1)
453
+ l1=Line(d1.get_center(),d2.get_center()).set_color(RED)
454
+ x=ValueTracker(0)
455
+ y=ValueTracker(0)
456
+ d1.add_updater(lambda z: z.set_x(x.get_value()))
457
+ d2.add_updater(lambda z: z.set_y(y.get_value()))
458
+ l1.add_updater(lambda z: z.become(Line(d1.get_center(),d2.get_center())))
459
+ self.add(d1,d2,l1)
460
+ self.play(x.animate.set_value(5))
461
+ self.play(y.animate.set_value(4))
462
+ self.wait()
463
+
464
+ </pre></div><div id="movinggrouptodestination" class="admonition admonition-manim-example">
465
+ <p class="admonition-title">Example: MovingGroupToDestination <a class="headerlink" href="#movinggrouptodestination">¶</a></p><video
466
+ class="manim-video"
467
+ controls
468
+ loop
469
+ autoplay
470
+ src="./MovingGroupToDestination-1.mp4">
471
+ </video>
472
+ ```python
473
+ from manim import *
474
+
475
+ class MovingGroupToDestination(Scene):
476
+ def construct(self):
477
+ group = VGroup(Dot(LEFT), Dot(ORIGIN), Dot(RIGHT, color=RED), Dot(2 * RIGHT)).scale(1.4)
478
+ dest = Dot([4, 3, 0], color=YELLOW)
479
+ self.add(group, dest)
480
+ self.play(group.animate.shift(dest.get_center() - group[2].get_center()))
481
+ self.wait(0.5)
482
+ ```
483
+
484
+ <pre data-manim-binder data-manim-classname="MovingGroupToDestination">
485
+ class MovingGroupToDestination(Scene):
486
+ def construct(self):
487
+ group = VGroup(Dot(LEFT), Dot(ORIGIN), Dot(RIGHT, color=RED), Dot(2 \* RIGHT)).scale(1.4)
488
+ dest = Dot([4, 3, 0], color=YELLOW)
489
+ self.add(group, dest)
490
+ self.play(group.animate.shift(dest.get_center() - group[2].get_center()))
491
+ self.wait(0.5)
492
+
493
+ </pre></div><div id="movingframebox" class="admonition admonition-manim-example">
494
+ <p class="admonition-title">Example: MovingFrameBox <a class="headerlink" href="#movingframebox">¶</a></p><video
495
+ class="manim-video"
496
+ controls
497
+ loop
498
+ autoplay
499
+ src="./MovingFrameBox-1.mp4">
500
+ </video>
501
+ ```python
502
+ from manim import *
503
+
504
+ class MovingFrameBox(Scene):
505
+ def construct(self):
506
+ text=MathTex(
507
+ "\\frac{d}{dx}f(x)g(x)=","f(x)\\frac{d}{dx}g(x)","+",
508
+ "g(x)\\frac{d}{dx}f(x)"
509
+ )
510
+ self.play(Write(text))
511
+ framebox1 = SurroundingRectangle(text[1], buff = .1)
512
+ framebox2 = SurroundingRectangle(text[3], buff = .1)
513
+ self.play(
514
+ Create(framebox1),
515
+ )
516
+ self.wait()
517
+ self.play(
518
+ ReplacementTransform(framebox1,framebox2),
519
+ )
520
+ self.wait()
521
+ ```
522
+
523
+ <pre data-manim-binder data-manim-classname="MovingFrameBox">
524
+ class MovingFrameBox(Scene):
525
+ def construct(self):
526
+ text=MathTex(
527
+ "\\\\frac{d}{dx}f(x)g(x)=","f(x)\\\\frac{d}{dx}g(x)","+",
528
+ "g(x)\\\\frac{d}{dx}f(x)"
529
+ )
530
+ self.play(Write(text))
531
+ framebox1 = SurroundingRectangle(text[1], buff = .1)
532
+ framebox2 = SurroundingRectangle(text[3], buff = .1)
533
+ self.play(
534
+ Create(framebox1),
535
+ )
536
+ self.wait()
537
+ self.play(
538
+ ReplacementTransform(framebox1,framebox2),
539
+ )
540
+ self.wait()
541
+
542
+ </pre>
543
+
544
+ References: `tex_mobject` [`MathTex`](reference/manim.mobject.text.tex_mobject.MathTex.md#manim.mobject.text.tex_mobject.MathTex) [`SurroundingRectangle`](reference/manim.mobject.geometry.shape_matchers.SurroundingRectangle.md#manim.mobject.geometry.shape_matchers.SurroundingRectangle)
545
+
546
+ </div><div id="rotationupdater" class="admonition admonition-manim-example">
547
+ <p class="admonition-title">Example: RotationUpdater <a class="headerlink" href="#rotationupdater">¶</a></p><video
548
+ class="manim-video"
549
+ controls
550
+ loop
551
+ autoplay
552
+ src="./RotationUpdater-1.mp4">
553
+ </video>
554
+ ```python
555
+ from manim import *
556
+
557
+ class RotationUpdater(Scene):
558
+ def construct(self):
559
+ def updater_forth(mobj, dt):
560
+ mobj.rotate_about_origin(dt)
561
+ def updater_back(mobj, dt):
562
+ mobj.rotate_about_origin(-dt)
563
+ line_reference = Line(ORIGIN, LEFT).set_color(WHITE)
564
+ line_moving = Line(ORIGIN, LEFT).set_color(YELLOW)
565
+ line_moving.add_updater(updater_forth)
566
+ self.add(line_reference, line_moving)
567
+ self.wait(2)
568
+ line_moving.remove_updater(updater_forth)
569
+ line_moving.add_updater(updater_back)
570
+ self.wait(2)
571
+ line_moving.remove_updater(updater_back)
572
+ self.wait(0.5)
573
+ ```
574
+
575
+ <pre data-manim-binder data-manim-classname="RotationUpdater">
576
+ class RotationUpdater(Scene):
577
+ def construct(self):
578
+ def updater_forth(mobj, dt):
579
+ mobj.rotate_about_origin(dt)
580
+ def updater_back(mobj, dt):
581
+ mobj.rotate_about_origin(-dt)
582
+ line_reference = Line(ORIGIN, LEFT).set_color(WHITE)
583
+ line_moving = Line(ORIGIN, LEFT).set_color(YELLOW)
584
+ line_moving.add_updater(updater_forth)
585
+ self.add(line_reference, line_moving)
586
+ self.wait(2)
587
+ line_moving.remove_updater(updater_forth)
588
+ line_moving.add_updater(updater_back)
589
+ self.wait(2)
590
+ line_moving.remove_updater(updater_back)
591
+ self.wait(0.5)
592
+
593
+ </pre>
594
+
595
+ References: [`add_updater()`](reference/manim.mobject.mobject.Mobject.md#manim.mobject.mobject.Mobject.add_updater) [`remove_updater()`](reference/manim.mobject.mobject.Mobject.md#manim.mobject.mobject.Mobject.remove_updater)
596
+
597
+ </div><div id="pointwithtrace" class="admonition admonition-manim-example">
598
+ <p class="admonition-title">Example: PointWithTrace <a class="headerlink" href="#pointwithtrace">¶</a></p><video
599
+ class="manim-video"
600
+ controls
601
+ loop
602
+ autoplay
603
+ src="./PointWithTrace-1.mp4">
604
+ </video>
605
+ ```python
606
+ from manim import *
607
+
608
+ class PointWithTrace(Scene):
609
+ def construct(self):
610
+ path = VMobject()
611
+ dot = Dot()
612
+ path.set_points_as_corners([dot.get_center(), dot.get_center()])
613
+ def update_path(path):
614
+ previous_path = path.copy()
615
+ previous_path.add_points_as_corners([dot.get_center()])
616
+ path.become(previous_path)
617
+ path.add_updater(update_path)
618
+ self.add(path, dot)
619
+ self.play(Rotating(dot, radians=PI, about_point=RIGHT, run_time=2))
620
+ self.wait()
621
+ self.play(dot.animate.shift(UP))
622
+ self.play(dot.animate.shift(LEFT))
623
+ self.wait()
624
+ ```
625
+
626
+ <pre data-manim-binder data-manim-classname="PointWithTrace">
627
+ class PointWithTrace(Scene):
628
+ def construct(self):
629
+ path = VMobject()
630
+ dot = Dot()
631
+ path.set_points_as_corners([dot.get_center(), dot.get_center()])
632
+ def update_path(path):
633
+ previous_path = path.copy()
634
+ previous_path.add_points_as_corners([dot.get_center()])
635
+ path.become(previous_path)
636
+ path.add_updater(update_path)
637
+ self.add(path, dot)
638
+ self.play(Rotating(dot, radians=PI, about_point=RIGHT, run_time=2))
639
+ self.wait()
640
+ self.play(dot.animate.shift(UP))
641
+ self.play(dot.animate.shift(LEFT))
642
+ self.wait()
643
+
644
+ </pre>
645
+
646
+ References: [`Rotating`](reference/manim.animation.rotation.Rotating.md#manim.animation.rotation.Rotating) [`set_points_as_corners()`](reference/manim.mobject.types.vectorized_mobject.VMobject.md#manim.mobject.types.vectorized_mobject.VMobject.set_points_as_corners) [`add_updater()`](reference/manim.mobject.mobject.Mobject.md#manim.mobject.mobject.Mobject.add_updater)
647
+
648
+ </div>
649
+
650
+ ## Plotting with Manim
651
+
652
+ <div id="sinandcosfunctionplot" class="admonition admonition-manim-example">
653
+ <p class="admonition-title">Example: SinAndCosFunctionPlot <a class="headerlink" href="#sinandcosfunctionplot">¶</a></p>![image](media/images/SinAndCosFunctionPlot-1.png)
654
+ ```python
655
+ from manim import *
656
+
657
+ class SinAndCosFunctionPlot(Scene):
658
+ def construct(self):
659
+ axes = Axes(
660
+ x_range=[-10, 10.3, 1],
661
+ y_range=[-1.5, 1.5, 1],
662
+ x_length=10,
663
+ axis_config={"color": GREEN},
664
+ x_axis_config={
665
+ "numbers_to_include": np.arange(-10, 10.01, 2),
666
+ "numbers_with_elongated_ticks": np.arange(-10, 10.01, 2),
667
+ },
668
+ tips=False,
669
+ )
670
+ axes_labels = axes.get_axis_labels()
671
+ sin_graph = axes.plot(lambda x: np.sin(x), color=BLUE)
672
+ cos_graph = axes.plot(lambda x: np.cos(x), color=RED)
673
+
674
+ sin_label = axes.get_graph_label(
675
+ sin_graph, "\\sin(x)", x_val=-10, direction=UP / 2
676
+ )
677
+ cos_label = axes.get_graph_label(cos_graph, label="\\cos(x)")
678
+
679
+ vert_line = axes.get_vertical_line(
680
+ axes.i2gp(TAU, cos_graph), color=YELLOW, line_func=Line
681
+ )
682
+ line_label = axes.get_graph_label(
683
+ cos_graph, r"x=2\pi", x_val=TAU, direction=UR, color=WHITE
684
+ )
685
+
686
+ plot = VGroup(axes, sin_graph, cos_graph, vert_line)
687
+ labels = VGroup(axes_labels, sin_label, cos_label, line_label)
688
+ self.add(plot, labels)
689
+ ```
690
+
691
+ <pre data-manim-binder data-manim-classname="SinAndCosFunctionPlot">
692
+ class SinAndCosFunctionPlot(Scene):
693
+ def construct(self):
694
+ axes = Axes(
695
+ x_range=[-10, 10.3, 1],
696
+ y_range=[-1.5, 1.5, 1],
697
+ x_length=10,
698
+ axis_config={"color": GREEN},
699
+ x_axis_config={
700
+ "numbers_to_include": np.arange(-10, 10.01, 2),
701
+ "numbers_with_elongated_ticks": np.arange(-10, 10.01, 2),
702
+ },
703
+ tips=False,
704
+ )
705
+ axes_labels = axes.get_axis_labels()
706
+ sin_graph = axes.plot(lambda x: np.sin(x), color=BLUE)
707
+ cos_graph = axes.plot(lambda x: np.cos(x), color=RED)
708
+
709
+ sin_label = axes.get_graph_label(
710
+ sin_graph, "\\\\sin(x)", x_val=-10, direction=UP / 2
711
+ )
712
+ cos_label = axes.get_graph_label(cos_graph, label="\\\\cos(x)")
713
+
714
+ vert_line = axes.get_vertical_line(
715
+ axes.i2gp(TAU, cos_graph), color=YELLOW, line_func=Line
716
+ )
717
+ line_label = axes.get_graph_label(
718
+ cos_graph, r"x=2\\pi", x_val=TAU, direction=UR, color=WHITE
719
+ )
720
+
721
+ plot = VGroup(axes, sin_graph, cos_graph, vert_line)
722
+ labels = VGroup(axes_labels, sin_label, cos_label, line_label)
723
+ self.add(plot, labels)
724
+
725
+ </pre>
726
+
727
+ References: `coordinate_systems` [`MathTex`](reference/manim.mobject.text.tex_mobject.MathTex.md#manim.mobject.text.tex_mobject.MathTex) `plot()` `get_vertical_line_to_graph()` `input_to_graph_point()` [`get_axis_labels()`](reference/manim.mobject.graphing.coordinate_systems.Axes.md#manim.mobject.graphing.coordinate_systems.Axes.get_axis_labels)
728
+
729
+ </div><div id="argminexample" class="admonition admonition-manim-example">
730
+ <p class="admonition-title">Example: ArgMinExample <a class="headerlink" href="#argminexample">¶</a></p><video
731
+ class="manim-video"
732
+ controls
733
+ loop
734
+ autoplay
735
+ src="./ArgMinExample-1.mp4">
736
+ </video>
737
+ ```python
738
+ from manim import *
739
+
740
+ class ArgMinExample(Scene):
741
+ def construct(self):
742
+ ax = Axes(
743
+ x_range=[0, 10], y_range=[0, 100, 10], axis_config={"include_tip": False}
744
+ )
745
+ labels = ax.get_axis_labels(x_label="x", y_label="f(x)")
746
+
747
+ t = ValueTracker(0)
748
+
749
+ def func(x):
750
+ return 2 * (x - 5) ** 2
751
+ graph = ax.plot(func, color=MAROON)
752
+
753
+ initial_point = [ax.coords_to_point(t.get_value(), func(t.get_value()))]
754
+ dot = Dot(point=initial_point)
755
+
756
+ dot.add_updater(lambda x: x.move_to(ax.c2p(t.get_value(), func(t.get_value()))))
757
+ x_space = np.linspace(*ax.x_range[:2],200)
758
+ minimum_index = func(x_space).argmin()
759
+
760
+ self.add(ax, labels, graph, dot)
761
+ self.play(t.animate.set_value(x_space[minimum_index]))
762
+ self.wait()
763
+ ```
764
+
765
+ <pre data-manim-binder data-manim-classname="ArgMinExample">
766
+ class ArgMinExample(Scene):
767
+ def construct(self):
768
+ ax = Axes(
769
+ x_range=[0, 10], y_range=[0, 100, 10], axis_config={"include_tip": False}
770
+ )
771
+ labels = ax.get_axis_labels(x_label="x", y_label="f(x)")
772
+
773
+ t = ValueTracker(0)
774
+
775
+ def func(x):
776
+ return 2 \* (x - 5) \*\* 2
777
+ graph = ax.plot(func, color=MAROON)
778
+
779
+ initial_point = [ax.coords_to_point(t.get_value(), func(t.get_value()))]
780
+ dot = Dot(point=initial_point)
781
+
782
+ dot.add_updater(lambda x: x.move_to(ax.c2p(t.get_value(), func(t.get_value()))))
783
+ x_space = np.linspace(\*ax.x_range[:2],200)
784
+ minimum_index = func(x_space).argmin()
785
+
786
+ self.add(ax, labels, graph, dot)
787
+ self.play(t.animate.set_value(x_space[minimum_index]))
788
+ self.wait()
789
+
790
+ </pre></div><div id="graphareaplot" class="admonition admonition-manim-example">
791
+ <p class="admonition-title">Example: GraphAreaPlot <a class="headerlink" href="#graphareaplot">¶</a></p>![image](media/images/GraphAreaPlot-1.png)
792
+ ```python
793
+ from manim import *
794
+
795
+ class GraphAreaPlot(Scene):
796
+ def construct(self):
797
+ ax = Axes(
798
+ x_range=[0, 5],
799
+ y_range=[0, 6],
800
+ x_axis_config={"numbers_to_include": [2, 3]},
801
+ tips=False,
802
+ )
803
+
804
+ labels = ax.get_axis_labels()
805
+
806
+ curve_1 = ax.plot(lambda x: 4 * x - x ** 2, x_range=[0, 4], color=BLUE_C)
807
+ curve_2 = ax.plot(
808
+ lambda x: 0.8 * x ** 2 - 3 * x + 4,
809
+ x_range=[0, 4],
810
+ color=GREEN_B,
811
+ )
812
+
813
+ line_1 = ax.get_vertical_line(ax.input_to_graph_point(2, curve_1), color=YELLOW)
814
+ line_2 = ax.get_vertical_line(ax.i2gp(3, curve_1), color=YELLOW)
815
+
816
+ riemann_area = ax.get_riemann_rectangles(curve_1, x_range=[0.3, 0.6], dx=0.03, color=BLUE, fill_opacity=0.5)
817
+ area = ax.get_area(curve_2, [2, 3], bounded_graph=curve_1, color=GREY, opacity=0.5)
818
+
819
+ self.add(ax, labels, curve_1, curve_2, line_1, line_2, riemann_area, area)
820
+ ```
821
+
822
+ <pre data-manim-binder data-manim-classname="GraphAreaPlot">
823
+ class GraphAreaPlot(Scene):
824
+ def construct(self):
825
+ ax = Axes(
826
+ x_range=[0, 5],
827
+ y_range=[0, 6],
828
+ x_axis_config={"numbers_to_include": [2, 3]},
829
+ tips=False,
830
+ )
831
+
832
+ labels = ax.get_axis_labels()
833
+
834
+ curve_1 = ax.plot(lambda x: 4 \* x - x \*\* 2, x_range=[0, 4], color=BLUE_C)
835
+ curve_2 = ax.plot(
836
+ lambda x: 0.8 \* x \*\* 2 - 3 \* x + 4,
837
+ x_range=[0, 4],
838
+ color=GREEN_B,
839
+ )
840
+
841
+ line_1 = ax.get_vertical_line(ax.input_to_graph_point(2, curve_1), color=YELLOW)
842
+ line_2 = ax.get_vertical_line(ax.i2gp(3, curve_1), color=YELLOW)
843
+
844
+ riemann_area = ax.get_riemann_rectangles(curve_1, x_range=[0.3, 0.6], dx=0.03, color=BLUE, fill_opacity=0.5)
845
+ area = ax.get_area(curve_2, [2, 3], bounded_graph=curve_1, color=GREY, opacity=0.5)
846
+
847
+ self.add(ax, labels, curve_1, curve_2, line_1, line_2, riemann_area, area)
848
+
849
+ </pre>
850
+
851
+ References: `coordinate_systems` `plot()` `get_vertical_line_to_graph()` `get_area()` [`get_axis_labels()`](reference/manim.mobject.graphing.coordinate_systems.Axes.md#manim.mobject.graphing.coordinate_systems.Axes.get_axis_labels)
852
+
853
+ </div><div id="polygononaxes" class="admonition admonition-manim-example">
854
+ <p class="admonition-title">Example: PolygonOnAxes <a class="headerlink" href="#polygononaxes">¶</a></p><video
855
+ class="manim-video"
856
+ controls
857
+ loop
858
+ autoplay
859
+ src="./PolygonOnAxes-1.mp4">
860
+ </video>
861
+ ```python
862
+ from manim import *
863
+
864
+ class PolygonOnAxes(Scene):
865
+ def get_rectangle_corners(self, bottom_left, top_right):
866
+ return [
867
+ (top_right[0], top_right[1]),
868
+ (bottom_left[0], top_right[1]),
869
+ (bottom_left[0], bottom_left[1]),
870
+ (top_right[0], bottom_left[1]),
871
+ ]
872
+
873
+ def construct(self):
874
+ ax = Axes(
875
+ x_range=[0, 10],
876
+ y_range=[0, 10],
877
+ x_length=6,
878
+ y_length=6,
879
+ axis_config={"include_tip": False},
880
+ )
881
+
882
+ t = ValueTracker(5)
883
+ k = 25
884
+
885
+ graph = ax.plot(
886
+ lambda x: k / x,
887
+ color=YELLOW_D,
888
+ x_range=[k / 10, 10.0, 0.01],
889
+ use_smoothing=False,
890
+ )
891
+
892
+ def get_rectangle():
893
+ polygon = Polygon(
894
+ *[
895
+ ax.c2p(*i)
896
+ for i in self.get_rectangle_corners(
897
+ (0, 0), (t.get_value(), k / t.get_value())
898
+ )
899
+ ]
900
+ )
901
+ polygon.stroke_width = 1
902
+ polygon.set_fill(BLUE, opacity=0.5)
903
+ polygon.set_stroke(YELLOW_B)
904
+ return polygon
905
+
906
+ polygon = always_redraw(get_rectangle)
907
+
908
+ dot = Dot()
909
+ dot.add_updater(lambda x: x.move_to(ax.c2p(t.get_value(), k / t.get_value())))
910
+ dot.set_z_index(10)
911
+
912
+ self.add(ax, graph, dot)
913
+ self.play(Create(polygon))
914
+ self.play(t.animate.set_value(10))
915
+ self.play(t.animate.set_value(k / 10))
916
+ self.play(t.animate.set_value(5))
917
+ ```
918
+
919
+ <pre data-manim-binder data-manim-classname="PolygonOnAxes">
920
+ class PolygonOnAxes(Scene):
921
+ def get_rectangle_corners(self, bottom_left, top_right):
922
+ return [
923
+ (top_right[0], top_right[1]),
924
+ (bottom_left[0], top_right[1]),
925
+ (bottom_left[0], bottom_left[1]),
926
+ (top_right[0], bottom_left[1]),
927
+ ]
928
+
929
+ def construct(self):
930
+ ax = Axes(
931
+ x_range=[0, 10],
932
+ y_range=[0, 10],
933
+ x_length=6,
934
+ y_length=6,
935
+ axis_config={"include_tip": False},
936
+ )
937
+
938
+ t = ValueTracker(5)
939
+ k = 25
940
+
941
+ graph = ax.plot(
942
+ lambda x: k / x,
943
+ color=YELLOW_D,
944
+ x_range=[k / 10, 10.0, 0.01],
945
+ use_smoothing=False,
946
+ )
947
+
948
+ def get_rectangle():
949
+ polygon = Polygon(
950
+ \*[
951
+ ax.c2p(\*i)
952
+ for i in self.get_rectangle_corners(
953
+ (0, 0), (t.get_value(), k / t.get_value())
954
+ )
955
+ ]
956
+ )
957
+ polygon.stroke_width = 1
958
+ polygon.set_fill(BLUE, opacity=0.5)
959
+ polygon.set_stroke(YELLOW_B)
960
+ return polygon
961
+
962
+ polygon = always_redraw(get_rectangle)
963
+
964
+ dot = Dot()
965
+ dot.add_updater(lambda x: x.move_to(ax.c2p(t.get_value(), k / t.get_value())))
966
+ dot.set_z_index(10)
967
+
968
+ self.add(ax, graph, dot)
969
+ self.play(Create(polygon))
970
+ self.play(t.animate.set_value(10))
971
+ self.play(t.animate.set_value(k / 10))
972
+ self.play(t.animate.set_value(5))
973
+
974
+ </pre>
975
+
976
+ References: [`Axes`](reference/manim.mobject.graphing.coordinate_systems.Axes.md#manim.mobject.graphing.coordinate_systems.Axes) [`Polygon`](reference/manim.mobject.geometry.polygram.Polygon.md#manim.mobject.geometry.polygram.Polygon)
977
+
978
+ </div><div id="heatdiagramplot" class="admonition admonition-manim-example">
979
+ <p class="admonition-title">Example: HeatDiagramPlot <a class="headerlink" href="#heatdiagramplot">¶</a></p>![image](media/images/HeatDiagramPlot-1.png)
980
+ ```python
981
+ from manim import *
982
+
983
+ class HeatDiagramPlot(Scene):
984
+ def construct(self):
985
+ ax = Axes(
986
+ x_range=[0, 40, 5],
987
+ y_range=[-8, 32, 5],
988
+ x_length=9,
989
+ y_length=6,
990
+ x_axis_config={"numbers_to_include": np.arange(0, 40, 5)},
991
+ y_axis_config={"numbers_to_include": np.arange(-5, 34, 5)},
992
+ tips=False,
993
+ )
994
+ labels = ax.get_axis_labels(
995
+ x_label=Tex(r"$\Delta Q$"), y_label=Tex(r"T[$^\circ C$]")
996
+ )
997
+
998
+ x_vals = [0, 8, 38, 39]
999
+ y_vals = [20, 0, 0, -5]
1000
+ graph = ax.plot_line_graph(x_values=x_vals, y_values=y_vals)
1001
+
1002
+ self.add(ax, labels, graph)
1003
+ ```
1004
+
1005
+ <pre data-manim-binder data-manim-classname="HeatDiagramPlot">
1006
+ class HeatDiagramPlot(Scene):
1007
+ def construct(self):
1008
+ ax = Axes(
1009
+ x_range=[0, 40, 5],
1010
+ y_range=[-8, 32, 5],
1011
+ x_length=9,
1012
+ y_length=6,
1013
+ x_axis_config={"numbers_to_include": np.arange(0, 40, 5)},
1014
+ y_axis_config={"numbers_to_include": np.arange(-5, 34, 5)},
1015
+ tips=False,
1016
+ )
1017
+ labels = ax.get_axis_labels(
1018
+ x_label=Tex(r"$\\Delta Q$"), y_label=Tex(r"T[$^\\circ C$]")
1019
+ )
1020
+
1021
+ x_vals = [0, 8, 38, 39]
1022
+ y_vals = [20, 0, 0, -5]
1023
+ graph = ax.plot_line_graph(x_values=x_vals, y_values=y_vals)
1024
+
1025
+ self.add(ax, labels, graph)
1026
+
1027
+ </pre>
1028
+
1029
+ References: `coordinate_systems` [`plot_line_graph()`](reference/manim.mobject.graphing.coordinate_systems.Axes.md#manim.mobject.graphing.coordinate_systems.Axes.plot_line_graph) [`get_axis_labels()`](reference/manim.mobject.graphing.coordinate_systems.Axes.md#manim.mobject.graphing.coordinate_systems.Axes.get_axis_labels)
1030
+
1031
+ </div>
1032
+
1033
+ ## Special Camera Settings
1034
+
1035
+ <div id="followinggraphcamera" class="admonition admonition-manim-example">
1036
+ <p class="admonition-title">Example: FollowingGraphCamera <a class="headerlink" href="#followinggraphcamera">¶</a></p><video
1037
+ class="manim-video"
1038
+ controls
1039
+ loop
1040
+ autoplay
1041
+ src="./FollowingGraphCamera-1.mp4">
1042
+ </video>
1043
+ ```python
1044
+ from manim import *
1045
+
1046
+ class FollowingGraphCamera(MovingCameraScene):
1047
+ def construct(self):
1048
+ self.camera.frame.save_state()
1049
+
1050
+ # create the axes and the curve
1051
+ ax = Axes(x_range=[-1, 10], y_range=[-1, 10])
1052
+ graph = ax.plot(lambda x: np.sin(x), color=BLUE, x_range=[0, 3 * PI])
1053
+
1054
+ # create dots based on the graph
1055
+ moving_dot = Dot(ax.i2gp(graph.t_min, graph), color=ORANGE)
1056
+ dot_1 = Dot(ax.i2gp(graph.t_min, graph))
1057
+ dot_2 = Dot(ax.i2gp(graph.t_max, graph))
1058
+
1059
+ self.add(ax, graph, dot_1, dot_2, moving_dot)
1060
+ self.play(self.camera.frame.animate.scale(0.5).move_to(moving_dot))
1061
+
1062
+ def update_curve(mob):
1063
+ mob.move_to(moving_dot.get_center())
1064
+
1065
+ self.camera.frame.add_updater(update_curve)
1066
+ self.play(MoveAlongPath(moving_dot, graph, rate_func=linear))
1067
+ self.camera.frame.remove_updater(update_curve)
1068
+
1069
+ self.play(Restore(self.camera.frame))
1070
+ ```
1071
+
1072
+ <pre data-manim-binder data-manim-classname="FollowingGraphCamera">
1073
+ class FollowingGraphCamera(MovingCameraScene):
1074
+ def construct(self):
1075
+ self.camera.frame.save_state()
1076
+
1077
+ # create the axes and the curve
1078
+ ax = Axes(x_range=[-1, 10], y_range=[-1, 10])
1079
+ graph = ax.plot(lambda x: np.sin(x), color=BLUE, x_range=[0, 3 \* PI])
1080
+
1081
+ # create dots based on the graph
1082
+ moving_dot = Dot(ax.i2gp(graph.t_min, graph), color=ORANGE)
1083
+ dot_1 = Dot(ax.i2gp(graph.t_min, graph))
1084
+ dot_2 = Dot(ax.i2gp(graph.t_max, graph))
1085
+
1086
+ self.add(ax, graph, dot_1, dot_2, moving_dot)
1087
+ self.play(self.camera.frame.animate.scale(0.5).move_to(moving_dot))
1088
+
1089
+ def update_curve(mob):
1090
+ mob.move_to(moving_dot.get_center())
1091
+
1092
+ self.camera.frame.add_updater(update_curve)
1093
+ self.play(MoveAlongPath(moving_dot, graph, rate_func=linear))
1094
+ self.camera.frame.remove_updater(update_curve)
1095
+
1096
+ self.play(Restore(self.camera.frame))
1097
+
1098
+ </pre>
1099
+
1100
+ References: [`moving_camera_scene`](reference/manim.scene.moving_camera_scene.md#module-manim.scene.moving_camera_scene) [`MovingCameraScene`](reference/manim.scene.moving_camera_scene.MovingCameraScene.md#manim.scene.moving_camera_scene.MovingCameraScene) [`MoveAlongPath`](reference/manim.animation.movement.MoveAlongPath.md#manim.animation.movement.MoveAlongPath) [`Restore`](reference/manim.animation.transform.Restore.md#manim.animation.transform.Restore) `plot()` [`add_updater()`](reference/manim.mobject.mobject.Mobject.md#manim.mobject.mobject.Mobject.add_updater)
1101
+
1102
+ </div><div id="movingzoomedscenearound" class="admonition admonition-manim-example">
1103
+ <p class="admonition-title">Example: MovingZoomedSceneAround <a class="headerlink" href="#movingzoomedscenearound">¶</a></p><video
1104
+ class="manim-video"
1105
+ controls
1106
+ loop
1107
+ autoplay
1108
+ src="./MovingZoomedSceneAround-1.mp4">
1109
+ </video>
1110
+ ```python
1111
+ from manim import *
1112
+
1113
+ class MovingZoomedSceneAround(ZoomedScene):
1114
+ # contributed by TheoremofBeethoven, www.youtube.com/c/TheoremofBeethoven
1115
+ def __init__(self, **kwargs):
1116
+ ZoomedScene.__init__(
1117
+ self,
1118
+ zoom_factor=0.3,
1119
+ zoomed_display_height=1,
1120
+ zoomed_display_width=6,
1121
+ image_frame_stroke_width=20,
1122
+ zoomed_camera_config={
1123
+ "default_frame_stroke_width": 3,
1124
+ },
1125
+ **kwargs
1126
+ )
1127
+
1128
+ def construct(self):
1129
+ dot = Dot().shift(UL * 2)
1130
+ image = ImageMobject(np.uint8([[0, 100, 30, 200],
1131
+ [255, 0, 5, 33]]))
1132
+ image.height = 7
1133
+ frame_text = Text("Frame", color=PURPLE, font_size=67)
1134
+ zoomed_camera_text = Text("Zoomed camera", color=RED, font_size=67)
1135
+
1136
+ self.add(image, dot)
1137
+ zoomed_camera = self.zoomed_camera
1138
+ zoomed_display = self.zoomed_display
1139
+ frame = zoomed_camera.frame
1140
+ zoomed_display_frame = zoomed_display.display_frame
1141
+
1142
+ frame.move_to(dot)
1143
+ frame.set_color(PURPLE)
1144
+ zoomed_display_frame.set_color(RED)
1145
+ zoomed_display.shift(DOWN)
1146
+
1147
+ zd_rect = BackgroundRectangle(zoomed_display, fill_opacity=0, buff=MED_SMALL_BUFF)
1148
+ self.add_foreground_mobject(zd_rect)
1149
+
1150
+ unfold_camera = UpdateFromFunc(zd_rect, lambda rect: rect.replace(zoomed_display))
1151
+
1152
+ frame_text.next_to(frame, DOWN)
1153
+
1154
+ self.play(Create(frame), FadeIn(frame_text, shift=UP))
1155
+ self.activate_zooming()
1156
+
1157
+ self.play(self.get_zoomed_display_pop_out_animation(), unfold_camera)
1158
+ zoomed_camera_text.next_to(zoomed_display_frame, DOWN)
1159
+ self.play(FadeIn(zoomed_camera_text, shift=UP))
1160
+ # Scale in x y z
1161
+ scale_factor = [0.5, 1.5, 0]
1162
+ self.play(
1163
+ frame.animate.scale(scale_factor),
1164
+ zoomed_display.animate.scale(scale_factor),
1165
+ FadeOut(zoomed_camera_text),
1166
+ FadeOut(frame_text)
1167
+ )
1168
+ self.wait()
1169
+ self.play(ScaleInPlace(zoomed_display, 2))
1170
+ self.wait()
1171
+ self.play(frame.animate.shift(2.5 * DOWN))
1172
+ self.wait()
1173
+ self.play(self.get_zoomed_display_pop_out_animation(), unfold_camera, rate_func=lambda t: smooth(1 - t))
1174
+ self.play(Uncreate(zoomed_display_frame), FadeOut(frame))
1175
+ self.wait()
1176
+ ```
1177
+
1178
+ <pre data-manim-binder data-manim-classname="MovingZoomedSceneAround">
1179
+ class MovingZoomedSceneAround(ZoomedScene):
1180
+ # contributed by TheoremofBeethoven, www.youtube.com/c/TheoremofBeethoven
1181
+ def \_\_init_\_(self, \*\*kwargs):
1182
+ ZoomedScene._\_init_\_(
1183
+ self,
1184
+ zoom_factor=0.3,
1185
+ zoomed_display_height=1,
1186
+ zoomed_display_width=6,
1187
+ image_frame_stroke_width=20,
1188
+ zoomed_camera_config={
1189
+ "default_frame_stroke_width": 3,
1190
+ },
1191
+ \*\*kwargs
1192
+ )
1193
+
1194
+ def construct(self):
1195
+ dot = Dot().shift(UL \* 2)
1196
+ image = ImageMobject(np.uint8([[0, 100, 30, 200],
1197
+ [255, 0, 5, 33]]))
1198
+ image.height = 7
1199
+ frame_text = Text("Frame", color=PURPLE, font_size=67)
1200
+ zoomed_camera_text = Text("Zoomed camera", color=RED, font_size=67)
1201
+
1202
+ self.add(image, dot)
1203
+ zoomed_camera = self.zoomed_camera
1204
+ zoomed_display = self.zoomed_display
1205
+ frame = zoomed_camera.frame
1206
+ zoomed_display_frame = zoomed_display.display_frame
1207
+
1208
+ frame.move_to(dot)
1209
+ frame.set_color(PURPLE)
1210
+ zoomed_display_frame.set_color(RED)
1211
+ zoomed_display.shift(DOWN)
1212
+
1213
+ zd_rect = BackgroundRectangle(zoomed_display, fill_opacity=0, buff=MED_SMALL_BUFF)
1214
+ self.add_foreground_mobject(zd_rect)
1215
+
1216
+ unfold_camera = UpdateFromFunc(zd_rect, lambda rect: rect.replace(zoomed_display))
1217
+
1218
+ frame_text.next_to(frame, DOWN)
1219
+
1220
+ self.play(Create(frame), FadeIn(frame_text, shift=UP))
1221
+ self.activate_zooming()
1222
+
1223
+ self.play(self.get_zoomed_display_pop_out_animation(), unfold_camera)
1224
+ zoomed_camera_text.next_to(zoomed_display_frame, DOWN)
1225
+ self.play(FadeIn(zoomed_camera_text, shift=UP))
1226
+ # Scale in x y z
1227
+ scale_factor = [0.5, 1.5, 0]
1228
+ self.play(
1229
+ frame.animate.scale(scale_factor),
1230
+ zoomed_display.animate.scale(scale_factor),
1231
+ FadeOut(zoomed_camera_text),
1232
+ FadeOut(frame_text)
1233
+ )
1234
+ self.wait()
1235
+ self.play(ScaleInPlace(zoomed_display, 2))
1236
+ self.wait()
1237
+ self.play(frame.animate.shift(2.5 \* DOWN))
1238
+ self.wait()
1239
+ self.play(self.get_zoomed_display_pop_out_animation(), unfold_camera, rate_func=lambda t: smooth(1 - t))
1240
+ self.play(Uncreate(zoomed_display_frame), FadeOut(frame))
1241
+ self.wait()
1242
+
1243
+ </pre>
1244
+
1245
+ References: [`zoomed_scene`](reference/manim.scene.zoomed_scene.md#module-manim.scene.zoomed_scene) [`ZoomedScene`](reference/manim.scene.zoomed_scene.ZoomedScene.md#manim.scene.zoomed_scene.ZoomedScene) [`BackgroundRectangle`](reference/manim.mobject.geometry.shape_matchers.BackgroundRectangle.md#manim.mobject.geometry.shape_matchers.BackgroundRectangle) [`UpdateFromFunc`](reference/manim.animation.updaters.update.UpdateFromFunc.md#manim.animation.updaters.update.UpdateFromFunc) [`add_updater()`](reference/manim.mobject.mobject.Mobject.md#manim.mobject.mobject.Mobject.add_updater) [`get_zoomed_display_pop_out_animation()`](reference/manim.scene.zoomed_scene.ZoomedScene.md#manim.scene.zoomed_scene.ZoomedScene.get_zoomed_display_pop_out_animation)
1246
+
1247
+ </div><div id="fixedinframemobjecttest" class="admonition admonition-manim-example">
1248
+ <p class="admonition-title">Example: FixedInFrameMObjectTest <a class="headerlink" href="#fixedinframemobjecttest">¶</a></p>![image](media/images/FixedInFrameMObjectTest-1.png)
1249
+ ```python
1250
+ from manim import *
1251
+
1252
+ class FixedInFrameMObjectTest(ThreeDScene):
1253
+ def construct(self):
1254
+ axes = ThreeDAxes()
1255
+ self.set_camera_orientation(phi=75 * DEGREES, theta=-45 * DEGREES)
1256
+ text3d = Text("This is a 3D text")
1257
+ self.add_fixed_in_frame_mobjects(text3d)
1258
+ text3d.to_corner(UL)
1259
+ self.add(axes)
1260
+ self.wait()
1261
+ ```
1262
+
1263
+ <pre data-manim-binder data-manim-classname="FixedInFrameMObjectTest">
1264
+ class FixedInFrameMObjectTest(ThreeDScene):
1265
+ def construct(self):
1266
+ axes = ThreeDAxes()
1267
+ self.set_camera_orientation(phi=75 \* DEGREES, theta=-45 \* DEGREES)
1268
+ text3d = Text("This is a 3D text")
1269
+ self.add_fixed_in_frame_mobjects(text3d)
1270
+ text3d.to_corner(UL)
1271
+ self.add(axes)
1272
+ self.wait()
1273
+
1274
+ </pre>
1275
+
1276
+ References: [`ThreeDScene`](reference/manim.scene.three_d_scene.ThreeDScene.md#manim.scene.three_d_scene.ThreeDScene) [`set_camera_orientation()`](reference/manim.scene.three_d_scene.ThreeDScene.md#manim.scene.three_d_scene.ThreeDScene.set_camera_orientation) [`add_fixed_in_frame_mobjects()`](reference/manim.scene.three_d_scene.ThreeDScene.md#manim.scene.three_d_scene.ThreeDScene.add_fixed_in_frame_mobjects)
1277
+
1278
+ </div><div id="threedlightsourceposition" class="admonition admonition-manim-example">
1279
+ <p class="admonition-title">Example: ThreeDLightSourcePosition <a class="headerlink" href="#threedlightsourceposition">¶</a></p>![image](media/images/ThreeDLightSourcePosition-1.png)
1280
+ ```python
1281
+ from manim import *
1282
+
1283
+ class ThreeDLightSourcePosition(ThreeDScene):
1284
+ def construct(self):
1285
+ axes = ThreeDAxes()
1286
+ sphere = Surface(
1287
+ lambda u, v: np.array([
1288
+ 1.5 * np.cos(u) * np.cos(v),
1289
+ 1.5 * np.cos(u) * np.sin(v),
1290
+ 1.5 * np.sin(u)
1291
+ ]), v_range=[0, TAU], u_range=[-PI / 2, PI / 2],
1292
+ checkerboard_colors=[RED_D, RED_E], resolution=(15, 32)
1293
+ )
1294
+ self.renderer.camera.light_source.move_to(3*IN) # changes the source of the light
1295
+ self.set_camera_orientation(phi=75 * DEGREES, theta=30 * DEGREES)
1296
+ self.add(axes, sphere)
1297
+ ```
1298
+
1299
+ <pre data-manim-binder data-manim-classname="ThreeDLightSourcePosition">
1300
+ class ThreeDLightSourcePosition(ThreeDScene):
1301
+ def construct(self):
1302
+ axes = ThreeDAxes()
1303
+ sphere = Surface(
1304
+ lambda u, v: np.array([
1305
+ 1.5 \* np.cos(u) \* np.cos(v),
1306
+ 1.5 \* np.cos(u) \* np.sin(v),
1307
+ 1.5 \* np.sin(u)
1308
+ ]), v_range=[0, TAU], u_range=[-PI / 2, PI / 2],
1309
+ checkerboard_colors=[RED_D, RED_E], resolution=(15, 32)
1310
+ )
1311
+ self.renderer.camera.light_source.move_to(3\*IN) # changes the source of the light
1312
+ self.set_camera_orientation(phi=75 \* DEGREES, theta=30 \* DEGREES)
1313
+ self.add(axes, sphere)
1314
+
1315
+ </pre>
1316
+
1317
+ References: [`ThreeDScene`](reference/manim.scene.three_d_scene.ThreeDScene.md#manim.scene.three_d_scene.ThreeDScene) [`ThreeDAxes`](reference/manim.mobject.graphing.coordinate_systems.ThreeDAxes.md#manim.mobject.graphing.coordinate_systems.ThreeDAxes) [`Surface`](reference/manim.mobject.three_d.three_dimensions.Surface.md#manim.mobject.three_d.three_dimensions.Surface) [`set_camera_orientation()`](reference/manim.scene.three_d_scene.ThreeDScene.md#manim.scene.three_d_scene.ThreeDScene.set_camera_orientation)
1318
+
1319
+ </div><div id="threedcamerarotation" class="admonition admonition-manim-example">
1320
+ <p class="admonition-title">Example: ThreeDCameraRotation <a class="headerlink" href="#threedcamerarotation">¶</a></p><video
1321
+ class="manim-video"
1322
+ controls
1323
+ loop
1324
+ autoplay
1325
+ src="./ThreeDCameraRotation-1.mp4">
1326
+ </video>
1327
+ ```python
1328
+ from manim import *
1329
+
1330
+ class ThreeDCameraRotation(ThreeDScene):
1331
+ def construct(self):
1332
+ axes = ThreeDAxes()
1333
+ circle=Circle()
1334
+ self.set_camera_orientation(phi=75 * DEGREES, theta=30 * DEGREES)
1335
+ self.add(circle,axes)
1336
+ self.begin_ambient_camera_rotation(rate=0.1)
1337
+ self.wait()
1338
+ self.stop_ambient_camera_rotation()
1339
+ self.move_camera(phi=75 * DEGREES, theta=30 * DEGREES)
1340
+ self.wait()
1341
+ ```
1342
+
1343
+ <pre data-manim-binder data-manim-classname="ThreeDCameraRotation">
1344
+ class ThreeDCameraRotation(ThreeDScene):
1345
+ def construct(self):
1346
+ axes = ThreeDAxes()
1347
+ circle=Circle()
1348
+ self.set_camera_orientation(phi=75 \* DEGREES, theta=30 \* DEGREES)
1349
+ self.add(circle,axes)
1350
+ self.begin_ambient_camera_rotation(rate=0.1)
1351
+ self.wait()
1352
+ self.stop_ambient_camera_rotation()
1353
+ self.move_camera(phi=75 \* DEGREES, theta=30 \* DEGREES)
1354
+ self.wait()
1355
+
1356
+ </pre>
1357
+
1358
+ References: [`ThreeDScene`](reference/manim.scene.three_d_scene.ThreeDScene.md#manim.scene.three_d_scene.ThreeDScene) [`ThreeDAxes`](reference/manim.mobject.graphing.coordinate_systems.ThreeDAxes.md#manim.mobject.graphing.coordinate_systems.ThreeDAxes) [`begin_ambient_camera_rotation()`](reference/manim.scene.three_d_scene.ThreeDScene.md#manim.scene.three_d_scene.ThreeDScene.begin_ambient_camera_rotation) [`stop_ambient_camera_rotation()`](reference/manim.scene.three_d_scene.ThreeDScene.md#manim.scene.three_d_scene.ThreeDScene.stop_ambient_camera_rotation)
1359
+
1360
+ </div><div id="threedcameraillusionrotation" class="admonition admonition-manim-example">
1361
+ <p class="admonition-title">Example: ThreeDCameraIllusionRotation <a class="headerlink" href="#threedcameraillusionrotation">¶</a></p><video
1362
+ class="manim-video"
1363
+ controls
1364
+ loop
1365
+ autoplay
1366
+ src="./ThreeDCameraIllusionRotation-1.mp4">
1367
+ </video>
1368
+ ```python
1369
+ from manim import *
1370
+
1371
+ class ThreeDCameraIllusionRotation(ThreeDScene):
1372
+ def construct(self):
1373
+ axes = ThreeDAxes()
1374
+ circle=Circle()
1375
+ self.set_camera_orientation(phi=75 * DEGREES, theta=30 * DEGREES)
1376
+ self.add(circle,axes)
1377
+ self.begin_3dillusion_camera_rotation(rate=2)
1378
+ self.wait(PI/2)
1379
+ self.stop_3dillusion_camera_rotation()
1380
+ ```
1381
+
1382
+ <pre data-manim-binder data-manim-classname="ThreeDCameraIllusionRotation">
1383
+ class ThreeDCameraIllusionRotation(ThreeDScene):
1384
+ def construct(self):
1385
+ axes = ThreeDAxes()
1386
+ circle=Circle()
1387
+ self.set_camera_orientation(phi=75 \* DEGREES, theta=30 \* DEGREES)
1388
+ self.add(circle,axes)
1389
+ self.begin_3dillusion_camera_rotation(rate=2)
1390
+ self.wait(PI/2)
1391
+ self.stop_3dillusion_camera_rotation()
1392
+
1393
+ </pre>
1394
+
1395
+ References: [`ThreeDScene`](reference/manim.scene.three_d_scene.ThreeDScene.md#manim.scene.three_d_scene.ThreeDScene) [`ThreeDAxes`](reference/manim.mobject.graphing.coordinate_systems.ThreeDAxes.md#manim.mobject.graphing.coordinate_systems.ThreeDAxes) [`begin_3dillusion_camera_rotation()`](reference/manim.scene.three_d_scene.ThreeDScene.md#manim.scene.three_d_scene.ThreeDScene.begin_3dillusion_camera_rotation) [`stop_3dillusion_camera_rotation()`](reference/manim.scene.three_d_scene.ThreeDScene.md#manim.scene.three_d_scene.ThreeDScene.stop_3dillusion_camera_rotation)
1396
+
1397
+ </div><div id="threedsurfaceplot" class="admonition admonition-manim-example">
1398
+ <p class="admonition-title">Example: ThreeDSurfacePlot <a class="headerlink" href="#threedsurfaceplot">¶</a></p>![image](media/images/ThreeDSurfacePlot-1.png)
1399
+ ```python
1400
+ from manim import *
1401
+
1402
+ class ThreeDSurfacePlot(ThreeDScene):
1403
+ def construct(self):
1404
+ resolution_fa = 24
1405
+ self.set_camera_orientation(phi=75 * DEGREES, theta=-30 * DEGREES)
1406
+
1407
+ def param_gauss(u, v):
1408
+ x = u
1409
+ y = v
1410
+ sigma, mu = 0.4, [0.0, 0.0]
1411
+ d = np.linalg.norm(np.array([x - mu[0], y - mu[1]]))
1412
+ z = np.exp(-(d ** 2 / (2.0 * sigma ** 2)))
1413
+ return np.array([x, y, z])
1414
+
1415
+ gauss_plane = Surface(
1416
+ param_gauss,
1417
+ resolution=(resolution_fa, resolution_fa),
1418
+ v_range=[-2, +2],
1419
+ u_range=[-2, +2]
1420
+ )
1421
+
1422
+ gauss_plane.scale(2, about_point=ORIGIN)
1423
+ gauss_plane.set_style(fill_opacity=1,stroke_color=GREEN)
1424
+ gauss_plane.set_fill_by_checkerboard(ORANGE, BLUE, opacity=0.5)
1425
+ axes = ThreeDAxes()
1426
+ self.add(axes,gauss_plane)
1427
+ ```
1428
+
1429
+ <pre data-manim-binder data-manim-classname="ThreeDSurfacePlot">
1430
+ class ThreeDSurfacePlot(ThreeDScene):
1431
+ def construct(self):
1432
+ resolution_fa = 24
1433
+ self.set_camera_orientation(phi=75 \* DEGREES, theta=-30 \* DEGREES)
1434
+
1435
+ def param_gauss(u, v):
1436
+ x = u
1437
+ y = v
1438
+ sigma, mu = 0.4, [0.0, 0.0]
1439
+ d = np.linalg.norm(np.array([x - mu[0], y - mu[1]]))
1440
+ z = np.exp(-(d \*\* 2 / (2.0 \* sigma \*\* 2)))
1441
+ return np.array([x, y, z])
1442
+
1443
+ gauss_plane = Surface(
1444
+ param_gauss,
1445
+ resolution=(resolution_fa, resolution_fa),
1446
+ v_range=[-2, +2],
1447
+ u_range=[-2, +2]
1448
+ )
1449
+
1450
+ gauss_plane.scale(2, about_point=ORIGIN)
1451
+ gauss_plane.set_style(fill_opacity=1,stroke_color=GREEN)
1452
+ gauss_plane.set_fill_by_checkerboard(ORANGE, BLUE, opacity=0.5)
1453
+ axes = ThreeDAxes()
1454
+ self.add(axes,gauss_plane)
1455
+
1456
+ </pre>
1457
+
1458
+ References: [`ThreeDScene`](reference/manim.scene.three_d_scene.ThreeDScene.md#manim.scene.three_d_scene.ThreeDScene) [`Surface`](reference/manim.mobject.three_d.three_dimensions.Surface.md#manim.mobject.three_d.three_dimensions.Surface)
1459
+
1460
+ </div>
1461
+
1462
+ ## Advanced Projects
1463
+
1464
+ <div id="openingmanim" class="admonition admonition-manim-example">
1465
+ <p class="admonition-title">Example: OpeningManim <a class="headerlink" href="#openingmanim">¶</a></p><video
1466
+ class="manim-video"
1467
+ controls
1468
+ loop
1469
+ autoplay
1470
+ src="./OpeningManim-1.mp4">
1471
+ </video>
1472
+ ```python
1473
+ from manim import *
1474
+
1475
+ class OpeningManim(Scene):
1476
+ def construct(self):
1477
+ title = Tex(r"This is some \LaTeX")
1478
+ basel = MathTex(r"\sum_{n=1}^\infty \frac{1}{n^2} = \frac{\pi^2}{6}")
1479
+ VGroup(title, basel).arrange(DOWN)
1480
+ self.play(
1481
+ Write(title),
1482
+ FadeIn(basel, shift=DOWN),
1483
+ )
1484
+ self.wait()
1485
+
1486
+ transform_title = Tex("That was a transform")
1487
+ transform_title.to_corner(UP + LEFT)
1488
+ self.play(
1489
+ Transform(title, transform_title),
1490
+ LaggedStart(*[FadeOut(obj, shift=DOWN) for obj in basel]),
1491
+ )
1492
+ self.wait()
1493
+
1494
+ grid = NumberPlane()
1495
+ grid_title = Tex("This is a grid", font_size=72)
1496
+ grid_title.move_to(transform_title)
1497
+
1498
+ self.add(grid, grid_title) # Make sure title is on top of grid
1499
+ self.play(
1500
+ FadeOut(title),
1501
+ FadeIn(grid_title, shift=UP),
1502
+ Create(grid, run_time=3, lag_ratio=0.1),
1503
+ )
1504
+ self.wait()
1505
+
1506
+ grid_transform_title = Tex(
1507
+ r"That was a non-linear function \\ applied to the grid"
1508
+ )
1509
+ grid_transform_title.move_to(grid_title, UL)
1510
+ grid.prepare_for_nonlinear_transform()
1511
+ self.play(
1512
+ grid.animate.apply_function(
1513
+ lambda p: p
1514
+ + np.array(
1515
+ [
1516
+ np.sin(p[1]),
1517
+ np.sin(p[0]),
1518
+ 0,
1519
+ ]
1520
+ )
1521
+ ),
1522
+ run_time=3,
1523
+ )
1524
+ self.wait()
1525
+ self.play(Transform(grid_title, grid_transform_title))
1526
+ self.wait()
1527
+ ```
1528
+
1529
+ <pre data-manim-binder data-manim-classname="OpeningManim">
1530
+ class OpeningManim(Scene):
1531
+ def construct(self):
1532
+ title = Tex(r"This is some \\LaTeX")
1533
+ basel = MathTex(r"\\sum_{n=1}^\\infty \\frac{1}{n^2} = \\frac{\\pi^2}{6}")
1534
+ VGroup(title, basel).arrange(DOWN)
1535
+ self.play(
1536
+ Write(title),
1537
+ FadeIn(basel, shift=DOWN),
1538
+ )
1539
+ self.wait()
1540
+
1541
+ transform_title = Tex("That was a transform")
1542
+ transform_title.to_corner(UP + LEFT)
1543
+ self.play(
1544
+ Transform(title, transform_title),
1545
+ LaggedStart(\*[FadeOut(obj, shift=DOWN) for obj in basel]),
1546
+ )
1547
+ self.wait()
1548
+
1549
+ grid = NumberPlane()
1550
+ grid_title = Tex("This is a grid", font_size=72)
1551
+ grid_title.move_to(transform_title)
1552
+
1553
+ self.add(grid, grid_title) # Make sure title is on top of grid
1554
+ self.play(
1555
+ FadeOut(title),
1556
+ FadeIn(grid_title, shift=UP),
1557
+ Create(grid, run_time=3, lag_ratio=0.1),
1558
+ )
1559
+ self.wait()
1560
+
1561
+ grid_transform_title = Tex(
1562
+ r"That was a non-linear function \\\\ applied to the grid"
1563
+ )
1564
+ grid_transform_title.move_to(grid_title, UL)
1565
+ grid.prepare_for_nonlinear_transform()
1566
+ self.play(
1567
+ grid.animate.apply_function(
1568
+ lambda p: p
1569
+ + np.array(
1570
+ [
1571
+ np.sin(p[1]),
1572
+ np.sin(p[0]),
1573
+ 0,
1574
+ ]
1575
+ )
1576
+ ),
1577
+ run_time=3,
1578
+ )
1579
+ self.wait()
1580
+ self.play(Transform(grid_title, grid_transform_title))
1581
+ self.wait()
1582
+
1583
+ </pre>
1584
+
1585
+ References: [`Tex`](reference/manim.mobject.text.tex_mobject.Tex.md#manim.mobject.text.tex_mobject.Tex) [`MathTex`](reference/manim.mobject.text.tex_mobject.MathTex.md#manim.mobject.text.tex_mobject.MathTex) [`Write`](reference/manim.animation.creation.Write.md#manim.animation.creation.Write) [`FadeIn`](reference/manim.animation.fading.FadeIn.md#manim.animation.fading.FadeIn) [`LaggedStart`](reference/manim.animation.composition.LaggedStart.md#manim.animation.composition.LaggedStart) [`NumberPlane`](reference/manim.mobject.graphing.coordinate_systems.NumberPlane.md#manim.mobject.graphing.coordinate_systems.NumberPlane) [`Create`](reference/manim.animation.creation.Create.md#manim.animation.creation.Create) `prepare_for_nonlinear_transform()`
1586
+
1587
+ </div><div id="sinecurveunitcircle" class="admonition admonition-manim-example">
1588
+ <p class="admonition-title">Example: SineCurveUnitCircle <a class="headerlink" href="#sinecurveunitcircle">¶</a></p><video
1589
+ class="manim-video"
1590
+ controls
1591
+ loop
1592
+ autoplay
1593
+ src="./SineCurveUnitCircle-1.mp4">
1594
+ </video>
1595
+ ```python
1596
+ from manim import *
1597
+
1598
+ class SineCurveUnitCircle(Scene):
1599
+ # contributed by heejin_park, https://infograph.tistory.com/230
1600
+ def construct(self):
1601
+ self.show_axis()
1602
+ self.show_circle()
1603
+ self.move_dot_and_draw_curve()
1604
+ self.wait()
1605
+
1606
+ def show_axis(self):
1607
+ x_start = np.array([-6,0,0])
1608
+ x_end = np.array([6,0,0])
1609
+
1610
+ y_start = np.array([-4,-2,0])
1611
+ y_end = np.array([-4,2,0])
1612
+
1613
+ x_axis = Line(x_start, x_end)
1614
+ y_axis = Line(y_start, y_end)
1615
+
1616
+ self.add(x_axis, y_axis)
1617
+ self.add_x_labels()
1618
+
1619
+ self.origin_point = np.array([-4,0,0])
1620
+ self.curve_start = np.array([-3,0,0])
1621
+
1622
+ def add_x_labels(self):
1623
+ x_labels = [
1624
+ MathTex(r"\pi"), MathTex(r"2 \pi"),
1625
+ MathTex(r"3 \pi"), MathTex(r"4 \pi"),
1626
+ ]
1627
+
1628
+ for i in range(len(x_labels)):
1629
+ x_labels[i].next_to(np.array([-1 + 2*i, 0, 0]), DOWN)
1630
+ self.add(x_labels[i])
1631
+
1632
+ def show_circle(self):
1633
+ circle = Circle(radius=1)
1634
+ circle.move_to(self.origin_point)
1635
+ self.add(circle)
1636
+ self.circle = circle
1637
+
1638
+ def move_dot_and_draw_curve(self):
1639
+ orbit = self.circle
1640
+ origin_point = self.origin_point
1641
+
1642
+ dot = Dot(radius=0.08, color=YELLOW)
1643
+ dot.move_to(orbit.point_from_proportion(0))
1644
+ self.t_offset = 0
1645
+ rate = 0.25
1646
+
1647
+ def go_around_circle(mob, dt):
1648
+ self.t_offset += (dt * rate)
1649
+ # print(self.t_offset)
1650
+ mob.move_to(orbit.point_from_proportion(self.t_offset % 1))
1651
+
1652
+ def get_line_to_circle():
1653
+ return Line(origin_point, dot.get_center(), color=BLUE)
1654
+
1655
+ def get_line_to_curve():
1656
+ x = self.curve_start[0] + self.t_offset * 4
1657
+ y = dot.get_center()[1]
1658
+ return Line(dot.get_center(), np.array([x,y,0]), color=YELLOW_A, stroke_width=2 )
1659
+
1660
+
1661
+ self.curve = VGroup()
1662
+ self.curve.add(Line(self.curve_start,self.curve_start))
1663
+ def get_curve():
1664
+ last_line = self.curve[-1]
1665
+ x = self.curve_start[0] + self.t_offset * 4
1666
+ y = dot.get_center()[1]
1667
+ new_line = Line(last_line.get_end(),np.array([x,y,0]), color=YELLOW_D)
1668
+ self.curve.add(new_line)
1669
+
1670
+ return self.curve
1671
+
1672
+ dot.add_updater(go_around_circle)
1673
+
1674
+ origin_to_circle_line = always_redraw(get_line_to_circle)
1675
+ dot_to_curve_line = always_redraw(get_line_to_curve)
1676
+ sine_curve_line = always_redraw(get_curve)
1677
+
1678
+ self.add(dot)
1679
+ self.add(orbit, origin_to_circle_line, dot_to_curve_line, sine_curve_line)
1680
+ self.wait(8.5)
1681
+
1682
+ dot.remove_updater(go_around_circle)
1683
+ ```
1684
+
1685
+ <pre data-manim-binder data-manim-classname="SineCurveUnitCircle">
1686
+ class SineCurveUnitCircle(Scene):
1687
+ # contributed by heejin_park, https://infograph.tistory.com/230
1688
+ def construct(self):
1689
+ self.show_axis()
1690
+ self.show_circle()
1691
+ self.move_dot_and_draw_curve()
1692
+ self.wait()
1693
+
1694
+ def show_axis(self):
1695
+ x_start = np.array([-6,0,0])
1696
+ x_end = np.array([6,0,0])
1697
+
1698
+ y_start = np.array([-4,-2,0])
1699
+ y_end = np.array([-4,2,0])
1700
+
1701
+ x_axis = Line(x_start, x_end)
1702
+ y_axis = Line(y_start, y_end)
1703
+
1704
+ self.add(x_axis, y_axis)
1705
+ self.add_x_labels()
1706
+
1707
+ self.origin_point = np.array([-4,0,0])
1708
+ self.curve_start = np.array([-3,0,0])
1709
+
1710
+ def add_x_labels(self):
1711
+ x_labels = [
1712
+ MathTex(r"\\pi"), MathTex(r"2 \\pi"),
1713
+ MathTex(r"3 \\pi"), MathTex(r"4 \\pi"),
1714
+ ]
1715
+
1716
+ for i in range(len(x_labels)):
1717
+ x_labels[i].next_to(np.array([-1 + 2\*i, 0, 0]), DOWN)
1718
+ self.add(x_labels[i])
1719
+
1720
+ def show_circle(self):
1721
+ circle = Circle(radius=1)
1722
+ circle.move_to(self.origin_point)
1723
+ self.add(circle)
1724
+ self.circle = circle
1725
+
1726
+ def move_dot_and_draw_curve(self):
1727
+ orbit = self.circle
1728
+ origin_point = self.origin_point
1729
+
1730
+ dot = Dot(radius=0.08, color=YELLOW)
1731
+ dot.move_to(orbit.point_from_proportion(0))
1732
+ self.t_offset = 0
1733
+ rate = 0.25
1734
+
1735
+ def go_around_circle(mob, dt):
1736
+ self.t_offset += (dt \* rate)
1737
+ # print(self.t_offset)
1738
+ mob.move_to(orbit.point_from_proportion(self.t_offset % 1))
1739
+
1740
+ def get_line_to_circle():
1741
+ return Line(origin_point, dot.get_center(), color=BLUE)
1742
+
1743
+ def get_line_to_curve():
1744
+ x = self.curve_start[0] + self.t_offset \* 4
1745
+ y = dot.get_center()[1]
1746
+ return Line(dot.get_center(), np.array([x,y,0]), color=YELLOW_A, stroke_width=2 )
1747
+
1748
+
1749
+ self.curve = VGroup()
1750
+ self.curve.add(Line(self.curve_start,self.curve_start))
1751
+ def get_curve():
1752
+ last_line = self.curve[-1]
1753
+ x = self.curve_start[0] + self.t_offset \* 4
1754
+ y = dot.get_center()[1]
1755
+ new_line = Line(last_line.get_end(),np.array([x,y,0]), color=YELLOW_D)
1756
+ self.curve.add(new_line)
1757
+
1758
+ return self.curve
1759
+
1760
+ dot.add_updater(go_around_circle)
1761
+
1762
+ origin_to_circle_line = always_redraw(get_line_to_circle)
1763
+ dot_to_curve_line = always_redraw(get_line_to_curve)
1764
+ sine_curve_line = always_redraw(get_curve)
1765
+
1766
+ self.add(dot)
1767
+ self.add(orbit, origin_to_circle_line, dot_to_curve_line, sine_curve_line)
1768
+ self.wait(8.5)
1769
+
1770
+ dot.remove_updater(go_around_circle)
1771
+
1772
+ </pre>
1773
+
1774
+ References: [`MathTex`](reference/manim.mobject.text.tex_mobject.MathTex.md#manim.mobject.text.tex_mobject.MathTex) [`Circle`](reference/manim.mobject.geometry.arc.Circle.md#manim.mobject.geometry.arc.Circle) [`Dot`](reference/manim.mobject.geometry.arc.Dot.md#manim.mobject.geometry.arc.Dot) [`Line`](reference/manim.mobject.geometry.line.Line.md#manim.mobject.geometry.line.Line) [`VGroup`](reference/manim.mobject.types.vectorized_mobject.VGroup.md#manim.mobject.types.vectorized_mobject.VGroup) [`always_redraw()`](reference/manim.animation.updaters.mobject_update_utils.md#manim.animation.updaters.mobject_update_utils.always_redraw) [`add_updater()`](reference/manim.mobject.mobject.Mobject.md#manim.mobject.mobject.Mobject.add_updater) [`remove_updater()`](reference/manim.mobject.mobject.Mobject.md#manim.mobject.mobject.Mobject.remove_updater)
1775
+
1776
+ </div>
data/rag/manim_docs/manim_core/docs/guides/.DS_Store ADDED
Binary file (6.15 kB). View file
 
data/rag/manim_docs/manim_core/docs/guides/add_voiceovers.md ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Adding Voiceovers to Videos
2
+
3
+ Creating a full-fledged video with voiceovers is a bit more involved than
4
+ creating purely visual Manim scenes. One has to use [a video editing
5
+ program](https://en.wikipedia.org/wiki/List_of_video_editing_software)
6
+ to add the voiceovers after the video has been rendered. This process
7
+ can be difficult and time-consuming, since it requires a lot of planning
8
+ and preparation.
9
+
10
+ To ease the process of adding voiceovers to videos, we have created
11
+ [Manim Voiceover](https://voiceover.manim.community), a plugin
12
+ that lets you add voiceovers to scenes directly in Python. To install it, run
13
+
14
+ ```bash
15
+ pip install "manim-voiceover[azure,gtts]"
16
+ ```
17
+
18
+ Visit [the installation page](https://voiceover.manim.community/en/latest/installation.html)
19
+ for more details on how to install Manim Voiceover.
20
+
21
+ ## Basic Usage
22
+
23
+ Manim Voiceover lets you …
24
+
25
+ - Add voiceovers to Manim videos directly in Python, without having to use a video editor.
26
+ - Record voiceovers with your microphone during rendering through a simple command line interface.
27
+ - Develop animations with auto-generated AI voices from various free and proprietary services.
28
+
29
+ It provides a very simple API that lets you specify your voiceover script
30
+ and then record it during rendering:
31
+
32
+ ```python
33
+ from manim import *
34
+ from manim_voiceover import VoiceoverScene
35
+ from manim_voiceover.services.recorder import RecorderService
36
+
37
+
38
+ # Simply inherit from VoiceoverScene instead of Scene to get all the
39
+ # voiceover functionality.
40
+ class RecorderExample(VoiceoverScene):
41
+ def construct(self):
42
+ # You can choose from a multitude of TTS services,
43
+ # or in this example, record your own voice:
44
+ self.set_speech_service(RecorderService())
45
+
46
+ circle = Circle()
47
+
48
+ # Surround animation sections with with-statements:
49
+ with self.voiceover(text="This circle is drawn as I speak.") as tracker:
50
+ self.play(Create(circle), run_time=tracker.duration)
51
+ # The duration of the animation is received from the audio file
52
+ # and passed to the tracker automatically.
53
+
54
+ # This part will not start playing until the previous voiceover is finished.
55
+ with self.voiceover(text="Let's shift it to the left 2 units.") as tracker:
56
+ self.play(circle.animate.shift(2 * LEFT), run_time=tracker.duration)
57
+ ```
58
+
59
+ To get started with Manim Voiceover,
60
+ visit the [Quick Start Guide](https://voiceover.manim.community/en/latest/quickstart.html).
61
+
62
+ Visit the [Example Gallery](https://voiceover.manim.community/en/latest/examples.html)
63
+ to see some examples of Manim Voiceover in action.
data/rag/manim_docs/manim_core/docs/guides/deep_dive.md ADDED
@@ -0,0 +1,1004 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # A deep dive into Manim’s internals
2
+
3
+ **Author:** [Benjamin Hackl](https://benjamin-hackl.at)
4
+
5
+ ## Introduction
6
+
7
+ Manim can be a wonderful library, if it behaves the way you would like it to,
8
+ and/or the way you expect it to. Unfortunately, this is not always the case
9
+ (as you probably know if you have played with some manimations yourself already).
10
+ To understand where things *go wrong*, digging through the library’s source code
11
+ is sometimes the only option – but in order to do that, you need to know where
12
+ to start digging.
13
+
14
+ This article is intended as some sort of life line through the render process.
15
+ We aim to give an appropriate amount of detail describing what happens when
16
+ Manim reads your scene code and produces the corresponding animation. Throughout
17
+ this article, we will focus on the following toy example:
18
+
19
+ ```default
20
+ from manim import *
21
+
22
+ class ToyExample(Scene):
23
+ def construct(self):
24
+ orange_square = Square(color=ORANGE, fill_opacity=0.5)
25
+ blue_circle = Circle(color=BLUE, fill_opacity=0.5)
26
+ self.add(orange_square)
27
+ self.play(ReplacementTransform(orange_square, blue_circle, run_time=3))
28
+ small_dot = Dot()
29
+ small_dot.add_updater(lambda mob: mob.next_to(blue_circle, DOWN))
30
+ self.play(Create(small_dot))
31
+ self.play(blue_circle.animate.shift(RIGHT))
32
+ self.wait()
33
+ self.play(FadeOut(blue_circle, small_dot))
34
+ ```
35
+
36
+ Before we go into details or even look at the rendered output of this scene,
37
+ let us first describe verbally what happens in this *manimation*. In the first
38
+ three lines of the `construct` method, a [`Square`](../reference/manim.mobject.geometry.polygram.Square.md#manim.mobject.geometry.polygram.Square) and a [`Circle`](../reference/manim.mobject.geometry.arc.Circle.md#manim.mobject.geometry.arc.Circle)
39
+ are initialized, then the square is added to the scene. The first frame of the
40
+ rendered output should thus show an orange square.
41
+
42
+ Then the actual animations happen: the square first transforms into a circle,
43
+ then a [`Dot`](../reference/manim.mobject.geometry.arc.Dot.md#manim.mobject.geometry.arc.Dot) is created (Where do you guess the dot is located when
44
+ it is first added to the scene? Answering this already requires detailed
45
+ knowledge about the render process.). The dot has an updater attached to it, and
46
+ as the circle moves right, the dot moves with it. In the end, all mobjects are
47
+ faded out.
48
+
49
+ Actually rendering the code yields the following video:
50
+
51
+ <video
52
+ class="manim-video"
53
+ controls
54
+ loop
55
+ autoplay
56
+ src="./ToyExample-1.mp4">
57
+ </video>
58
+
59
+ For this example, the output (fortunately) coincides with our expectations.
60
+
61
+ ## Overview
62
+
63
+ Because there is a lot of information in this article, here is a brief overview
64
+ discussing the contents of the following chapters on a very high level.
65
+
66
+ - [Preliminaries](): In this chapter we unravel all the steps that take place
67
+ to prepare a scene for rendering; right until the point where the user-overridden
68
+ `construct` method is ran. This includes a brief discussion on using Manim’s CLI
69
+ versus other means of rendering (e.g., via Jupyter notebooks, or in your Python
70
+ script by calling the [`Scene.render()`](../reference/manim.scene.scene.Scene.md#manim.scene.scene.Scene.render) method yourself).
71
+ - [Mobject Initialization](): For the second chapter we dive into creating and handling
72
+ Mobjects, the basic elements that should be displayed in our scene.
73
+ We discuss the [`Mobject`](../reference/manim.mobject.mobject.Mobject.md#manim.mobject.mobject.Mobject) base class, how there are essentially
74
+ three different types of Mobjects, and then discuss the most important of them,
75
+ vectorized Mobjects. In particular, we describe the internal point data structure
76
+ that governs how the mechanism responsible for drawing the vectorized Mobject
77
+ to the screen sets the corresponding Bézier curves. We conclude the chapter
78
+ with a tour into [`Scene.add()`](../reference/manim.scene.scene.Scene.md#manim.scene.scene.Scene.add), the bookkeeping mechanism controlling which
79
+ mobjects should be rendered.
80
+ - [Animations and the Render Loop](): And finally, in the last chapter we walk
81
+ through the instantiation of [`Animation`](../reference/manim.animation.animation.Animation.md#manim.animation.animation.Animation) objects (the blueprints that
82
+ hold information on how Mobjects should be modified when the render loop runs),
83
+ followed by a investigation of the infamous [`Scene.play()`](../reference/manim.scene.scene.Scene.md#manim.scene.scene.Scene.play) call. We will
84
+ see that there are three relevant parts in a [`Scene.play()`](../reference/manim.scene.scene.Scene.md#manim.scene.scene.Scene.play) call;
85
+ a part in which the passed animations and keyword arguments are processed
86
+ and prepared, followed by the actual “render loop” in which the library
87
+ steps through a time line and renders frame by frame. The final part
88
+ does some post-processing to save a short video segment (“partial movie file”)
89
+ and cleanup for the next call to [`Scene.play()`](../reference/manim.scene.scene.Scene.md#manim.scene.scene.Scene.play). In the end, after all of
90
+ [`Scene.construct()`](../reference/manim.scene.scene.Scene.md#manim.scene.scene.Scene.construct) has been run, the library combines the partial movie
91
+ files to one video.
92
+
93
+ And with that, let us get *in medias res*.
94
+
95
+ ## Preliminaries
96
+
97
+ ### Importing the library
98
+
99
+ Independent of how exactly you are telling your system
100
+ to render the scene, i.e., whether you run `manim -qm -p file_name.py ToyExample`, or
101
+ whether you are rendering the scene directly from the Python script via a snippet
102
+ like
103
+
104
+ ```default
105
+ with tempconfig({"quality": "medium_quality", "preview": True}):
106
+ scene = ToyExample()
107
+ scene.render()
108
+ ```
109
+
110
+ or whether you are rendering the code in a Jupyter notebook, you are still telling your
111
+ python interpreter to import the library. The usual pattern used to do this is
112
+
113
+ ```default
114
+ from manim import *
115
+ ```
116
+
117
+ which (while being a debatable strategy in general) imports a lot of classes and
118
+ functions shipped with the library and makes them available in your global name space.
119
+ I explicitly avoided stating that it imports **all** classes and functions of the
120
+ library, because it does not do that: Manim makes use of the practice described
121
+ in [Section 6.4.1 of the Python tutorial](https://docs.python.org/3/tutorial/modules.html#importing-from-a-package),
122
+ and all module members that should be exposed to the user upon running the `*`-import
123
+ are explicitly declared in the `__all__` variable of the module.
124
+
125
+ Manim also uses this strategy internally: taking a peek at the file that is run when
126
+ the import is called, `__init__.py` (see
127
+ [here](https://github.com/ManimCommunity/manim/blob/main/manim/__init__.py)),
128
+ you will notice that most of the code in that module is concerned with importing
129
+ members from various different submodules, again using `*`-imports.
130
+
131
+ In that file, there is one particular import at the beginning of the file however,
132
+ namely:
133
+
134
+ ```default
135
+ from ._config import *
136
+ ```
137
+
138
+ This initializes Manim’s global configuration system, which is used in various places
139
+ throughout the library. After the library runs this line, the current configuration
140
+ options are set. The code in there takes care of reading the options in your `.cfg`
141
+ files (all users have at least the global one that is shipped with the library)
142
+ as well as correctly handling command line arguments (if you used the CLI to render).
143
+
144
+ You can read more about the config system in the
145
+ [corresponding thematic guide](configuration.md), and if you are interested in learning
146
+ more about the internals of the configuration system and how it is initialized,
147
+ follow the code flow starting in [the config module’s init file](https://github.com/ManimCommunity/manim/blob/main/manim/_config/__init__.py).
148
+
149
+ Now that the library is imported, we can turn our attention to the next step:
150
+ reading your scene code (which is not particularly exciting, Python just creates
151
+ a new class `ToyExample` based on our code; Manim is virtually not involved
152
+ in that step, with the exception that `ToyExample` inherits from `Scene`).
153
+
154
+ However, with the `ToyExample` class created and ready to go, there is a new
155
+ excellent question to answer: how is the code in our `construct` method
156
+ actually executed?
157
+
158
+ ### Scene instantiation and rendering
159
+
160
+ The answer to this question depends on how exactly you are running the code.
161
+ To make things a bit clearer, let us first consider the case that you
162
+ have created a file `toy_example.py` which looks like this:
163
+
164
+ ```default
165
+ from manim import *
166
+
167
+ class ToyExample(Scene):
168
+ def construct(self):
169
+ orange_square = Square(color=ORANGE, fill_opacity=0.5)
170
+ blue_circle = Circle(color=BLUE, fill_opacity=0.5)
171
+ self.add(orange_square)
172
+ self.play(ReplacementTransform(orange_square, blue_circle, run_time=3))
173
+ small_dot = Dot()
174
+ small_dot.add_updater(lambda mob: mob.next_to(blue_circle, DOWN))
175
+ self.play(Create(small_dot))
176
+ self.play(blue_circle.animate.shift(RIGHT))
177
+ self.wait()
178
+ self.play(FadeOut(blue_circle, small_dot))
179
+
180
+ with tempconfig({"quality": "medium_quality", "preview": True}):
181
+ scene = ToyExample()
182
+ scene.render()
183
+ ```
184
+
185
+ With such a file, the desired scene is rendered by simply running this Python
186
+ script via `python toy_example.py`. Then, as described above, the library
187
+ is imported and Python has read and defined the `ToyExample` class (but,
188
+ read carefully: *no instance of this class has been created yet*).
189
+
190
+ At this point, the interpreter is about to enter the `tempconfig` context
191
+ manager. Even if you have not seen Manim’s `tempconfig` before, its name
192
+ already suggests what it does: it creates a copy of the current state of the
193
+ configuration, applies the changes to the key-value pairs in the passed
194
+ dictionary, and upon leaving the context the original version of the
195
+ configuration is restored. TL;DR: it provides a fancy way of temporarily setting
196
+ configuration options.
197
+
198
+ Inside the context manager, two things happen: an actual `ToyExample`-scene
199
+ object is instantiated, and the `render` method is called. Every way of using
200
+ Manim ultimately does something along of these lines, the library always instantiates
201
+ the scene object and then calls its `render` method. To illustrate that this
202
+ really is the case, let us briefly look at the two most common ways of rendering
203
+ scenes:
204
+
205
+ **Command Line Interface.** When using the CLI and running the command
206
+ `manim -qm -p toy_example.py ToyExample` in your terminal, the actual
207
+ entry point is Manim’s `__main__.py` file (located
208
+ [here](https://github.com/ManimCommunity/manim/blob/main/manim/__main__.py).
209
+ Manim uses [Click](https://click.palletsprojects.com/en/8.0.x/) to implement
210
+ the command line interface, and the corresponding code is located in Manim’s
211
+ `cli` module ([https://github.com/ManimCommunity/manim/tree/main/manim/cli](https://github.com/ManimCommunity/manim/tree/main/manim/cli)).
212
+ The corresponding code creating the scene class and calling its render method
213
+ is located [here](https://github.com/ManimCommunity/manim/blob/ac1ee9a683ce8b92233407351c681f7d71a4f2db/manim/cli/render/commands.py#L139-L141).
214
+
215
+ **Jupyter notebooks.** In Jupyter notebooks, the communication with the library
216
+ is handled by the `%%manim` magic command, which is implemented in the
217
+ `manim.utils.ipython_magic` module. There is
218
+ [`some documentation`](../reference/manim.utils.ipython_magic.ManimMagic.md#manim.utils.ipython_magic.ManimMagic.manim) available for the magic command,
219
+ and the code creating the scene class and calling its render method is located
220
+ [here](https://github.com/ManimCommunity/manim/blob/ac1ee9a683ce8b92233407351c681f7d71a4f2db/manim/utils/ipython_magic.py#L137-L138).
221
+
222
+ Now that we know that either way, a [`Scene`](../reference/manim.scene.scene.Scene.md#manim.scene.scene.Scene) object is created, let us investigate
223
+ what Manim does when that happens. When instantiating our scene object
224
+
225
+ ```default
226
+ scene = ToyExample()
227
+ ```
228
+
229
+ the `Scene.__init__` method is called, given that we did not implement our own initialization
230
+ method. Inspecting the corresponding code (see
231
+ [here](https://github.com/ManimCommunity/manim/blob/main/manim/scene/scene.py))
232
+ reveals that `Scene.__init__` first sets several attributes of the scene objects that do not
233
+ depend on any configuration options set in `config`. Then the scene inspects the value of
234
+ `config.renderer`, and based on its value, either instantiates a `CairoRenderer` or an
235
+ `OpenGLRenderer` object and assigns it to its `renderer` attribute.
236
+
237
+ The scene then asks its renderer to initialize the scene by calling
238
+
239
+ ```default
240
+ self.renderer.init_scene(self)
241
+ ```
242
+
243
+ Inspecting both the default Cairo renderer and the OpenGL renderer shows that the `init_scene`
244
+ method effectively makes the renderer instantiate a [`SceneFileWriter`](../reference/manim.scene.scene_file_writer.SceneFileWriter.md#manim.scene.scene_file_writer.SceneFileWriter) object, which
245
+ basically is Manim’s interface to `libav` (FFMPEG) and actually writes the movie file. The Cairo
246
+ renderer (see the implementation [here](https://github.com/ManimCommunity/manim/blob/main/manim/renderer/cairo_renderer.py)) does not require any further initialization. The OpenGL renderer
247
+ does some additional setup to enable the realtime rendering preview window, which we do not go
248
+ into detail further here.
249
+
250
+ #### WARNING
251
+ Currently, there is a lot of interplay between a scene and its renderer. This is a flaw
252
+ in Manim’s current architecture, and we are working on reducing this interdependency to
253
+ achieve a less convoluted code flow.
254
+
255
+ After the renderer has been instantiated and initialized its file writer, the scene populates
256
+ further initial attributes (notable mention: the `mobjects` attribute which keeps track
257
+ of the mobjects that have been added to the scene). It is then done with its instantiation
258
+ and ready to be rendered.
259
+
260
+ The rest of this article is concerned with the last line in our toy example script:
261
+
262
+ ```default
263
+ scene.render()
264
+ ```
265
+
266
+ This is where the actual magic happens.
267
+
268
+ Inspecting the [implementation of the render method](https://github.com/ManimCommunity/manim/blob/df1a60421ea1119cbbbd143ef288d294851baaac/manim/scene/scene.py#L211)
269
+ reveals that there are several hooks that can be used for pre- or postprocessing
270
+ a scene. Unsurprisingly, [`Scene.render()`](../reference/manim.scene.scene.Scene.md#manim.scene.scene.Scene.render) describes the full *render cycle*
271
+ of a scene. During this life cycle, there are three custom methods whose base
272
+ implementation is empty and that can be overwritten to suit your purposes. In
273
+ the order they are called, these customizable methods are:
274
+
275
+ - [`Scene.setup()`](../reference/manim.scene.scene.Scene.md#manim.scene.scene.Scene.setup), which is intended for preparing and, well, *setting up*
276
+ the scene for your animation (e.g., adding initial mobjects, assigning custom
277
+ attributes to your scene class, etc.),
278
+ - [`Scene.construct()`](../reference/manim.scene.scene.Scene.md#manim.scene.scene.Scene.construct), which is the *script* for your screen play and
279
+ contains programmatic descriptions of your animations, and
280
+ - [`Scene.tear_down()`](../reference/manim.scene.scene.Scene.md#manim.scene.scene.Scene.tear_down), which is intended for any operations you might
281
+ want to run on the scene after the last frame has already been rendered
282
+ (for example, this could run some code that generates a custom thumbnail
283
+ for the video based on the state of the objects in the scene – this
284
+ hook is more relevant for situations where Manim is used within other
285
+ Python scripts).
286
+
287
+ After these three methods are run, the animations have been fully rendered,
288
+ and Manim calls `CairoRenderer.scene_finished()` to gracefully
289
+ complete the rendering process. This checks whether any animations have been
290
+ played – and if so, it tells the [`SceneFileWriter`](../reference/manim.scene.scene_file_writer.SceneFileWriter.md#manim.scene.scene_file_writer.SceneFileWriter) to close the output
291
+ file. If not, Manim assumes that a static image should be output
292
+ which it then renders using the same strategy by calling the render loop
293
+ (see below) once.
294
+
295
+ **Back in our toy example,** the call to [`Scene.render()`](../reference/manim.scene.scene.Scene.md#manim.scene.scene.Scene.render) first
296
+ triggers [`Scene.setup()`](../reference/manim.scene.scene.Scene.md#manim.scene.scene.Scene.setup) (which only consists of `pass`), followed by
297
+ a call of [`Scene.construct()`](../reference/manim.scene.scene.Scene.md#manim.scene.scene.Scene.construct). At this point, our *animation script*
298
+ is run, starting with the initialization of `orange_square`.
299
+
300
+ ## Mobject Initialization
301
+
302
+ Mobjects are, in a nutshell, the Python objects that represent all the
303
+ *things* we want to display in our scene. Before we follow our debugger
304
+ into the depths of mobject initialization code, it makes sense to
305
+ discuss Manim’s different types of Mobjects and their basic data
306
+ structure.
307
+
308
+ ### What even is a Mobject?
309
+
310
+ [`Mobject`](../reference/manim.mobject.mobject.Mobject.md#manim.mobject.mobject.Mobject) stands for *mathematical object* or *Manim object*
311
+ (depends on who you ask 😄). The Python class [`Mobject`](../reference/manim.mobject.mobject.Mobject.md#manim.mobject.mobject.Mobject) is
312
+ the base class for all objects that should be displayed on screen.
313
+ Looking at the [initialization method](https://github.com/ManimCommunity/manim/blob/5d72d9cfa2e3dd21c844b1da807576f5a7194fda/manim/mobject/mobject.py#L94)
314
+ of [`Mobject`](../reference/manim.mobject.mobject.Mobject.md#manim.mobject.mobject.Mobject), you will find that not too much happens in there:
315
+
316
+ - some initial attribute values are assigned, like `name` (which makes the
317
+ render logs mention the name of the mobject instead of its type),
318
+ `submobjects` (initially an empty list), `color`, and some others.
319
+ - Then, two methods related to *points* are called: `reset_points`
320
+ followed by `generate_points`,
321
+ - and finally, `init_colors` is called.
322
+
323
+ Digging deeper, you will find that [`Mobject.reset_points()`](../reference/manim.mobject.mobject.Mobject.md#manim.mobject.mobject.Mobject.reset_points) simply
324
+ sets the `points` attribute of the mobject to an empty NumPy vector,
325
+ while the other two methods, [`Mobject.generate_points()`](../reference/manim.mobject.mobject.Mobject.md#manim.mobject.mobject.Mobject.generate_points) and
326
+ [`Mobject.init_colors()`](../reference/manim.mobject.mobject.Mobject.md#manim.mobject.mobject.Mobject.init_colors) are just implemented as `pass`.
327
+
328
+ This makes sense: [`Mobject`](../reference/manim.mobject.mobject.Mobject.md#manim.mobject.mobject.Mobject) is not supposed to be used as
329
+ an *actual* object that is displayed on screen; in fact the camera
330
+ (which we will discuss later in more detail; it is the class that is,
331
+ for the Cairo renderer, responsible for “taking a picture” of the
332
+ current scene) does not process “pure” [`Mobjects`](../reference/manim.mobject.mobject.Mobject.md#manim.mobject.mobject.Mobject)
333
+ in any way, they *cannot* even appear in the rendered output.
334
+
335
+ This is where different types of mobjects come into play. Roughly
336
+ speaking, the Cairo renderer setup knows three different types of
337
+ mobjects that can be rendered:
338
+
339
+ - [`ImageMobject`](../reference/manim.mobject.types.image_mobject.ImageMobject.md#manim.mobject.types.image_mobject.ImageMobject), which represent images that you can display
340
+ in your scene,
341
+ - [`PMobject`](../reference/manim.mobject.types.point_cloud_mobject.PMobject.md#manim.mobject.types.point_cloud_mobject.PMobject), which are very special mobjects used to represent
342
+ point clouds; we will not discuss them further in this guide,
343
+ - [`VMobject`](../reference/manim.mobject.types.vectorized_mobject.VMobject.md#manim.mobject.types.vectorized_mobject.VMobject), which are *vectorized mobjects*, that is, mobjects
344
+ that consist of points that are connected via curves. These are pretty
345
+ much everywhere, and we will discuss them in detail in the next section.
346
+
347
+ ### … and what are VMobjects?
348
+
349
+ As just mentioned, [`VMobjects`](../reference/manim.mobject.types.vectorized_mobject.VMobject.md#manim.mobject.types.vectorized_mobject.VMobject) represent vectorized
350
+ mobjects. To render a [`VMobject`](../reference/manim.mobject.types.vectorized_mobject.VMobject.md#manim.mobject.types.vectorized_mobject.VMobject), the camera looks at the
351
+ `points` attribute of a [`VMobject`](../reference/manim.mobject.types.vectorized_mobject.VMobject.md#manim.mobject.types.vectorized_mobject.VMobject) and divides it into sets
352
+ of four points each. Each of these sets is then used to construct a
353
+ cubic Bézier curve with the first and last entry describing the
354
+ end points of the curve (“anchors”), and the second and third entry
355
+ describing the control points in between (“handles”).
356
+
357
+ In contrast to [`Mobject`](../reference/manim.mobject.mobject.Mobject.md#manim.mobject.mobject.Mobject), [`VMobject`](../reference/manim.mobject.types.vectorized_mobject.VMobject.md#manim.mobject.types.vectorized_mobject.VMobject) can be displayed
358
+ on screen (even though, technically, it is still considered a base class).
359
+ To illustrate how points are processed, consider the following short example
360
+ of a [`VMobject`](../reference/manim.mobject.types.vectorized_mobject.VMobject.md#manim.mobject.types.vectorized_mobject.VMobject) with 8 points (and thus made out of 8/4 = 2 cubic
361
+ Bézier curves). The resulting [`VMobject`](../reference/manim.mobject.types.vectorized_mobject.VMobject.md#manim.mobject.types.vectorized_mobject.VMobject) is drawn in green.
362
+ The handles are drawn as red dots with a line to their closest anchor.
363
+
364
+ <div id="vmobjectdemo" class="admonition admonition-manim-example">
365
+ <p class="admonition-title">Example: VMobjectDemo <a class="headerlink" href="#vmobjectdemo">¶</a></p>![image](media/images/VMobjectDemo-1.png)
366
+ ```python
367
+ from manim import *
368
+
369
+ class VMobjectDemo(Scene):
370
+ def construct(self):
371
+ plane = NumberPlane()
372
+ my_vmobject = VMobject(color=GREEN)
373
+ my_vmobject.points = [
374
+ np.array([-2, -1, 0]), # start of first curve
375
+ np.array([-3, 1, 0]),
376
+ np.array([0, 3, 0]),
377
+ np.array([1, 3, 0]), # end of first curve
378
+ np.array([1, 3, 0]), # start of second curve
379
+ np.array([0, 1, 0]),
380
+ np.array([4, 3, 0]),
381
+ np.array([4, -2, 0]), # end of second curve
382
+ ]
383
+ handles = [
384
+ Dot(point, color=RED) for point in
385
+ [[-3, 1, 0], [0, 3, 0], [0, 1, 0], [4, 3, 0]]
386
+ ]
387
+ handle_lines = [
388
+ Line(
389
+ my_vmobject.points[ind],
390
+ my_vmobject.points[ind+1],
391
+ color=RED,
392
+ stroke_width=2
393
+ ) for ind in range(0, len(my_vmobject.points), 2)
394
+ ]
395
+ self.add(plane, *handles, *handle_lines, my_vmobject)
396
+ ```
397
+
398
+ <pre data-manim-binder data-manim-classname="VMobjectDemo">
399
+ class VMobjectDemo(Scene):
400
+ def construct(self):
401
+ plane = NumberPlane()
402
+ my_vmobject = VMobject(color=GREEN)
403
+ my_vmobject.points = [
404
+ np.array([-2, -1, 0]), # start of first curve
405
+ np.array([-3, 1, 0]),
406
+ np.array([0, 3, 0]),
407
+ np.array([1, 3, 0]), # end of first curve
408
+ np.array([1, 3, 0]), # start of second curve
409
+ np.array([0, 1, 0]),
410
+ np.array([4, 3, 0]),
411
+ np.array([4, -2, 0]), # end of second curve
412
+ ]
413
+ handles = [
414
+ Dot(point, color=RED) for point in
415
+ [[-3, 1, 0], [0, 3, 0], [0, 1, 0], [4, 3, 0]]
416
+ ]
417
+ handle_lines = [
418
+ Line(
419
+ my_vmobject.points[ind],
420
+ my_vmobject.points[ind+1],
421
+ color=RED,
422
+ stroke_width=2
423
+ ) for ind in range(0, len(my_vmobject.points), 2)
424
+ ]
425
+ self.add(plane, \*handles, \*handle_lines, my_vmobject)
426
+
427
+ </pre></div>
428
+
429
+ #### WARNING
430
+ Manually setting the points of your [`VMobject`](../reference/manim.mobject.types.vectorized_mobject.VMobject.md#manim.mobject.types.vectorized_mobject.VMobject) is usually
431
+ discouraged; there are specialized methods that can take care of
432
+ that for you – but it might be relevant when implementing your own,
433
+ custom [`VMobject`](../reference/manim.mobject.types.vectorized_mobject.VMobject.md#manim.mobject.types.vectorized_mobject.VMobject).
434
+
435
+ ### Squares and Circles: back to our Toy Example
436
+
437
+ With a basic understanding of different types of mobjects,
438
+ and an idea of how vectorized mobjects are built we can now
439
+ come back to our toy example and the execution of the
440
+ [`Scene.construct()`](../reference/manim.scene.scene.Scene.md#manim.scene.scene.Scene.construct) method. In the first two lines
441
+ of our animation script, the `orange_square` and the
442
+ `blue_circle` are initialized.
443
+
444
+ When creating the orange square by running
445
+
446
+ ```default
447
+ Square(color=ORANGE, fill_opacity=0.5)
448
+ ```
449
+
450
+ the initialization method of [`Square`](../reference/manim.mobject.geometry.polygram.Square.md#manim.mobject.geometry.polygram.Square),
451
+ `Square.__init__`, is called. [Looking at the
452
+ implementation](https://github.com/ManimCommunity/manim/blob/5d72d9cfa2e3dd21c844b1da807576f5a7194fda/manim/mobject/geometry/polygram.py#L607),
453
+ we can see that the `side_length` attribute of the square is set,
454
+ and then
455
+
456
+ ```default
457
+ super().__init__(height=side_length, width=side_length, **kwargs)
458
+ ```
459
+
460
+ is called. This `super` call is the Python way of calling the
461
+ initialization function of the parent class. As [`Square`](../reference/manim.mobject.geometry.polygram.Square.md#manim.mobject.geometry.polygram.Square)
462
+ inherits from [`Rectangle`](../reference/manim.mobject.geometry.polygram.Rectangle.md#manim.mobject.geometry.polygram.Rectangle), the next method called
463
+ is `Rectangle.__init__`. There, only the first three lines
464
+ are really relevant for us:
465
+
466
+ ```default
467
+ super().__init__(UR, UL, DL, DR, color=color, **kwargs)
468
+ self.stretch_to_fit_width(width)
469
+ self.stretch_to_fit_height(height)
470
+ ```
471
+
472
+ First, the initialization function of the parent class of
473
+ [`Rectangle`](../reference/manim.mobject.geometry.polygram.Rectangle.md#manim.mobject.geometry.polygram.Rectangle) – [`Polygon`](../reference/manim.mobject.geometry.polygram.Polygon.md#manim.mobject.geometry.polygram.Polygon) – is called. The
474
+ four positional arguments passed are the four corners of
475
+ the polygon: `UR` is up right (and equal to `UP + RIGHT`),
476
+ `UL` is up left (and equal to `UP + LEFT`), and so forth.
477
+ Before we follow our debugger deeper, let us observe what
478
+ happens with the constructed polygon: the remaining two lines
479
+ stretch the polygon to fit the specified width and height
480
+ such that a rectangle with the desired measurements is created.
481
+
482
+ The initialization function of [`Polygon`](../reference/manim.mobject.geometry.polygram.Polygon.md#manim.mobject.geometry.polygram.Polygon) is particularly
483
+ simple, it only calls the initialization function of its parent
484
+ class, [`Polygram`](../reference/manim.mobject.geometry.polygram.Polygram.md#manim.mobject.geometry.polygram.Polygram). There, we have almost reached the end
485
+ of the chain: [`Polygram`](../reference/manim.mobject.geometry.polygram.Polygram.md#manim.mobject.geometry.polygram.Polygram) inherits from [`VMobject`](../reference/manim.mobject.types.vectorized_mobject.VMobject.md#manim.mobject.types.vectorized_mobject.VMobject),
486
+ whose initialization function mainly sets the values of some
487
+ attributes (quite similar to `Mobject.__init__`, but more specific
488
+ to the Bézier curves that make up the mobject).
489
+
490
+ After calling the initialization function of [`VMobject`](../reference/manim.mobject.types.vectorized_mobject.VMobject.md#manim.mobject.types.vectorized_mobject.VMobject),
491
+ the constructor of [`Polygram`](../reference/manim.mobject.geometry.polygram.Polygram.md#manim.mobject.geometry.polygram.Polygram) also does something somewhat
492
+ odd: it sets the points (which, you might remember above, should
493
+ actually be set in a corresponding `generate_points` method
494
+ of [`Polygram`](../reference/manim.mobject.geometry.polygram.Polygram.md#manim.mobject.geometry.polygram.Polygram)).
495
+
496
+ #### WARNING
497
+ In several instances, the implementation of mobjects does
498
+ not really stick to all aspects of Manim’s interface. This
499
+ is unfortunate, and increasing consistency is something
500
+ that we actively work on. Help is welcome!
501
+
502
+ Without going too much into detail, [`Polygram`](../reference/manim.mobject.geometry.polygram.Polygram.md#manim.mobject.geometry.polygram.Polygram) sets its
503
+ `points` attribute via [`VMobject.start_new_path()`](../reference/manim.mobject.types.vectorized_mobject.VMobject.md#manim.mobject.types.vectorized_mobject.VMobject.start_new_path),
504
+ [`VMobject.add_points_as_corners()`](../reference/manim.mobject.types.vectorized_mobject.VMobject.md#manim.mobject.types.vectorized_mobject.VMobject.add_points_as_corners), which take care of
505
+ setting the quadruples of anchors and handles appropriately.
506
+ After the points are set, Python continues to process the
507
+ call stack until it reaches the method that was first called;
508
+ the initialization method of [`Square`](../reference/manim.mobject.geometry.polygram.Square.md#manim.mobject.geometry.polygram.Square). After this,
509
+ the square is initialized and assigned to the `orange_square`
510
+ variable.
511
+
512
+ The initialization of `blue_circle` is similar to the one of
513
+ `orange_square`, with the main difference being that the inheritance
514
+ chain of [`Circle`](../reference/manim.mobject.geometry.arc.Circle.md#manim.mobject.geometry.arc.Circle) is different. Let us briefly follow the trace
515
+ of the debugger:
516
+
517
+ The implementation of `Circle.__init__()` immediately calls
518
+ the initialization method of [`Arc`](../reference/manim.mobject.geometry.arc.Arc.md#manim.mobject.geometry.arc.Arc), as a circle in Manim
519
+ is simply an arc with an angle of $\tau = 2\pi$. When
520
+ initializing the arc, some basic attributes are set (like
521
+ `Arc.radius`, `Arc.arc_center`, `Arc.start_angle`, and
522
+ `Arc.angle`), and then the initialization method of its
523
+ parent class, [`TipableVMobject`](../reference/manim.mobject.geometry.arc.TipableVMobject.md#manim.mobject.geometry.arc.TipableVMobject), is called (which is
524
+ a rather abstract base class for mobjects which a arrow tip can
525
+ be attached to). Note that in contrast to [`Polygram`](../reference/manim.mobject.geometry.polygram.Polygram.md#manim.mobject.geometry.polygram.Polygram),
526
+ this class does **not** preemptively generate the points of the circle.
527
+
528
+ After that, things are less exciting: [`TipableVMobject`](../reference/manim.mobject.geometry.arc.TipableVMobject.md#manim.mobject.geometry.arc.TipableVMobject) again
529
+ sets some attributes relevant for adding arrow tips, and afterwards
530
+ passes to the initialization method of [`VMobject`](../reference/manim.mobject.types.vectorized_mobject.VMobject.md#manim.mobject.types.vectorized_mobject.VMobject). From there,
531
+ [`Mobject`](../reference/manim.mobject.mobject.Mobject.md#manim.mobject.mobject.Mobject) is initialized and [`Mobject.generate_points()`](../reference/manim.mobject.mobject.Mobject.md#manim.mobject.mobject.Mobject.generate_points)
532
+ is called, which actually runs the method implemented in
533
+ [`Arc.generate_points()`](../reference/manim.mobject.geometry.arc.Arc.md#manim.mobject.geometry.arc.Arc.generate_points).
534
+
535
+ After both our `orange_square` and the `blue_circle` are initialized,
536
+ the square is actually added to the scene. The [`Scene.add()`](../reference/manim.scene.scene.Scene.md#manim.scene.scene.Scene.add) method
537
+ is actually doing a few interesting things, so it is worth to dig a bit
538
+ deeper in the next section.
539
+
540
+ ### Adding Mobjects to the Scene
541
+
542
+ The code in our `construct` method that is run next is
543
+
544
+ ```default
545
+ self.add(orange_square)
546
+ ```
547
+
548
+ From a high-level point of view, [`Scene.add()`](../reference/manim.scene.scene.Scene.md#manim.scene.scene.Scene.add) adds the
549
+ `orange_square` to the list of mobjects that should be rendered,
550
+ which is stored in the `mobjects` attribute of the scene. However,
551
+ it does so in a very careful way to avoid the situation that a mobject
552
+ is being added to the scene more than once. At a first glance, this
553
+ sounds like a simple task – the problem is that `Scene.mobjects`
554
+ is not a “flat” list of mobjects, but a list of mobjects which
555
+ might contain mobjects themselves, and so on.
556
+
557
+ Stepping through the code in [`Scene.add()`](../reference/manim.scene.scene.Scene.md#manim.scene.scene.Scene.add), we see that first
558
+ it is checked whether we are currently using the OpenGL renderer
559
+ (which we are not) – adding mobjects to the scene works slightly
560
+ different (and actually easier!) for the OpenGL renderer. Then, the
561
+ code branch for the Cairo renderer is entered and the list of so-called
562
+ foreground mobjects (which are rendered on top of all other mobjects)
563
+ is added to the list of passed mobjects. This is to ensure that the
564
+ foreground mobjects will stay above of the other mobjects, even after
565
+ adding the new ones. In our case, the list of foreground mobjects
566
+ is actually empty, and nothing changes.
567
+
568
+ Next, [`Scene.restructure_mobjects()`](../reference/manim.scene.scene.Scene.md#manim.scene.scene.Scene.restructure_mobjects) is called with the list
569
+ of mobjects to be added as the `to_remove` argument, which might
570
+ sound odd at first. Practically, this ensures that mobjects are not
571
+ added twice, as mentioned above: if they were present in the scene
572
+ `Scene.mobjects` list before (even if they were contained as a
573
+ child of some other mobject), they are first removed from the list.
574
+ The way [`Scene.restructure_mobjects()`](../reference/manim.scene.scene.Scene.md#manim.scene.scene.Scene.restructure_mobjects) works is rather aggressive:
575
+ It always operates on a given list of mobjects; in the `add` method
576
+ two different lists occur: the default one, `Scene.mobjects` (no extra
577
+ keyword argument is passed), and `Scene.moving_mobjects` (which we will
578
+ discuss later in more detail). It iterates through all of the members of
579
+ the list, and checks whether any of the mobjects passed in `to_remove`
580
+ are contained as children (in any nesting level). If so, **their parent
581
+ mobject is deconstructed** and their siblings are inserted directly
582
+ one level higher. Consider the following example:
583
+
584
+ ```default
585
+ >>> from manim import Scene, Square, Circle, Group
586
+ >>> test_scene = Scene()
587
+ >>> mob1 = Square()
588
+ >>> mob2 = Circle()
589
+ >>> mob_group = Group(mob1, mob2)
590
+ >>> test_scene.add(mob_group)
591
+ <manim.scene.scene.Scene object at ...>
592
+ >>> test_scene.mobjects
593
+ [Group]
594
+ >>> test_scene.restructure_mobjects(to_remove=[mob1])
595
+ <manim.scene.scene.Scene object at ...>
596
+ >>> test_scene.mobjects
597
+ [Circle]
598
+ ```
599
+
600
+ Note that the group is disbanded and the circle moves into the
601
+ root layer of mobjects in `test_scene.mobjects`.
602
+
603
+ After the mobject list is “restructured”, the mobject to be added
604
+ are simply appended to `Scene.mobjects`. In our toy example,
605
+ the `Scene.mobjects` list is actually empty, so the
606
+ `restructure_mobjects` method does not actually do anything. The
607
+ `orange_square` is simply added to `Scene.mobjects`, and as
608
+ the aforementioned `Scene.moving_mobjects` list is, at this point,
609
+ also still empty, nothing happens and [`Scene.add()`](../reference/manim.scene.scene.Scene.md#manim.scene.scene.Scene.add) returns.
610
+
611
+ We will hear more about the `moving_mobject` list when we discuss
612
+ the render loop. Before we do that, let us look at the next line
613
+ of code in our toy example, which includes the initialization of
614
+ an animation class,
615
+
616
+ ```default
617
+ ReplacementTransform(orange_square, blue_circle, run_time=3)
618
+ ```
619
+
620
+ Hence it is time to talk about [`Animation`](../reference/manim.animation.animation.Animation.md#manim.animation.animation.Animation).
621
+
622
+ ## Animations and the Render Loop
623
+
624
+ ### Initializing animations
625
+
626
+ Before we follow the trace of the debugger, let us briefly discuss
627
+ the general structure of the (abstract) base class [`Animation`](../reference/manim.animation.animation.Animation.md#manim.animation.animation.Animation).
628
+ An animation object holds all the information necessary for the renderer
629
+ to generate the corresponding frames. Animations (in the sense of
630
+ animation objects) in Manim are *always* tied to a specific mobject;
631
+ even in the case of [`AnimationGroup`](../reference/manim.animation.composition.AnimationGroup.md#manim.animation.composition.AnimationGroup) (which you should actually
632
+ think of as an animation on a group of mobjects rather than a group
633
+ of animations). Moreover, except for in a particular special case,
634
+ the run time of animations is also fixed and known beforehand.
635
+
636
+ The initialization of animations actually is not very exciting,
637
+ `Animation.__init__()` merely sets some attributes derived
638
+ from the passed keyword arguments and additionally ensures that
639
+ the `Animation.starting_mobject` and `Animation.mobject`
640
+ attributes are populated. Once the animation is played, the
641
+ `starting_mobject` attribute holds an unmodified copy of the
642
+ mobject the animation is attached to; during the initialization
643
+ it is set to a placeholder mobject. The `mobject` attribute
644
+ is set to the mobject the animation is attached to.
645
+
646
+ Animations have a few special methods which are called during the
647
+ render loop:
648
+
649
+ - [`Animation.begin()`](../reference/manim.animation.animation.Animation.md#manim.animation.animation.Animation.begin), which is called (as hinted by its name)
650
+ at the beginning of every animation, so before the first frame
651
+ is rendered. In it, all the required setup for the animation happens.
652
+ - [`Animation.finish()`](../reference/manim.animation.animation.Animation.md#manim.animation.animation.Animation.finish) is the counterpart to the `begin` method
653
+ which is called at the end of the life cycle of the animation (after
654
+ the last frame has been rendered).
655
+ - [`Animation.interpolate()`](../reference/manim.animation.animation.Animation.md#manim.animation.animation.Animation.interpolate) is the method that updates the mobject
656
+ attached to the animation to the corresponding animation completion
657
+ percentage. For example, if in the render loop,
658
+ `some_animation.interpolate(0.5)` is called, the attached mobject
659
+ will be updated to the state where 50% of the animation are completed.
660
+
661
+ We will discuss details about these and some further animation methods
662
+ once we walk through the actual render loop. For now, we continue with
663
+ our toy example and the code that is run when initializing the
664
+ [`ReplacementTransform`](../reference/manim.animation.transform.ReplacementTransform.md#manim.animation.transform.ReplacementTransform) animation.
665
+
666
+ The initialization method of [`ReplacementTransform`](../reference/manim.animation.transform.ReplacementTransform.md#manim.animation.transform.ReplacementTransform) only
667
+ consists of a call to the constructor of its parent class,
668
+ [`Transform`](../reference/manim.animation.transform.Transform.md#manim.animation.transform.Transform), with the additional keyword argument
669
+ `replace_mobject_with_target_in_scene` set to `True`.
670
+ [`Transform`](../reference/manim.animation.transform.Transform.md#manim.animation.transform.Transform) then sets attributes that control how the
671
+ points of the starting mobject are deformed into the points of
672
+ the target mobject, and then passes on to the initialization
673
+ method of [`Animation`](../reference/manim.animation.animation.Animation.md#manim.animation.animation.Animation). Other basic properties of the
674
+ animation (like its `run_time`, the `rate_func`, etc.) are
675
+ processed there – and then the animation object is fully
676
+ initialized and ready to be played.
677
+
678
+ ### The `play` call: preparing to enter Manim’s render loop
679
+
680
+ We are finally there, the render loop is in our reach. Let us
681
+ walk through the code that is run when [`Scene.play()`](../reference/manim.scene.scene.Scene.md#manim.scene.scene.Scene.play) is called.
682
+
683
+ As you will see when inspecting the method, [`Scene.play()`](../reference/manim.scene.scene.Scene.md#manim.scene.scene.Scene.play) almost
684
+ immediately passes over to the `play` method of the renderer,
685
+ in our case `CairoRenderer.play`. The one thing [`Scene.play()`](../reference/manim.scene.scene.Scene.md#manim.scene.scene.Scene.play)
686
+ takes care of is the management of subcaptions that you might have
687
+ passed to it (see the the documentation of [`Scene.play()`](../reference/manim.scene.scene.Scene.md#manim.scene.scene.Scene.play) and
688
+ [`Scene.add_subcaption()`](../reference/manim.scene.scene.Scene.md#manim.scene.scene.Scene.add_subcaption) for more information).
689
+
690
+ #### WARNING
691
+ As has been said before, the communication between scene and renderer
692
+ is not in a very clean state at this point, so the following paragraphs
693
+ might be confusing if you don’t run a debugger and step through the
694
+ code yourself a bit.
695
+
696
+ Inside `CairoRenderer.play()`, the renderer first checks whether
697
+ it may skip rendering of the current play call. This might happen, for example,
698
+ when `-s` is passed to the CLI (i.e., only the last frame should be rendered),
699
+ or when the `-n` flag is passed and the current play call is outside of the
700
+ specified render bounds. The “skipping status” is updated in form of the
701
+ call to `CairoRenderer.update_skipping_status()`.
702
+
703
+ Next, the renderer asks the scene to process the animations in the play
704
+ call so that renderer obtains all of the information it needs. To
705
+ be more concrete, [`Scene.compile_animation_data()`](../reference/manim.scene.scene.Scene.md#manim.scene.scene.Scene.compile_animation_data) is called,
706
+ which then takes care of several things:
707
+
708
+ - The method processes all animations and the keyword arguments passed
709
+ to the initial [`Scene.play()`](../reference/manim.scene.scene.Scene.md#manim.scene.scene.Scene.play) call. In particular, this means
710
+ that it makes sure all arguments passed to the play call are actually
711
+ animations (or `.animate` syntax calls, which are also assembled to
712
+ be actual [`Animation`](../reference/manim.animation.animation.Animation.md#manim.animation.animation.Animation)-objects at that point). It also propagates
713
+ any animation-related keyword arguments (like `run_time`,
714
+ or `rate_func`) passed to `Scene.play` to each individual
715
+ animation. The processed animations are then stored in the `animations`
716
+ attribute of the scene (which the renderer later reads…).
717
+ - It adds all mobjects to which the animations that are played are
718
+ bound to to the scene (provided the animation is not an mobject-introducing
719
+ animation – for these, the addition to the scene happens later).
720
+ - In case the played animation is a [`Wait`](../reference/manim.animation.animation.Wait.md#manim.animation.animation.Wait) animation (this is the
721
+ case in a [`Scene.wait()`](../reference/manim.scene.scene.Scene.md#manim.scene.scene.Scene.wait) call), the method checks whether a static
722
+ image should be rendered, or whether the render loop should be processed
723
+ as usual (see [`Scene.should_update_mobjects()`](../reference/manim.scene.scene.Scene.md#manim.scene.scene.Scene.should_update_mobjects) for the exact conditions,
724
+ basically it checks whether there are any time-dependent updater functions
725
+ and so on).
726
+ - Finally, the method determines the total run time of the play call (which
727
+ at this point is computed as the maximum of the run times of the passed
728
+ animations). This is stored in the `duration` attribute of the scene.
729
+
730
+ After the animation data has been compiled by the scene, the renderer
731
+ continues to prepare for entering the render loop. It now checks the
732
+ skipping status which has been determined before. If the renderer can
733
+ skip this play call, it does so: it sets the current play call hash (which
734
+ we will get back to in a moment) to `None` and increases the time of the
735
+ renderer by the determined animation run time.
736
+
737
+ Otherwise, the renderer checks whether or not Manim’s caching system should
738
+ be used. The idea of the caching system is simple: for every play call, a
739
+ hash value is computed, which is then stored and upon re-rendering the scene,
740
+ the hash is generated again and checked against the stored value. If it is the
741
+ same, the cached output is reused, otherwise it is fully rerendered again.
742
+ We will not go into details of the caching system here; if you would like
743
+ to learn more, the [`get_hash_from_play_call()`](../reference/manim.utils.hashing.md#manim.utils.hashing.get_hash_from_play_call) function in the
744
+ [`utils.hashing`](../reference/manim.utils.hashing.md#module-manim.utils.hashing) module is essentially the entry point to the caching
745
+ mechanism.
746
+
747
+ In the event that the animation has to be rendered, the renderer asks
748
+ its [`SceneFileWriter`](../reference/manim.scene.scene_file_writer.SceneFileWriter.md#manim.scene.scene_file_writer.SceneFileWriter) to open an output container. The process
749
+ is started by a call to `libav` and opens a container to which rendered
750
+ raw frames can be written. As long as the output is open, the container
751
+ can be accessed via the `output_container` attribute of the file writer.
752
+ With the writing process in place, the renderer then asks the scene
753
+ to “begin” the animations.
754
+
755
+ First, it literally *begins* all of the animations by calling their
756
+ setup methods ([`Animation._setup_scene()`](../reference/manim.animation.animation.Animation.md#manim.animation.animation.Animation._setup_scene), [`Animation.begin()`](../reference/manim.animation.animation.Animation.md#manim.animation.animation.Animation.begin)).
757
+ In doing so, the mobjects that are newly introduced by an animation
758
+ (like via [`Create`](../reference/manim.animation.creation.Create.md#manim.animation.creation.Create) etc.) are added to the scene. Furthermore, the
759
+ animation suspends updater functions being called on its mobject, and
760
+ it sets its mobject to the state that corresponds to the first frame
761
+ of the animation.
762
+
763
+ After this has happened for all animations in the current `play` call,
764
+ the Cairo renderer determines which of the scene’s mobjects can be
765
+ painted statically to the background, and which ones have to be
766
+ redrawn every frame. It does so by calling
767
+ `Scene.get_moving_and_static_mobjects()`, and the resulting
768
+ partition of mobjects is stored in the corresponding `moving_mobjects`
769
+ and `static_mobjects` attributes.
770
+
771
+ #### NOTE
772
+ The mechanism that determines static and moving mobjects is
773
+ specific for the Cairo renderer, the OpenGL renderer works differently.
774
+ Basically, moving mobjects are determined by checking whether they,
775
+ any of their children, or any of the mobjects “below” them (in the
776
+ sense of the order in which mobjects are processed in the scene)
777
+ either have an update function attached, or whether they appear
778
+ in one of the current animations. See the implementation of
779
+ [`Scene.get_moving_mobjects()`](../reference/manim.scene.scene.Scene.md#manim.scene.scene.Scene.get_moving_mobjects) for more details.
780
+
781
+ Up to this very point, we did not actually render any (partial)
782
+ image or movie files from the scene yet. This is, however, about to change.
783
+ Before we enter the render loop, let us briefly revisit our toy
784
+ example and discuss how the generic [`Scene.play()`](../reference/manim.scene.scene.Scene.md#manim.scene.scene.Scene.play) call
785
+ setup looks like there.
786
+
787
+ For the call that plays the [`ReplacementTransform`](../reference/manim.animation.transform.ReplacementTransform.md#manim.animation.transform.ReplacementTransform), there
788
+ is no subcaption to be taken care of. The renderer then asks
789
+ the scene to compile the animation data: the passed argument
790
+ already is an animation (no additional preparations needed),
791
+ there is no need for processing any keyword arguments (as
792
+ we did not specify any additional ones to `play`). The
793
+ mobject bound to the animation, `orange_square`, is already
794
+ part of the scene (so again, no action taken). Finally, the run
795
+ time is extracted (3 seconds long) and stored in
796
+ `Scene.duration`. The renderer then checks whether it should
797
+ skip (it should not), then whether the animation is already
798
+ cached (it is not). The corresponding animation hash value is
799
+ determined and passed to the file writer, which then also calls
800
+ `libav` to start the writing process which waits for rendered
801
+ frames from the library.
802
+
803
+ The scene then `begin`s the animation: for the
804
+ [`ReplacementTransform`](../reference/manim.animation.transform.ReplacementTransform.md#manim.animation.transform.ReplacementTransform) this means that the animation populates
805
+ all of its relevant animation attributes (i.e., compatible copies
806
+ of the starting and the target mobject so that it can safely interpolate
807
+ between the two).
808
+
809
+ The mechanism determining static and moving mobjects considers
810
+ all of the scenes mobjects (at this point only the
811
+ `orange_square`), and determines that the `orange_square` is
812
+ bound to an animation that is currently played. As a result,
813
+ the square is classified as a “moving mobject”.
814
+
815
+ Time to render some frames.
816
+
817
+ ### The render loop (for real this time)
818
+
819
+ As mentioned above, due to the mechanism that determines static and moving
820
+ mobjects in the scene, the renderer knows which mobjects it can paint
821
+ statically to the background of the scene. Practically, this means that
822
+ it partially renders a scene (to produce a background image), and then
823
+ when iterating through the time progression of the animation only the
824
+ “moving mobjects” are re-painted on top of the static background.
825
+
826
+ The renderer calls `CairoRenderer.save_static_frame_data()`, which
827
+ first checks whether there are currently any static mobjects, and if there
828
+ are, it updates the frame (only with the static mobjects; more about how
829
+ exactly this works in a moment) and then saves a NumPy array representing
830
+ the rendered frame in the `static_image` attribute. In our toy example,
831
+ there are no static mobjects, and so the `static_image` attribute is
832
+ simply set to `None`.
833
+
834
+ Next, the renderer asks the scene whether the current animation is
835
+ a “frozen frame” animation, which would mean that the renderer actually
836
+ does not have to repaint the moving mobjects in every frame of the time
837
+ progression. It can then just take the latest static frame, and display it
838
+ throughout the animation.
839
+
840
+ #### NOTE
841
+ An animation is considered a “frozen frame” animation if only a
842
+ static [`Wait`](../reference/manim.animation.animation.Wait.md#manim.animation.animation.Wait) animation is played. See the description
843
+ of [`Scene.compile_animation_data()`](../reference/manim.scene.scene.Scene.md#manim.scene.scene.Scene.compile_animation_data) above, or the
844
+ implementation of [`Scene.should_update_mobjects()`](../reference/manim.scene.scene.Scene.md#manim.scene.scene.Scene.should_update_mobjects) for
845
+ more details.
846
+
847
+ If this is not the case (just as in our toy example), the renderer
848
+ then calls the [`Scene.play_internal()`](../reference/manim.scene.scene.Scene.md#manim.scene.scene.Scene.play_internal) method, which is the
849
+ integral part of the render loop (in which the library steps through
850
+ the time progression of the animation and renders the corresponding
851
+ frames).
852
+
853
+ Within [`Scene.play_internal()`](../reference/manim.scene.scene.Scene.md#manim.scene.scene.Scene.play_internal), the following steps are performed:
854
+
855
+ - The scene determines the run time of the animations by calling
856
+ [`Scene.get_run_time()`](../reference/manim.scene.scene.Scene.md#manim.scene.scene.Scene.get_run_time). This method basically takes the maximum
857
+ `run_time` attribute of all of the animations passed to the
858
+ [`Scene.play()`](../reference/manim.scene.scene.Scene.md#manim.scene.scene.Scene.play) call.
859
+ - Then the *time progression* is constructed via the (internal)
860
+ [`Scene._get_animation_time_progression()`](../reference/manim.scene.scene.Scene.md#manim.scene.scene.Scene._get_animation_time_progression) method, which wraps
861
+ the actual [`Scene.get_time_progression()`](../reference/manim.scene.scene.Scene.md#manim.scene.scene.Scene.get_time_progression) method. The time
862
+ progression is a `tqdm` [progress bar object](https://tqdm.github.io)
863
+ for an iterator over `np.arange(0, run_time, 1 / config.frame_rate)`. In
864
+ other words, the time progression holds the time stamps (relative to the
865
+ current animations, so starting at 0 and ending at the total animation run time,
866
+ with the step size determined by the render frame rate) of the timeline where
867
+ a new animation frame should be rendered.
868
+ - Then the scene iterates over the time progression: for each time stamp `t`,
869
+ `Scene.update_to_time()` is called, which …
870
+ - … first computes the time passed since the last update (which might be 0,
871
+ especially for the initial call) and references it as `dt`,
872
+ - then (in the order in which the animations are passed to [`Scene.play()`](../reference/manim.scene.scene.Scene.md#manim.scene.scene.Scene.play))
873
+ calls [`Animation.update_mobjects()`](../reference/manim.animation.animation.Animation.md#manim.animation.animation.Animation.update_mobjects) to trigger all updater functions that
874
+ are attached to the respective animation except for the “main mobject” of
875
+ the animation (that is, for example, for [`Transform`](../reference/manim.animation.transform.Transform.md#manim.animation.transform.Transform) the unmodified
876
+ copies of start and target mobject – see [`Animation.get_all_mobjects_to_update()`](../reference/manim.animation.animation.Animation.md#manim.animation.animation.Animation.get_all_mobjects_to_update)
877
+ for more details),
878
+ - then the relative time progression with respect to the current animation
879
+ is computed (`alpha = t / animation.run_time`), which is then used to
880
+ update the state of the animation with a call to [`Animation.interpolate()`](../reference/manim.animation.animation.Animation.md#manim.animation.animation.Animation.interpolate).
881
+ - After all of the passed animations have been processed, the updater functions
882
+ of all mobjects in the scene, all meshes, and finally those attached to
883
+ the scene itself are run.
884
+
885
+ At this point, the internal (Python) state of all mobjects has been updated
886
+ to match the currently processed timestamp. If rendering should not be skipped,
887
+ then it is now time to *take a picture*!
888
+
889
+ #### NOTE
890
+ The update of the internal state (iteration over the time progression) happens
891
+ *always* once [`Scene.play_internal()`](../reference/manim.scene.scene.Scene.md#manim.scene.scene.Scene.play_internal) is entered. This ensures that even
892
+ if frames do not need to be rendered (because, e.g., the `-n` CLI flag has
893
+ been passed, something has been cached, or because we might be in a *Section*
894
+ with skipped rendering), updater functions still run correctly, and the state
895
+ of the first frame that *is* rendered is kept consistent.
896
+
897
+ To render an image, the scene calls the corresponding method of its renderer,
898
+ `CairoRenderer.render()` and passes just the list of *moving mobjects* (remember,
899
+ the *static mobjects* are assumed to have already been painted statically to
900
+ the background of the scene). All of the hard work then happens when the renderer
901
+ updates its current frame via a call to `CairoRenderer.update_frame()`:
902
+
903
+ First, the renderer prepares its [`Camera`](../reference/manim.camera.camera.Camera.md#manim.camera.camera.Camera) by checking whether the renderer
904
+ has a `static_image` different from `None` stored already. If so, it sets the
905
+ image as the *background image* of the camera via `Camera.set_frame_to_background()`,
906
+ and otherwise it just resets the camera via [`Camera.reset()`](../reference/manim.camera.camera.Camera.md#manim.camera.camera.Camera.reset). The camera is then
907
+ asked to capture the scene with a call to [`Camera.capture_mobjects()`](../reference/manim.camera.camera.Camera.md#manim.camera.camera.Camera.capture_mobjects).
908
+
909
+ Things get a bit technical here, and at some point it is more efficient to
910
+ delve into the implementation – but here is a summary of what happens once the
911
+ camera is asked to capture the scene:
912
+
913
+ - First, a flat list of mobjects is created (so submobjects get extracted from
914
+ their parents). This list is then processed in groups of the same type of
915
+ mobjects (e.g., a batch of vectorized mobjects, followed by a batch of image mobjects,
916
+ followed by more vectorized mobjects, etc. – in many cases there will just be
917
+ one batch of vectorized mobjects).
918
+ - Depending on the type of the currently processed batch, the camera uses dedicated
919
+ *display functions* to convert the [`Mobject`](../reference/manim.mobject.mobject.Mobject.md#manim.mobject.mobject.Mobject) Python object to
920
+ a NumPy array stored in the camera’s `pixel_array` attribute.
921
+ The most important example in that context is the display function for
922
+ vectorized mobjects, [`Camera.display_multiple_vectorized_mobjects()`](../reference/manim.camera.camera.Camera.md#manim.camera.camera.Camera.display_multiple_vectorized_mobjects),
923
+ or the more particular (in case you did not add a background image to your
924
+ [`VMobject`](../reference/manim.mobject.types.vectorized_mobject.VMobject.md#manim.mobject.types.vectorized_mobject.VMobject)), [`Camera.display_multiple_non_background_colored_vmobjects()`](../reference/manim.camera.camera.Camera.md#manim.camera.camera.Camera.display_multiple_non_background_colored_vmobjects).
925
+ This method first gets the current Cairo context, and then, for every (vectorized)
926
+ mobject in the batch, calls [`Camera.display_vectorized()`](../reference/manim.camera.camera.Camera.md#manim.camera.camera.Camera.display_vectorized). There,
927
+ the actual background stroke, fill, and then stroke of the mobject is
928
+ drawn onto the context. See [`Camera.apply_stroke()`](../reference/manim.camera.camera.Camera.md#manim.camera.camera.Camera.apply_stroke) and
929
+ [`Camera.set_cairo_context_color()`](../reference/manim.camera.camera.Camera.md#manim.camera.camera.Camera.set_cairo_context_color) for more details – but it does not get
930
+ much deeper than that, in the latter method the actual Bézier curves
931
+ determined by the points of the mobject are drawn; this is where the low-level
932
+ interaction with Cairo happens.
933
+
934
+ After all batches have been processed, the camera has an image representation
935
+ of the Scene at the current time stamp in form of a NumPy array stored in its
936
+ `pixel_array` attribute. The renderer then takes this array and passes it to
937
+ its [`SceneFileWriter`](../reference/manim.scene.scene_file_writer.SceneFileWriter.md#manim.scene.scene_file_writer.SceneFileWriter). This concludes one iteration of the render loop,
938
+ and once the time progression has been processed completely, a final bit
939
+ of cleanup is performed before the [`Scene.play_internal()`](../reference/manim.scene.scene.Scene.md#manim.scene.scene.Scene.play_internal) call is completed.
940
+
941
+ A TL;DR for the render loop, in the context of our toy example, reads as follows:
942
+
943
+ - The scene finds that a 3 second long animation (the [`ReplacementTransform`](../reference/manim.animation.transform.ReplacementTransform.md#manim.animation.transform.ReplacementTransform)
944
+ changing the orange square to the blue circle) should be played. Given the requested
945
+ medium render quality, the frame rate is 30 frames per second, and so the time
946
+ progression with steps `[0, 1/30, 2/30, ..., 89/30]` is created.
947
+ - In the internal render loop, each of these time stamps is processed:
948
+ there are no updater functions, so effectively the scene updates the
949
+ state of the transformation animation to the desired time stamp (for example,
950
+ at time stamp `t = 45/30`, the animation is completed to a rate of
951
+ `alpha = 0.5`).
952
+ - Then the scene asks the renderer to do its job. The renderer asks its camera
953
+ to capture the scene, the only mobject that needs to be processed at this point
954
+ is the main mobject attached to the transformation; the camera converts the
955
+ current state of the mobject to entries in a NumPy array. The renderer passes
956
+ this array to the file writer.
957
+ - At the end of the loop, 90 frames have been passed to the file writer.
958
+
959
+ ### Completing the render loop
960
+
961
+ The last few steps in the [`Scene.play_internal()`](../reference/manim.scene.scene.Scene.md#manim.scene.scene.Scene.play_internal) call are not too
962
+ exciting: for every animation, the corresponding [`Animation.finish()`](../reference/manim.animation.animation.Animation.md#manim.animation.animation.Animation.finish)
963
+ and [`Animation.clean_up_from_scene()`](../reference/manim.animation.animation.Animation.md#manim.animation.animation.Animation.clean_up_from_scene) methods are called.
964
+
965
+ #### NOTE
966
+ Note that as part of [`Animation.finish()`](../reference/manim.animation.animation.Animation.md#manim.animation.animation.Animation.finish), the [`Animation.interpolate()`](../reference/manim.animation.animation.Animation.md#manim.animation.animation.Animation.interpolate)
967
+ method is called with an argument of 1.0 – you might have noticed already that
968
+ the last frame of an animation can sometimes be a bit off or incomplete.
969
+ This is by current design! The last frame rendered in the render loop (and displayed
970
+ for a duration of `1 / frame_rate` seconds in the rendered video) corresponds to
971
+ the state of the animation `1 / frame_rate` seconds before it ends. To display
972
+ the final frame as well in the video, we would need to append another `1 / frame_rate`
973
+ seconds to the video – which would then mean that a 1 second rendered Manim video
974
+ would be slightly longer than 1 second. We decided against this at some point.
975
+
976
+ In the end, the time progression is closed (which completes the displayed progress bar)
977
+ in the terminal. With the closing of the time progression, the
978
+ [`Scene.play_internal()`](../reference/manim.scene.scene.Scene.md#manim.scene.scene.Scene.play_internal) call is completed, and we return to the renderer,
979
+ which now orders the [`SceneFileWriter`](../reference/manim.scene.scene_file_writer.SceneFileWriter.md#manim.scene.scene_file_writer.SceneFileWriter) to close the output container that has
980
+ been opened for this animation: a partial movie file is written.
981
+
982
+ This pretty much concludes the walkthrough of a `Scene.play` call,
983
+ and actually there is not too much more to say for our toy example either: at
984
+ this point, a partial movie file that represents playing the
985
+ [`ReplacementTransform`](../reference/manim.animation.transform.ReplacementTransform.md#manim.animation.transform.ReplacementTransform) has been written. The initialization of
986
+ the [`Dot`](../reference/manim.mobject.geometry.arc.Dot.md#manim.mobject.geometry.arc.Dot) happens analogous to the initialization of `blue_circle`,
987
+ which has been discussed above. The [`Mobject.add_updater()`](../reference/manim.mobject.mobject.Mobject.md#manim.mobject.mobject.Mobject.add_updater) call literally
988
+ just attaches a function to the `updaters` attribute of the `small_dot`. And
989
+ the remaining [`Scene.play()`](../reference/manim.scene.scene.Scene.md#manim.scene.scene.Scene.play) and [`Scene.wait()`](../reference/manim.scene.scene.Scene.md#manim.scene.scene.Scene.wait) calls follow the
990
+ exact same procedure as discussed in the render loop section above; each such call
991
+ produces a corresponding partial movie file.
992
+
993
+ Once the [`Scene.construct()`](../reference/manim.scene.scene.Scene.md#manim.scene.scene.Scene.construct) method has been fully processed (and thus all
994
+ of the corresponding partial movie files have been written), the
995
+ scene calls its cleanup method [`Scene.tear_down()`](../reference/manim.scene.scene.Scene.md#manim.scene.scene.Scene.tear_down), and then
996
+ asks its renderer to finish the scene. The renderer, in turn, asks
997
+ its scene file writer to wrap things up by calling [`SceneFileWriter.finish()`](../reference/manim.scene.scene_file_writer.SceneFileWriter.md#manim.scene.scene_file_writer.SceneFileWriter.finish),
998
+ which triggers the combination of the partial movie files into the final product.
999
+
1000
+ And there you go! This is a more or less detailed description of how Manim works
1001
+ under the hood. While we did not discuss every single line of code in detail
1002
+ in this walkthrough, it should still give you a fairly good idea of how the general
1003
+ structural design of the library and at least the Cairo rendering flow in particular
1004
+ looks like.
data/rag/manim_docs/manim_core/docs/guides/using_text.md ADDED
@@ -0,0 +1,826 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Rendering Text and Formulas
2
+
3
+ There are two different ways by which you can render **Text** in videos:
4
+
5
+ 1. Using Pango ([`text_mobject`](../reference/manim.mobject.text.text_mobject.md#module-manim.mobject.text.text_mobject))
6
+ 2. Using LaTeX ([`tex_mobject`](../reference/manim.mobject.text.tex_mobject.md#module-manim.mobject.text.tex_mobject))
7
+
8
+ If you want to render simple text, you should use either [`Text`](../reference/manim.mobject.text.text_mobject.Text.md#manim.mobject.text.text_mobject.Text) or
9
+ [`MarkupText`](../reference/manim.mobject.text.text_mobject.MarkupText.md#manim.mobject.text.text_mobject.MarkupText), or one of its derivatives like [`Paragraph`](../reference/manim.mobject.text.text_mobject.Paragraph.md#manim.mobject.text.text_mobject.Paragraph).
10
+ See [Text Without LaTeX](#using-text-objects) for more information.
11
+
12
+ LaTeX should be used when you need mathematical typesetting. See
13
+ [Text With LaTeX](#rendering-with-latex) for more information.
14
+
15
+ <a id="using-text-objects"></a>
16
+
17
+ ## Text Without LaTeX
18
+
19
+ The simplest way to add text to your animations is to use the [`Text`](../reference/manim.mobject.text.text_mobject.Text.md#manim.mobject.text.text_mobject.Text)
20
+ class. It uses the [Pango library](https://pango.gnome.org) to render text. With Pango, you can also
21
+ render non-English alphabets like 你好 or こんにちは or 안녕하세요 or
22
+ مرحبا بالعالم.
23
+
24
+ Here is a simple *Hello World* animation.
25
+
26
+ <div id="helloworld" class="admonition admonition-manim-example">
27
+ <p class="admonition-title">Example: HelloWorld <a class="headerlink" href="#helloworld">¶</a></p>![image](media/images/HelloWorld-1.png)
28
+ ```python
29
+ from manim import *
30
+
31
+ class HelloWorld(Scene):
32
+ def construct(self):
33
+ text = Text("Hello world", font_size=144)
34
+ self.add(text)
35
+ ```
36
+
37
+ <pre data-manim-binder data-manim-classname="HelloWorld">
38
+ class HelloWorld(Scene):
39
+ def construct(self):
40
+ text = Text("Hello world", font_size=144)
41
+ self.add(text)
42
+
43
+ </pre>
44
+
45
+ References: [`Text`](../reference/manim.mobject.text.text_mobject.Text.md#manim.mobject.text.text_mobject.Text)
46
+
47
+ </div>
48
+
49
+ You can also use [`MarkupText`](../reference/manim.mobject.text.text_mobject.MarkupText.md#manim.mobject.text.text_mobject.MarkupText) which allows the use of PangoMarkup
50
+ (see the documentation of [`MarkupText`](../reference/manim.mobject.text.text_mobject.MarkupText.md#manim.mobject.text.text_mobject.MarkupText) for details) to render text.
51
+ For example:
52
+
53
+ <div id="singlelinecolor" class="admonition admonition-manim-example">
54
+ <p class="admonition-title">Example: SingleLineColor <a class="headerlink" href="#singlelinecolor">¶</a></p>![image](media/images/SingleLineColor-1.png)
55
+ ```python
56
+ from manim import *
57
+
58
+ class SingleLineColor(Scene):
59
+ def construct(self):
60
+ text = MarkupText(
61
+ f'all in red <span fgcolor="{YELLOW}">except this</span>', color=RED
62
+ )
63
+ self.add(text)
64
+ ```
65
+
66
+ <pre data-manim-binder data-manim-classname="SingleLineColor">
67
+ class SingleLineColor(Scene):
68
+ def construct(self):
69
+ text = MarkupText(
70
+ f'all in red <span fgcolor="{YELLOW}">except this</span>', color=RED
71
+ )
72
+ self.add(text)
73
+
74
+ </pre>
75
+
76
+ References: [`MarkupText`](../reference/manim.mobject.text.text_mobject.MarkupText.md#manim.mobject.text.text_mobject.MarkupText)
77
+
78
+ </div>
79
+
80
+ ### Working with [`Text`](../reference/manim.mobject.text.text_mobject.Text.md#manim.mobject.text.text_mobject.Text)
81
+
82
+ This section explains the properties of [`Text`](../reference/manim.mobject.text.text_mobject.Text.md#manim.mobject.text.text_mobject.Text) and how can it be used
83
+ in your animations.
84
+
85
+ #### Using Fonts
86
+
87
+ You can set a different font using `font`.
88
+
89
+ #### NOTE
90
+ The font used must be installed in your system, and Pango should know
91
+ about it. You can get a list of fonts using `manimpango.list_fonts()`.
92
+
93
+ ```pycon
94
+ >>> import manimpango
95
+ >>> manimpango.list_fonts()
96
+ [...]
97
+ ```
98
+
99
+ <div id="fontsexample" class="admonition admonition-manim-example">
100
+ <p class="admonition-title">Example: FontsExample <a class="headerlink" href="#fontsexample">¶</a></p>![image](media/images/FontsExample-1.png)
101
+ ```python
102
+ from manim import *
103
+
104
+ class FontsExample(Scene):
105
+ def construct(self):
106
+ ft = Text("Noto Sans", font="Noto Sans")
107
+ self.add(ft)
108
+ ```
109
+
110
+ <pre data-manim-binder data-manim-classname="FontsExample">
111
+ class FontsExample(Scene):
112
+ def construct(self):
113
+ ft = Text("Noto Sans", font="Noto Sans")
114
+ self.add(ft)
115
+
116
+ </pre></div>
117
+
118
+ #### Setting Slant and Weight
119
+
120
+ Slant is the style of the Text, and it can be `NORMAL` (the default),
121
+ `ITALIC` or `OBLIQUE`. Usually, for many fonts both `ITALIC` and
122
+ `OBLIQUE` look similar, but `ITALIC` uses **Roman Style**, whereas
123
+ `OBLIQUE` uses **Italic Style**.
124
+
125
+ Weight specifies the boldness of a font. You can see a list of weights in
126
+ `manimpango.Weight`.
127
+
128
+ <div id="slantsexample" class="admonition admonition-manim-example">
129
+ <p class="admonition-title">Example: SlantsExample <a class="headerlink" href="#slantsexample">¶</a></p>![image](media/images/SlantsExample-1.png)
130
+ ```python
131
+ from manim import *
132
+
133
+ class SlantsExample(Scene):
134
+ def construct(self):
135
+ a = Text("Italic", slant=ITALIC)
136
+ self.add(a)
137
+ ```
138
+
139
+ <pre data-manim-binder data-manim-classname="SlantsExample">
140
+ class SlantsExample(Scene):
141
+ def construct(self):
142
+ a = Text("Italic", slant=ITALIC)
143
+ self.add(a)
144
+
145
+ </pre></div><div id="differentweight" class="admonition admonition-manim-example">
146
+ <p class="admonition-title">Example: DifferentWeight <a class="headerlink" href="#differentweight">¶</a></p>![image](media/images/DifferentWeight-1.png)
147
+ ```python
148
+ from manim import *
149
+
150
+ class DifferentWeight(Scene):
151
+ def construct(self):
152
+ import manimpango
153
+
154
+ g = VGroup()
155
+ weight_list = dict(
156
+ sorted(
157
+ {
158
+ weight: manimpango.Weight(weight).value
159
+ for weight in manimpango.Weight
160
+ }.items(),
161
+ key=lambda x: x[1],
162
+ )
163
+ )
164
+ for weight in weight_list:
165
+ g += Text(weight.name, weight=weight.name, font="Open Sans")
166
+ self.add(g.arrange(DOWN).scale(0.5))
167
+ ```
168
+
169
+ <pre data-manim-binder data-manim-classname="DifferentWeight">
170
+ class DifferentWeight(Scene):
171
+ def construct(self):
172
+ import manimpango
173
+
174
+ g = VGroup()
175
+ weight_list = dict(
176
+ sorted(
177
+ {
178
+ weight: manimpango.Weight(weight).value
179
+ for weight in manimpango.Weight
180
+ }.items(),
181
+ key=lambda x: x[1],
182
+ )
183
+ )
184
+ for weight in weight_list:
185
+ g += Text(weight.name, weight=weight.name, font="Open Sans")
186
+ self.add(g.arrange(DOWN).scale(0.5))
187
+
188
+ </pre></div>
189
+
190
+ <a id="using-colors"></a>
191
+
192
+ #### Using Colors
193
+
194
+ You can set the color of the text using `color`:
195
+
196
+ <div id="simplecolor" class="admonition admonition-manim-example">
197
+ <p class="admonition-title">Example: SimpleColor <a class="headerlink" href="#simplecolor">¶</a></p>![image](media/images/SimpleColor-1.png)
198
+ ```python
199
+ from manim import *
200
+
201
+ class SimpleColor(Scene):
202
+ def construct(self):
203
+ col = Text("RED COLOR", color=RED)
204
+ self.add(col)
205
+ ```
206
+
207
+ <pre data-manim-binder data-manim-classname="SimpleColor">
208
+ class SimpleColor(Scene):
209
+ def construct(self):
210
+ col = Text("RED COLOR", color=RED)
211
+ self.add(col)
212
+
213
+ </pre></div>
214
+
215
+ You can use utilities like `t2c` for coloring specific characters.
216
+ This may be problematic if your text contains ligatures
217
+ as explained in [Iterating Text](#iterating-text).
218
+
219
+ `t2c` accepts two types of dictionaries,
220
+
221
+ * The keys can contain indices like `[2:-1]` or `[4:8]`,
222
+ this works similar to how [slicing](https://realpython.com/python-strings/#string-slicing)
223
+ works in Python. The values should be the color of the Text from `Color`.
224
+ * The keys contain words or characters which should be colored separately
225
+ and the values should be the color from `Color`:
226
+
227
+ <div id="textt2cexample" class="admonition admonition-manim-example">
228
+ <p class="admonition-title">Example: Textt2cExample <a class="headerlink" href="#textt2cexample">¶</a></p>![image](media/images/Textt2cExample-1.png)
229
+ ```python
230
+ from manim import *
231
+
232
+ class Textt2cExample(Scene):
233
+ def construct(self):
234
+ t2cindices = Text('Hello', t2c={'[1:-1]': BLUE}).move_to(LEFT)
235
+ t2cwords = Text('World',t2c={'rl':RED}).next_to(t2cindices, RIGHT)
236
+ self.add(t2cindices, t2cwords)
237
+ ```
238
+
239
+ <pre data-manim-binder data-manim-classname="Textt2cExample">
240
+ class Textt2cExample(Scene):
241
+ def construct(self):
242
+ t2cindices = Text('Hello', t2c={'[1:-1]': BLUE}).move_to(LEFT)
243
+ t2cwords = Text('World',t2c={'rl':RED}).next_to(t2cindices, RIGHT)
244
+ self.add(t2cindices, t2cwords)
245
+
246
+ </pre></div>
247
+
248
+ If you want to avoid problems when using colors (due to ligatures), consider using
249
+ `MarkupText`.
250
+
251
+ #### Using Gradients
252
+
253
+ You can add a gradient using `gradient`. The value must
254
+ be an iterable of any length:
255
+
256
+ <div id="gradientexample" class="admonition admonition-manim-example">
257
+ <p class="admonition-title">Example: GradientExample <a class="headerlink" href="#gradientexample">¶</a></p>![image](media/images/GradientExample-1.png)
258
+ ```python
259
+ from manim import *
260
+
261
+ class GradientExample(Scene):
262
+ def construct(self):
263
+ t = Text("Hello", gradient=(RED, BLUE, GREEN), font_size=96)
264
+ self.add(t)
265
+ ```
266
+
267
+ <pre data-manim-binder data-manim-classname="GradientExample">
268
+ class GradientExample(Scene):
269
+ def construct(self):
270
+ t = Text("Hello", gradient=(RED, BLUE, GREEN), font_size=96)
271
+ self.add(t)
272
+
273
+ </pre></div>
274
+
275
+ You can also use `t2g` for gradients with specific
276
+ characters of the text. It shares a similar syntax to [the
277
+ interface for colors](#using-colors):
278
+
279
+ <div id="t2gexample" class="admonition admonition-manim-example">
280
+ <p class="admonition-title">Example: t2gExample <a class="headerlink" href="#t2gexample">¶</a></p>![image](media/images/t2gExample-1.png)
281
+ ```python
282
+ from manim import *
283
+
284
+ class t2gExample(Scene):
285
+ def construct(self):
286
+ t2gindices = Text(
287
+ 'Hello',
288
+ t2g={
289
+ '[1:-1]': (RED,GREEN),
290
+ },
291
+ ).move_to(LEFT)
292
+ t2gwords = Text(
293
+ 'World',
294
+ t2g={
295
+ 'World':(RED,BLUE),
296
+ },
297
+ ).next_to(t2gindices, RIGHT)
298
+ self.add(t2gindices, t2gwords)
299
+ ```
300
+
301
+ <pre data-manim-binder data-manim-classname="t2gExample">
302
+ class t2gExample(Scene):
303
+ def construct(self):
304
+ t2gindices = Text(
305
+ 'Hello',
306
+ t2g={
307
+ '[1:-1]': (RED,GREEN),
308
+ },
309
+ ).move_to(LEFT)
310
+ t2gwords = Text(
311
+ 'World',
312
+ t2g={
313
+ 'World':(RED,BLUE),
314
+ },
315
+ ).next_to(t2gindices, RIGHT)
316
+ self.add(t2gindices, t2gwords)
317
+
318
+ </pre></div>
319
+
320
+ #### Setting Line Spacing
321
+
322
+ You can set the line spacing using `line_spacing`:
323
+
324
+ <div id="linespacing" class="admonition admonition-manim-example">
325
+ <p class="admonition-title">Example: LineSpacing <a class="headerlink" href="#linespacing">¶</a></p>![image](media/images/LineSpacing-1.png)
326
+ ```python
327
+ from manim import *
328
+
329
+ class LineSpacing(Scene):
330
+ def construct(self):
331
+ a = Text("Hello\nWorld", line_spacing=1)
332
+ b = Text("Hello\nWorld", line_spacing=4)
333
+ self.add(Group(a,b).arrange(LEFT, buff=5))
334
+ ```
335
+
336
+ <pre data-manim-binder data-manim-classname="LineSpacing">
337
+ class LineSpacing(Scene):
338
+ def construct(self):
339
+ a = Text("Hello\\nWorld", line_spacing=1)
340
+ b = Text("Hello\\nWorld", line_spacing=4)
341
+ self.add(Group(a,b).arrange(LEFT, buff=5))
342
+
343
+ </pre></div>
344
+
345
+ <a id="disable-ligatures"></a>
346
+
347
+ #### Disabling Ligatures
348
+
349
+ By disabling ligatures you would get a one-to-one mapping between characters and
350
+ submobjects. This fixes the issues with coloring text.
351
+
352
+ #### WARNING
353
+ Be aware that using this method with text that heavily depends on
354
+ ligatures (Arabic text) may yield unexpected results.
355
+
356
+ You can disable ligatures by passing `disable_ligatures` to
357
+ `Text`. For example:
358
+
359
+ <div id="disableligature" class="admonition admonition-manim-example">
360
+ <p class="admonition-title">Example: DisableLigature <a class="headerlink" href="#disableligature">¶</a></p>![image](media/images/DisableLigature-1.png)
361
+ ```python
362
+ from manim import *
363
+
364
+ class DisableLigature(Scene):
365
+ def construct(self):
366
+ li = Text("fl ligature",font_size=96)
367
+ nli = Text("fl ligature", disable_ligatures=True, font_size=96)
368
+ self.add(Group(li, nli).arrange(DOWN, buff=.8))
369
+ ```
370
+
371
+ <pre data-manim-binder data-manim-classname="DisableLigature">
372
+ class DisableLigature(Scene):
373
+ def construct(self):
374
+ li = Text("fl ligature",font_size=96)
375
+ nli = Text("fl ligature", disable_ligatures=True, font_size=96)
376
+ self.add(Group(li, nli).arrange(DOWN, buff=.8))
377
+
378
+ </pre></div>
379
+
380
+ <a id="iterating-text"></a>
381
+
382
+ #### Iterating [`Text`](../reference/manim.mobject.text.text_mobject.Text.md#manim.mobject.text.text_mobject.Text)
383
+
384
+ Text objects behave like [`VGroups`](../reference/manim.mobject.types.vectorized_mobject.VGroup.md#manim.mobject.types.vectorized_mobject.VGroup). Therefore, you can slice and index
385
+ the text.
386
+
387
+ For example, you can set each letter to different color by iterating it.
388
+
389
+ <div id="iteratecolor" class="admonition admonition-manim-example">
390
+ <p class="admonition-title">Example: IterateColor <a class="headerlink" href="#iteratecolor">¶</a></p>![image](media/images/IterateColor-1.png)
391
+ ```python
392
+ from manim import *
393
+
394
+ class IterateColor(Scene):
395
+ def construct(self):
396
+ text = Text("Colors", font_size=96)
397
+ for letter in text:
398
+ letter.set_color(random_bright_color())
399
+ self.add(text)
400
+ ```
401
+
402
+ <pre data-manim-binder data-manim-classname="IterateColor">
403
+ class IterateColor(Scene):
404
+ def construct(self):
405
+ text = Text("Colors", font_size=96)
406
+ for letter in text:
407
+ letter.set_color(random_bright_color())
408
+ self.add(text)
409
+
410
+ </pre></div>
411
+
412
+ #### WARNING
413
+ Please note that [Ligature](https://en.wikipedia.org/wiki/Ligature_(writing)) can cause problems here. If you need a
414
+ one-to-one mapping of characters to submobjects you should pass
415
+ the `disable_ligatures` parameter to [`Text`](../reference/manim.mobject.text.text_mobject.Text.md#manim.mobject.text.text_mobject.Text).
416
+ See [Disabling Ligatures](#disable-ligatures).
417
+
418
+ ### Working with [`MarkupText`](../reference/manim.mobject.text.text_mobject.MarkupText.md#manim.mobject.text.text_mobject.MarkupText)
419
+
420
+ MarkupText is similar to [`Text`](../reference/manim.mobject.text.text_mobject.Text.md#manim.mobject.text.text_mobject.Text), the only difference between them is
421
+ that this accepts and processes PangoMarkup (which is similar to
422
+ html), instead of just rendering plain text.
423
+
424
+ Consult the documentation of [`MarkupText`](../reference/manim.mobject.text.text_mobject.MarkupText.md#manim.mobject.text.text_mobject.MarkupText) for more details
425
+ and further references about PangoMarkup.
426
+
427
+ <div id="markuptest" class="admonition admonition-manim-example">
428
+ <p class="admonition-title">Example: MarkupTest <a class="headerlink" href="#markuptest">¶</a></p>![image](media/images/MarkupTest-1.png)
429
+ ```python
430
+ from manim import *
431
+
432
+ class MarkupTest(Scene):
433
+ def construct(self):
434
+ text = MarkupText(
435
+ f'<span underline="double" underline_color="green">double green underline</span> in red text<span fgcolor="{YELLOW}"> except this</span>',
436
+ color=RED,
437
+ font_size=34
438
+ )
439
+ self.add(text)
440
+ ```
441
+
442
+ <pre data-manim-binder data-manim-classname="MarkupTest">
443
+ class MarkupTest(Scene):
444
+ def construct(self):
445
+ text = MarkupText(
446
+ f'<span underline="double" underline_color="green">double green underline</span> in red text<span fgcolor="{YELLOW}"> except this</span>',
447
+ color=RED,
448
+ font_size=34
449
+ )
450
+ self.add(text)
451
+
452
+ </pre></div>
453
+
454
+ <a id="rendering-with-latex"></a>
455
+
456
+ ## Text With LaTeX
457
+
458
+ Just as you can use [`Text`](../reference/manim.mobject.text.text_mobject.Text.md#manim.mobject.text.text_mobject.Text) to add text to your videos, you can
459
+ use [`Tex`](../reference/manim.mobject.text.tex_mobject.Tex.md#manim.mobject.text.tex_mobject.Tex) to insert LaTeX.
460
+
461
+ For example,
462
+
463
+ <div id="hellolatex" class="admonition admonition-manim-example">
464
+ <p class="admonition-title">Example: HelloLaTeX <a class="headerlink" href="#hellolatex">¶</a></p>![image](media/images/HelloLaTeX-1.png)
465
+ ```python
466
+ from manim import *
467
+
468
+ class HelloLaTeX(Scene):
469
+ def construct(self):
470
+ tex = Tex(r"\LaTeX", font_size=144)
471
+ self.add(tex)
472
+ ```
473
+
474
+ <pre data-manim-binder data-manim-classname="HelloLaTeX">
475
+ class HelloLaTeX(Scene):
476
+ def construct(self):
477
+ tex = Tex(r"\\LaTeX", font_size=144)
478
+ self.add(tex)
479
+
480
+ </pre></div>
481
+
482
+ #### NOTE
483
+ Note that we are using a raw string (`r'...'`) instead of a regular string (`'...'`).
484
+ This is because TeX code uses a lot of special characters - like `\` for example - that
485
+ have special meaning within a regular python string. An alternative would have been to
486
+ write `\\` to escape the backslash: `Tex('\\LaTeX')`.
487
+
488
+ ### Working with [`MathTex`](../reference/manim.mobject.text.tex_mobject.MathTex.md#manim.mobject.text.tex_mobject.MathTex)
489
+
490
+ Everything passed to [`MathTex`](../reference/manim.mobject.text.tex_mobject.MathTex.md#manim.mobject.text.tex_mobject.MathTex) is in math mode by default. To be more precise,
491
+ [`MathTex`](../reference/manim.mobject.text.tex_mobject.MathTex.md#manim.mobject.text.tex_mobject.MathTex) is processed within an `align*` environment. You can achieve a
492
+ similar effect with [`Tex`](../reference/manim.mobject.text.tex_mobject.Tex.md#manim.mobject.text.tex_mobject.Tex) by enclosing your formula with `$` symbols:
493
+ `$\xrightarrow{x^6y^8}$`:
494
+
495
+ <div id="mathtexdemo" class="admonition admonition-manim-example">
496
+ <p class="admonition-title">Example: MathTeXDemo <a class="headerlink" href="#mathtexdemo">¶</a></p>![image](media/images/MathTeXDemo-1.png)
497
+ ```python
498
+ from manim import *
499
+
500
+ class MathTeXDemo(Scene):
501
+ def construct(self):
502
+ rtarrow0 = MathTex(r"\xrightarrow{x^6y^8}", font_size=96)
503
+ rtarrow1 = Tex(r"$\xrightarrow{x^6y^8}$", font_size=96)
504
+
505
+ self.add(VGroup(rtarrow0, rtarrow1).arrange(DOWN))
506
+ ```
507
+
508
+ <pre data-manim-binder data-manim-classname="MathTeXDemo">
509
+ class MathTeXDemo(Scene):
510
+ def construct(self):
511
+ rtarrow0 = MathTex(r"\\xrightarrow{x^6y^8}", font_size=96)
512
+ rtarrow1 = Tex(r"$\\xrightarrow{x^6y^8}$", font_size=96)
513
+
514
+ self.add(VGroup(rtarrow0, rtarrow1).arrange(DOWN))
515
+
516
+ </pre></div>
517
+
518
+ ### LaTeX commands and keyword arguments
519
+
520
+ We can use any standard LaTeX commands in the AMS maths packages. Such
521
+ as the `mathtt` math-text type or the `looparrowright` arrow.
522
+
523
+ <div id="amslatex" class="admonition admonition-manim-example">
524
+ <p class="admonition-title">Example: AMSLaTeX <a class="headerlink" href="#amslatex">¶</a></p>![image](media/images/AMSLaTeX-1.png)
525
+ ```python
526
+ from manim import *
527
+
528
+ class AMSLaTeX(Scene):
529
+ def construct(self):
530
+ tex = Tex(r'$\mathtt{H} \looparrowright$ \LaTeX', font_size=144)
531
+ self.add(tex)
532
+ ```
533
+
534
+ <pre data-manim-binder data-manim-classname="AMSLaTeX">
535
+ class AMSLaTeX(Scene):
536
+ def construct(self):
537
+ tex = Tex(r'$\\mathtt{H} \\looparrowright$ \\LaTeX', font_size=144)
538
+ self.add(tex)
539
+
540
+ </pre></div>
541
+
542
+ On the Manim side, the [`Tex`](../reference/manim.mobject.text.tex_mobject.Tex.md#manim.mobject.text.tex_mobject.Tex) class also accepts attributes to
543
+ change the appearance of the output. This is very similar to the
544
+ [`Text`](../reference/manim.mobject.text.text_mobject.Text.md#manim.mobject.text.text_mobject.Text) class. For example, the `color` keyword changes the
545
+ color of the TeX mobject.
546
+
547
+ <div id="latexattributes" class="admonition admonition-manim-example">
548
+ <p class="admonition-title">Example: LaTeXAttributes <a class="headerlink" href="#latexattributes">¶</a></p>![image](media/images/LaTeXAttributes-1.png)
549
+ ```python
550
+ from manim import *
551
+
552
+ class LaTeXAttributes(Scene):
553
+ def construct(self):
554
+ tex = Tex(r'Hello \LaTeX', color=BLUE, font_size=144)
555
+ self.add(tex)
556
+ ```
557
+
558
+ <pre data-manim-binder data-manim-classname="LaTeXAttributes">
559
+ class LaTeXAttributes(Scene):
560
+ def construct(self):
561
+ tex = Tex(r'Hello \\LaTeX', color=BLUE, font_size=144)
562
+ self.add(tex)
563
+
564
+ </pre></div>
565
+
566
+ ### Extra LaTeX Packages
567
+
568
+ Some commands require special packages to be loaded into the TeX template.
569
+ For example, to use the `mathscr` script, we need to add the `mathrsfs`
570
+ package. Since this package isn’t loaded into Manim’s tex template by default,
571
+ we have to add it manually.
572
+
573
+ <div id="addpackagelatex" class="admonition admonition-manim-example">
574
+ <p class="admonition-title">Example: AddPackageLatex <a class="headerlink" href="#addpackagelatex">¶</a></p>![image](media/images/AddPackageLatex-1.png)
575
+ ```python
576
+ from manim import *
577
+
578
+ class AddPackageLatex(Scene):
579
+ def construct(self):
580
+ myTemplate = TexTemplate()
581
+ myTemplate.add_to_preamble(r"\usepackage{mathrsfs}")
582
+ tex = Tex(
583
+ r"$\mathscr{H} \rightarrow \mathbb{H}$",
584
+ tex_template=myTemplate,
585
+ font_size=144,
586
+ )
587
+ self.add(tex)
588
+ ```
589
+
590
+ <pre data-manim-binder data-manim-classname="AddPackageLatex">
591
+ class AddPackageLatex(Scene):
592
+ def construct(self):
593
+ myTemplate = TexTemplate()
594
+ myTemplate.add_to_preamble(r"\\usepackage{mathrsfs}")
595
+ tex = Tex(
596
+ r"$\\mathscr{H} \\rightarrow \\mathbb{H}$",
597
+ tex_template=myTemplate,
598
+ font_size=144,
599
+ )
600
+ self.add(tex)
601
+
602
+ </pre></div>
603
+
604
+ ### Substrings and parts
605
+
606
+ The TeX mobject can accept multiple strings as arguments. Afterwards you can
607
+ refer to the individual parts either by their index (like `tex[1]`), or by
608
+ selecting parts of the tex code. In this example, we set the color
609
+ of the `\bigstar` using `set_color_by_tex()`:
610
+
611
+ <div id="latexsubstrings" class="admonition admonition-manim-example">
612
+ <p class="admonition-title">Example: LaTeXSubstrings <a class="headerlink" href="#latexsubstrings">¶</a></p>![image](media/images/LaTeXSubstrings-1.png)
613
+ ```python
614
+ from manim import *
615
+
616
+ class LaTeXSubstrings(Scene):
617
+ def construct(self):
618
+ tex = Tex('Hello', r'$\bigstar$', r'\LaTeX', font_size=144)
619
+ tex.set_color_by_tex('igsta', RED)
620
+ self.add(tex)
621
+ ```
622
+
623
+ <pre data-manim-binder data-manim-classname="LaTeXSubstrings">
624
+ class LaTeXSubstrings(Scene):
625
+ def construct(self):
626
+ tex = Tex('Hello', r'$\\bigstar$', r'\\LaTeX', font_size=144)
627
+ tex.set_color_by_tex('igsta', RED)
628
+ self.add(tex)
629
+
630
+ </pre></div>
631
+
632
+ Note that `set_color_by_tex()` colors the entire substring containing
633
+ the Tex, not just the specific symbol or Tex expression. Consider the following example:
634
+
635
+ <div id="incorrectlatexsubstringcoloring" class="admonition admonition-manim-example">
636
+ <p class="admonition-title">Example: IncorrectLaTeXSubstringColoring <a class="headerlink" href="#incorrectlatexsubstringcoloring">¶</a></p>![image](media/images/IncorrectLaTeXSubstringColoring-1.png)
637
+ ```python
638
+ from manim import *
639
+
640
+ class IncorrectLaTeXSubstringColoring(Scene):
641
+ def construct(self):
642
+ equation = MathTex(
643
+ r"e^x = x^0 + x^1 + \frac{1}{2} x^2 + \frac{1}{6} x^3 + \cdots + \frac{1}{n!} x^n + \cdots"
644
+ )
645
+ equation.set_color_by_tex("x", YELLOW)
646
+ self.add(equation)
647
+ ```
648
+
649
+ <pre data-manim-binder data-manim-classname="IncorrectLaTeXSubstringColoring">
650
+ class IncorrectLaTeXSubstringColoring(Scene):
651
+ def construct(self):
652
+ equation = MathTex(
653
+ r"e^x = x^0 + x^1 + \\frac{1}{2} x^2 + \\frac{1}{6} x^3 + \\cdots + \\frac{1}{n!} x^n + \\cdots"
654
+ )
655
+ equation.set_color_by_tex("x", YELLOW)
656
+ self.add(equation)
657
+
658
+ </pre></div>
659
+
660
+ As you can see, this colors the entire equation yellow, contrary to what
661
+ may be expected. To color only `x` yellow, we have to do the following:
662
+
663
+ <div id="correctlatexsubstringcoloring" class="admonition admonition-manim-example">
664
+ <p class="admonition-title">Example: CorrectLaTeXSubstringColoring <a class="headerlink" href="#correctlatexsubstringcoloring">¶</a></p>![image](media/images/CorrectLaTeXSubstringColoring-1.png)
665
+ ```python
666
+ from manim import *
667
+
668
+ class CorrectLaTeXSubstringColoring(Scene):
669
+ def construct(self):
670
+ equation = MathTex(
671
+ r"e^x = x^0 + x^1 + \frac{1}{2} x^2 + \frac{1}{6} x^3 + \cdots + \frac{1}{n!} x^n + \cdots",
672
+ substrings_to_isolate="x"
673
+ )
674
+ equation.set_color_by_tex("x", YELLOW)
675
+ self.add(equation)
676
+ ```
677
+
678
+ <pre data-manim-binder data-manim-classname="CorrectLaTeXSubstringColoring">
679
+ class CorrectLaTeXSubstringColoring(Scene):
680
+ def construct(self):
681
+ equation = MathTex(
682
+ r"e^x = x^0 + x^1 + \\frac{1}{2} x^2 + \\frac{1}{6} x^3 + \\cdots + \\frac{1}{n!} x^n + \\cdots",
683
+ substrings_to_isolate="x"
684
+ )
685
+ equation.set_color_by_tex("x", YELLOW)
686
+ self.add(equation)
687
+
688
+ </pre></div>
689
+
690
+ By setting `substrings_to_isolate` to `x`, we split up the
691
+ [`MathTex`](../reference/manim.mobject.text.tex_mobject.MathTex.md#manim.mobject.text.tex_mobject.MathTex) into substrings automatically and isolate the `x` components
692
+ into individual substrings. Only then can `set_color_by_tex()` be used
693
+ to achieve the desired result.
694
+
695
+ Note that Manim also supports a custom syntax that allows splitting
696
+ a TeX string into substrings easily: simply enclose parts of your formula
697
+ that you want to isolate with double braces. In the string
698
+ `MathTex(r"{{ a^2 }} + {{ b^2 }} = {{ c^2 }}")`, the rendered mobject
699
+ will consist of the substrings `a^2`, `+`, `b^2`, `=`, and `c^2`.
700
+ This makes transformations between similar text fragments easy
701
+ to write using [`TransformMatchingTex`](../reference/manim.animation.transform_matching_parts.TransformMatchingTex.md#manim.animation.transform_matching_parts.TransformMatchingTex).
702
+
703
+ ### Using `index_labels` to work with complicated strings
704
+
705
+ You might sometimes be working with a very complicated [`MathTex`](../reference/manim.mobject.text.tex_mobject.MathTex.md#manim.mobject.text.tex_mobject.MathTex) mobject
706
+ that makes it difficult to work with its individual components. This is
707
+ where the debugging function [`index_labels()`](../reference/manim.utils.debug.md#manim.utils.debug.index_labels) is very useful.
708
+
709
+ The method shows the index of a mobject’s submobjects, allowing you
710
+ to easily find the components of the mobject you would like to change.
711
+
712
+ <div id="indexlabelsmathtex" class="admonition admonition-manim-example">
713
+ <p class="admonition-title">Example: IndexLabelsMathTex <a class="headerlink" href="#indexlabelsmathtex">¶</a></p>![image](media/images/IndexLabelsMathTex-1.png)
714
+ ```python
715
+ from manim import *
716
+
717
+ class IndexLabelsMathTex(Scene):
718
+ def construct(self):
719
+ text = MathTex(r"\binom{2n}{n+2}", font_size=96)
720
+
721
+ # index the first (and only) term of the MathTex mob
722
+ self.add(index_labels(text[0]))
723
+
724
+ text[0][1:3].set_color(YELLOW)
725
+ text[0][3:6].set_color(RED)
726
+ self.add(text)
727
+ ```
728
+
729
+ <pre data-manim-binder data-manim-classname="IndexLabelsMathTex">
730
+ class IndexLabelsMathTex(Scene):
731
+ def construct(self):
732
+ text = MathTex(r"\\binom{2n}{n+2}", font_size=96)
733
+
734
+ # index the first (and only) term of the MathTex mob
735
+ self.add(index_labels(text[0]))
736
+
737
+ text[0][1:3].set_color(YELLOW)
738
+ text[0][3:6].set_color(RED)
739
+ self.add(text)
740
+
741
+ </pre></div>
742
+
743
+ ### LaTeX Maths Fonts - The Template Library
744
+
745
+ Changing fonts in LaTeX when typesetting mathematical formulae is
746
+ trickier than regular text. It requires changing the template that is used
747
+ to compile the TeX. Manim comes with a collection of [`TexFontTemplates`](../reference/manim.utils.tex_templates.TexFontTemplates.md#manim.utils.tex_templates.TexFontTemplates)
748
+ ready for you to use. These templates will all work in math mode:
749
+
750
+ <div id="latexmathfonts" class="admonition admonition-manim-example">
751
+ <p class="admonition-title">Example: LaTeXMathFonts <a class="headerlink" href="#latexmathfonts">¶</a></p>![image](media/images/LaTeXMathFonts-1.png)
752
+ ```python
753
+ from manim import *
754
+
755
+ class LaTeXMathFonts(Scene):
756
+ def construct(self):
757
+ tex = Tex(
758
+ r"$x^2 + y^2 = z^2$",
759
+ tex_template=TexFontTemplates.french_cursive,
760
+ font_size=144,
761
+ )
762
+ self.add(tex)
763
+ ```
764
+
765
+ <pre data-manim-binder data-manim-classname="LaTeXMathFonts">
766
+ class LaTeXMathFonts(Scene):
767
+ def construct(self):
768
+ tex = Tex(
769
+ r"$x^2 + y^2 = z^2$",
770
+ tex_template=TexFontTemplates.french_cursive,
771
+ font_size=144,
772
+ )
773
+ self.add(tex)
774
+
775
+ </pre></div>
776
+
777
+ Manim also has a [`TexTemplateLibrary`](../reference/manim.utils.tex_templates.TexTemplateLibrary.md#manim.utils.tex_templates.TexTemplateLibrary) containing the TeX
778
+ templates used by 3Blue1Brown. One example is the ctex template,
779
+ used for typesetting Chinese script. For this to work, the ctex LaTeX package
780
+ must be installed on your system. Furthermore, if you are only
781
+ typesetting Text, you probably do not need [`Tex`](../reference/manim.mobject.text.tex_mobject.Tex.md#manim.mobject.text.tex_mobject.Tex) at all, and
782
+ should use [`Text`](../reference/manim.mobject.text.text_mobject.Text.md#manim.mobject.text.text_mobject.Text) instead.
783
+
784
+ <div id="latextemplatelibrary" class="admonition admonition-manim-example">
785
+ <p class="admonition-title">Example: LaTeXTemplateLibrary <a class="headerlink" href="#latextemplatelibrary">¶</a></p>![image](media/images/LaTeXTemplateLibrary-1.png)
786
+ ```python
787
+ from manim import *
788
+
789
+ class LaTeXTemplateLibrary(Scene):
790
+ def construct(self):
791
+ tex = Tex('Hello 你好 \\LaTeX', tex_template=TexTemplateLibrary.ctex, font_size=144)
792
+ self.add(tex)
793
+ ```
794
+
795
+ <pre data-manim-binder data-manim-classname="LaTeXTemplateLibrary">
796
+ class LaTeXTemplateLibrary(Scene):
797
+ def construct(self):
798
+ tex = Tex('Hello 你好 \\\\LaTeX', tex_template=TexTemplateLibrary.ctex, font_size=144)
799
+ self.add(tex)
800
+
801
+ </pre></div>
802
+
803
+ ### Aligning formulae
804
+
805
+ [`MathTex`](../reference/manim.mobject.text.tex_mobject.MathTex.md#manim.mobject.text.tex_mobject.MathTex) mobject is typeset in the LaTeX `align*`
806
+ environment. This means you can use the `&` alignment character
807
+ when typesetting multiline formulae:
808
+
809
+ <div id="latexalignenvironment" class="admonition admonition-manim-example">
810
+ <p class="admonition-title">Example: LaTeXAlignEnvironment <a class="headerlink" href="#latexalignenvironment">¶</a></p>![image](media/images/LaTeXAlignEnvironment-1.png)
811
+ ```python
812
+ from manim import *
813
+
814
+ class LaTeXAlignEnvironment(Scene):
815
+ def construct(self):
816
+ tex = MathTex(r'f(x) &= 3 + 2 + 1\\ &= 5 + 1 \\ &= 6', font_size=96)
817
+ self.add(tex)
818
+ ```
819
+
820
+ <pre data-manim-binder data-manim-classname="LaTeXAlignEnvironment">
821
+ class LaTeXAlignEnvironment(Scene):
822
+ def construct(self):
823
+ tex = MathTex(r'f(x) &= 3 + 2 + 1\\\\ &= 5 + 1 \\\\ &= 6', font_size=96)
824
+ self.add(tex)
825
+
826
+ </pre></div>
data/rag/manim_docs/manim_core/docs/reference/.DS_Store ADDED
Binary file (6.15 kB). View file
 
data/rag/manim_docs/manim_core/docs/reference/manim._config.logger_utils.JSONFormatter.md ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # JSONFormatter
2
+
3
+ Qualified name: `manim.\_config.logger\_utils.JSONFormatter`
4
+
5
+ ### *class* JSONFormatter(fmt=None, datefmt=None, style='%', validate=True, \*, defaults=None)
6
+
7
+ Bases: `Formatter`
8
+
9
+ A formatter that outputs logs in a custom JSON format.
10
+
11
+ This class is used internally for testing purposes.
12
+
13
+ Initialize the formatter with specified format strings.
14
+
15
+ Initialize the formatter either with the specified format string, or a
16
+ default as described above. Allow for specialized date formatting with
17
+ the optional datefmt argument. If datefmt is omitted, you get an
18
+ ISO8601-like (or RFC 3339-like) format.
19
+
20
+ Use a style parameter of ‘%’, ‘{’ or ‘$’ to specify that you want to
21
+ use one of %-formatting, `str.format()` (`{}`) formatting or
22
+ `string.Template` formatting in your format string.
23
+
24
+ #### Versionchanged
25
+ Changed in version 3.2: Added the `style` parameter.
26
+
27
+ ### Methods
28
+
29
+ | [`format`](#manim._config.logger_utils.JSONFormatter.format) | Format the record in a custom JSON format. |
30
+ |----------------------------------------------------------------|----------------------------------------------|
31
+
32
+ ### Attributes
33
+
34
+ | `default_msec_format` | |
35
+ |-------------------------|----|
36
+ | `default_time_format` | |
37
+
38
+ #### format(record)
39
+
40
+ Format the record in a custom JSON format.
41
+
42
+ * **Parameters:**
43
+ **record** (*LogRecord*)
44
+ * **Return type:**
45
+ str
data/rag/manim_docs/manim_core/docs/reference/manim._config.logger_utils.md ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # logger_utils
2
+
3
+ Utilities to create and set the logger.
4
+
5
+ Manim’s logger can be accessed as `manim.logger`, or as
6
+ `logging.getLogger("manim")`, once the library has been imported. Manim also
7
+ exports a second object, `console`, which should be used to print on screen
8
+ messages that need not be logged.
9
+
10
+ Both `logger` and `console` use the `rich` library to produce rich text
11
+ format.
12
+
13
+ ### Classes
14
+
15
+ | [`JSONFormatter`](manim._config.logger_utils.JSONFormatter.md#manim._config.logger_utils.JSONFormatter) | A formatter that outputs logs in a custom JSON format. |
16
+ |-----------------------------------------------------------------------------------------------------------|----------------------------------------------------------|
17
+
18
+ ### Functions
19
+
20
+ ### make_logger(parser, verbosity)
21
+
22
+ Make the manim logger and console.
23
+
24
+ * **Parameters:**
25
+ * **parser** (*SectionProxy*) – A parser containing any .cfg files in use.
26
+ * **verbosity** (*str*) – The verbosity level of the logger.
27
+ * **Returns:**
28
+ The manim logger and consoles. The first console outputs
29
+ to stdout, the second to stderr. All use the theme returned by
30
+ [`parse_theme()`](#manim._config.logger_utils.parse_theme).
31
+ * **Return type:**
32
+ `logging.Logger`, `rich.Console`, `rich.Console`
33
+
34
+ #### SEE ALSO
35
+ [`make_config_parser()`](manim._config.utils.md#manim._config.utils.make_config_parser), [`parse_theme()`](#manim._config.logger_utils.parse_theme)
36
+
37
+ ### Notes
38
+
39
+ The `parser` is assumed to contain only the options related to
40
+ configuring the logger at the top level.
41
+
42
+ ### parse_theme(parser)
43
+
44
+ Configure the rich style of logger and console output.
45
+
46
+ * **Parameters:**
47
+ **parser** (*SectionProxy*) – A parser containing any .cfg files in use.
48
+ * **Returns:**
49
+ The rich theme to be used by the manim logger.
50
+ * **Return type:**
51
+ `rich.Theme`
52
+
53
+ #### SEE ALSO
54
+ [`make_logger()`](#manim._config.logger_utils.make_logger)
55
+
56
+ ### set_file_logger(scene_name, module_name, log_dir)
57
+
58
+ Add a file handler to manim logger.
59
+
60
+ The path to the file is built using `config.log_dir`.
61
+
62
+ * **Parameters:**
63
+ * **scene_name** (*str*) – The name of the scene, used in the name of the log file.
64
+ * **module_name** (*str*) – The name of the module, used in the name of the log file.
65
+ * **log_dir** (*Path*) – Path to the folder where log files are stored.
66
+ * **Return type:**
67
+ None
data/rag/manim_docs/manim_core/docs/reference/manim._config.md ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # \_config
2
+
3
+ Set the global config and logger.
4
+
5
+ ### Functions
6
+
7
+ ### tempconfig(temp)
8
+
9
+ Context manager that temporarily modifies the global `config` object.
10
+
11
+ Inside the `with` statement, the modified config will be used. After
12
+ context manager exits, the config will be restored to its original state.
13
+
14
+ * **Parameters:**
15
+ **temp** ([*ManimConfig*](manim._config.utils.ManimConfig.md#manim._config.utils.ManimConfig) *|* *dict* *[**str* *,* *Any* *]*) – Object whose keys will be used to temporarily update the global
16
+ `config`.
17
+ * **Return type:**
18
+ *Generator*[None, None, None]
19
+
20
+ ### Examples
21
+
22
+ Use `with tempconfig({...})` to temporarily change the default values of
23
+ certain config options.
24
+
25
+ ```pycon
26
+ >>> config["frame_height"]
27
+ 8.0
28
+ >>> with tempconfig({"frame_height": 100.0}):
29
+ ... print(config["frame_height"])
30
+ 100.0
31
+ >>> config["frame_height"]
32
+ 8.0
33
+ ```
data/rag/manim_docs/manim_core/docs/reference/manim._config.utils.ManimConfig.md ADDED
@@ -0,0 +1,838 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ManimConfig
2
+
3
+ Qualified name: `manim.\_config.utils.ManimConfig`
4
+
5
+ ### *class* ManimConfig
6
+
7
+ Bases: `MutableMapping`
8
+
9
+ Dict-like class storing all config options.
10
+
11
+ The global `config` object is an instance of this class, and acts as a
12
+ single source of truth for all of the library’s customizable behavior.
13
+
14
+ The global `config` object is capable of digesting different types of
15
+ sources and converting them into a uniform interface. These sources are
16
+ (in ascending order of precedence): configuration files, command line
17
+ arguments, and programmatic changes. Regardless of how the user chooses to
18
+ set a config option, she can access its current value using
19
+ [`ManimConfig`](#manim._config.utils.ManimConfig)’s attributes and properties.
20
+
21
+ ### Notes
22
+
23
+ Each config option is implemented as a property of this class.
24
+
25
+ Each config option can be set via a config file, using the full name of the
26
+ property. If a config option has an associated CLI flag, then the flag is
27
+ equal to the full name of the property. Those that admit an alternative
28
+ flag or no flag at all are documented in the individual property’s
29
+ docstring.
30
+
31
+ ### Examples
32
+
33
+ We use a copy of the global configuration object in the following
34
+ examples for the sake of demonstration; you can skip these lines
35
+ and just import `config` directly if you actually want to modify
36
+ the configuration:
37
+
38
+ ```pycon
39
+ >>> from manim import config as global_config
40
+ >>> config = global_config.copy()
41
+ ```
42
+
43
+ Each config option allows for dict syntax and attribute syntax. For
44
+ example, the following two lines are equivalent,
45
+
46
+ ```pycon
47
+ >>> from manim import WHITE
48
+ >>> config.background_color = WHITE
49
+ >>> config["background_color"] = WHITE
50
+ ```
51
+
52
+ The former is preferred; the latter is provided mostly for backwards
53
+ compatibility.
54
+
55
+ The config options are designed to keep internal consistency. For example,
56
+ setting `frame_y_radius` will affect `frame_height`:
57
+
58
+ ```pycon
59
+ >>> config.frame_height
60
+ 8.0
61
+ >>> config.frame_y_radius = 5.0
62
+ >>> config.frame_height
63
+ 10.0
64
+ ```
65
+
66
+ There are many ways of interacting with config options. Take for example
67
+ the config option `background_color`. There are three ways to change it:
68
+ via a config file, via CLI flags, or programmatically.
69
+
70
+ To set the background color via a config file, save the following
71
+ `manim.cfg` file with the following contents.
72
+
73
+ ```default
74
+ [CLI]
75
+ background_color = WHITE
76
+ ```
77
+
78
+ In order to have this `.cfg` file apply to a manim scene, it needs to be
79
+ placed in the same directory as the script,
80
+
81
+ ```bash
82
+ project/
83
+ ├─scene.py
84
+ └─manim.cfg
85
+ ```
86
+
87
+ Now, when the user executes
88
+
89
+ ```bash
90
+ manim scene.py
91
+ ```
92
+
93
+ the background of the scene will be set to `WHITE`. This applies regardless
94
+ of where the manim command is invoked from.
95
+
96
+ Command line arguments override `.cfg` files. In the previous example,
97
+ executing
98
+
99
+ ```bash
100
+ manim scene.py -c BLUE
101
+ ```
102
+
103
+ will set the background color to BLUE, regardless of the contents of
104
+ `manim.cfg`.
105
+
106
+ Finally, any programmatic changes made within the scene script itself will
107
+ override the command line arguments. For example, if `scene.py` contains
108
+ the following
109
+
110
+ ```python
111
+ from manim import *
112
+
113
+ config.background_color = RED
114
+
115
+ class MyScene(Scene): ...
116
+ ```
117
+
118
+ the background color will be set to RED, regardless of the contents of
119
+ `manim.cfg` or the CLI arguments used when invoking manim.
120
+
121
+ ### Methods
122
+
123
+ | [`copy`](#manim._config.utils.ManimConfig.copy) | Deepcopy the contents of this ManimConfig. |
124
+ |-------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------|
125
+ | [`digest_args`](#manim._config.utils.ManimConfig.digest_args) | Process the config options present in CLI arguments. |
126
+ | [`digest_file`](#manim._config.utils.ManimConfig.digest_file) | Process the config options present in a `.cfg` file. |
127
+ | [`digest_parser`](#manim._config.utils.ManimConfig.digest_parser) | Process the config options present in a `ConfigParser` object. |
128
+ | [`get_dir`](#manim._config.utils.ManimConfig.get_dir) | Resolve a config option that stores a directory. |
129
+ | `resolve_movie_file_extension` | |
130
+ | [`update`](#manim._config.utils.ManimConfig.update) | Digest the options found in another [`ManimConfig`](#manim._config.utils.ManimConfig) or in a dict. |
131
+
132
+ ### Attributes
133
+
134
+ | [`aspect_ratio`](#manim._config.utils.ManimConfig.aspect_ratio) | Aspect ratio (width / height) in pixels (--resolution, -r). |
135
+ |---------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------|
136
+ | [`assets_dir`](#manim._config.utils.ManimConfig.assets_dir) | Directory to locate video assets (no flag). |
137
+ | [`background_color`](#manim._config.utils.ManimConfig.background_color) | Background color of the scene (-c). |
138
+ | [`background_opacity`](#manim._config.utils.ManimConfig.background_opacity) | A number between 0.0 (fully transparent) and 1.0 (fully opaque). |
139
+ | [`bottom`](#manim._config.utils.ManimConfig.bottom) | Coordinate at the center bottom of the frame. |
140
+ | [`custom_folders`](#manim._config.utils.ManimConfig.custom_folders) | Whether to use custom folder output. |
141
+ | [`disable_caching`](#manim._config.utils.ManimConfig.disable_caching) | Whether to use scene caching. |
142
+ | [`disable_caching_warning`](#manim._config.utils.ManimConfig.disable_caching_warning) | Whether a warning is raised if there are too much submobjects to hash. |
143
+ | [`dry_run`](#manim._config.utils.ManimConfig.dry_run) | Whether dry run is enabled. |
144
+ | [`enable_gui`](#manim._config.utils.ManimConfig.enable_gui) | Enable GUI interaction. |
145
+ | [`enable_wireframe`](#manim._config.utils.ManimConfig.enable_wireframe) | Whether to enable wireframe debugging mode in opengl. |
146
+ | [`ffmpeg_loglevel`](#manim._config.utils.ManimConfig.ffmpeg_loglevel) | Verbosity level of ffmpeg (no flag). |
147
+ | [`flush_cache`](#manim._config.utils.ManimConfig.flush_cache) | Whether to delete all the cached partial movie files. |
148
+ | [`force_window`](#manim._config.utils.ManimConfig.force_window) | Whether to force window when using the opengl renderer. |
149
+ | [`format`](#manim._config.utils.ManimConfig.format) | File format; "png", "gif", "mp4", "webm" or "mov". |
150
+ | [`frame_height`](#manim._config.utils.ManimConfig.frame_height) | Frame height in logical units (no flag). |
151
+ | [`frame_rate`](#manim._config.utils.ManimConfig.frame_rate) | Frame rate in frames per second. |
152
+ | [`frame_size`](#manim._config.utils.ManimConfig.frame_size) | Tuple with (pixel width, pixel height) (no flag). |
153
+ | [`frame_width`](#manim._config.utils.ManimConfig.frame_width) | Frame width in logical units (no flag). |
154
+ | [`frame_x_radius`](#manim._config.utils.ManimConfig.frame_x_radius) | Half the frame width (no flag). |
155
+ | [`frame_y_radius`](#manim._config.utils.ManimConfig.frame_y_radius) | Half the frame height (no flag). |
156
+ | [`from_animation_number`](#manim._config.utils.ManimConfig.from_animation_number) | Start rendering animations at this number (-n). |
157
+ | [`fullscreen`](#manim._config.utils.ManimConfig.fullscreen) | Expand the window to its maximum possible size. |
158
+ | [`gui_location`](#manim._config.utils.ManimConfig.gui_location) | Enable GUI interaction. |
159
+ | [`images_dir`](#manim._config.utils.ManimConfig.images_dir) | Directory to place images (no flag). |
160
+ | [`input_file`](#manim._config.utils.ManimConfig.input_file) | Input file name. |
161
+ | [`left_side`](#manim._config.utils.ManimConfig.left_side) | Coordinate at the middle left of the frame. |
162
+ | [`log_dir`](#manim._config.utils.ManimConfig.log_dir) | Directory to place logs. |
163
+ | [`log_to_file`](#manim._config.utils.ManimConfig.log_to_file) | Whether to save logs to a file. |
164
+ | [`max_files_cached`](#manim._config.utils.ManimConfig.max_files_cached) | Maximum number of files cached. |
165
+ | [`media_dir`](#manim._config.utils.ManimConfig.media_dir) | Main output directory. |
166
+ | [`media_embed`](#manim._config.utils.ManimConfig.media_embed) | Whether to embed videos in Jupyter notebook. |
167
+ | [`media_width`](#manim._config.utils.ManimConfig.media_width) | Media width in Jupyter notebook. |
168
+ | [`movie_file_extension`](#manim._config.utils.ManimConfig.movie_file_extension) | Either .mp4, .webm or .mov. |
169
+ | [`no_latex_cleanup`](#manim._config.utils.ManimConfig.no_latex_cleanup) | Prevents deletion of .aux, .dvi, and .log files produced by Tex and MathTex. |
170
+ | [`notify_outdated_version`](#manim._config.utils.ManimConfig.notify_outdated_version) | Whether to notify if there is a version update available. |
171
+ | [`output_file`](#manim._config.utils.ManimConfig.output_file) | Output file name (-o). |
172
+ | [`partial_movie_dir`](#manim._config.utils.ManimConfig.partial_movie_dir) | Directory to place partial movie files (no flag). |
173
+ | [`pixel_height`](#manim._config.utils.ManimConfig.pixel_height) | Frame height in pixels (--resolution, -r). |
174
+ | [`pixel_width`](#manim._config.utils.ManimConfig.pixel_width) | Frame width in pixels (--resolution, -r). |
175
+ | [`plugins`](#manim._config.utils.ManimConfig.plugins) | List of plugins to enable. |
176
+ | [`preview`](#manim._config.utils.ManimConfig.preview) | Whether to play the rendered movie (-p). |
177
+ | `preview_command` | |
178
+ | [`progress_bar`](#manim._config.utils.ManimConfig.progress_bar) | Whether to show progress bars while rendering animations. |
179
+ | [`quality`](#manim._config.utils.ManimConfig.quality) | Video quality (-q). |
180
+ | [`renderer`](#manim._config.utils.ManimConfig.renderer) | The currently active renderer. |
181
+ | [`right_side`](#manim._config.utils.ManimConfig.right_side) | Coordinate at the middle right of the frame. |
182
+ | [`save_as_gif`](#manim._config.utils.ManimConfig.save_as_gif) | Whether to save the rendered scene in .gif format (-i). |
183
+ | [`save_last_frame`](#manim._config.utils.ManimConfig.save_last_frame) | Whether to save the last frame of the scene as an image file (-s). |
184
+ | [`save_pngs`](#manim._config.utils.ManimConfig.save_pngs) | Whether to save all frames in the scene as images files (-g). |
185
+ | [`save_sections`](#manim._config.utils.ManimConfig.save_sections) | Whether to save single videos for each section in addition to the movie file. |
186
+ | [`scene_names`](#manim._config.utils.ManimConfig.scene_names) | Scenes to play from file. |
187
+ | [`sections_dir`](#manim._config.utils.ManimConfig.sections_dir) | Directory to place section videos (no flag). |
188
+ | [`show_in_file_browser`](#manim._config.utils.ManimConfig.show_in_file_browser) | Whether to show the output file in the file browser (-f). |
189
+ | [`tex_dir`](#manim._config.utils.ManimConfig.tex_dir) | Directory to place tex (no flag). |
190
+ | [`tex_template`](#manim._config.utils.ManimConfig.tex_template) | Template used when rendering Tex. |
191
+ | [`tex_template_file`](#manim._config.utils.ManimConfig.tex_template_file) | File to read Tex template from (no flag). |
192
+ | [`text_dir`](#manim._config.utils.ManimConfig.text_dir) | Directory to place text (no flag). |
193
+ | [`top`](#manim._config.utils.ManimConfig.top) | Coordinate at the center top of the frame. |
194
+ | [`transparent`](#manim._config.utils.ManimConfig.transparent) | Whether the background opacity is less than 1.0 (-t). |
195
+ | [`upto_animation_number`](#manim._config.utils.ManimConfig.upto_animation_number) | Stop rendering animations at this number. |
196
+ | [`use_projection_fill_shaders`](#manim._config.utils.ManimConfig.use_projection_fill_shaders) | Use shaders for OpenGLVMobject fill which are compatible with transformation matrices. |
197
+ | [`use_projection_stroke_shaders`](#manim._config.utils.ManimConfig.use_projection_stroke_shaders) | Use shaders for OpenGLVMobject stroke which are compatible with transformation matrices. |
198
+ | [`verbosity`](#manim._config.utils.ManimConfig.verbosity) | Logger verbosity; "DEBUG", "INFO", "WARNING", "ERROR", or "CRITICAL" (-v). |
199
+ | [`video_dir`](#manim._config.utils.ManimConfig.video_dir) | Directory to place videos (no flag). |
200
+ | [`window_monitor`](#manim._config.utils.ManimConfig.window_monitor) | The monitor on which the scene will be rendered. |
201
+ | [`window_position`](#manim._config.utils.ManimConfig.window_position) | Set the position of preview window. |
202
+ | [`window_size`](#manim._config.utils.ManimConfig.window_size) | The size of the opengl window. |
203
+ | [`write_all`](#manim._config.utils.ManimConfig.write_all) | Whether to render all scenes in the input file (-a). |
204
+ | [`write_to_movie`](#manim._config.utils.ManimConfig.write_to_movie) | Whether to render the scene to a movie file (-w). |
205
+ | [`zero_pad`](#manim._config.utils.ManimConfig.zero_pad) | PNG zero padding. |
206
+
207
+ #### \_set_between(key, val, lo, hi)
208
+
209
+ Set `key` to `val` if lo <= val <= hi.
210
+
211
+ * **Parameters:**
212
+ * **key** (*str*)
213
+ * **val** (*float*)
214
+ * **lo** (*float*)
215
+ * **hi** (*float*)
216
+ * **Return type:**
217
+ None
218
+
219
+ #### \_set_boolean(key, val)
220
+
221
+ Set `key` to `val` if `val` is Boolean.
222
+
223
+ * **Parameters:**
224
+ * **key** (*str*)
225
+ * **val** (*Any*)
226
+ * **Return type:**
227
+ None
228
+
229
+ #### \_set_from_enum(key, enum_value, enum_class)
230
+
231
+ Set `key` to the enum object with value `enum_value` in the given
232
+ `enum_class`.
233
+
234
+ Tests:
235
+
236
+ ```default
237
+ >>> from enum import Enum
238
+ >>> class Fruit(Enum):
239
+ ... APPLE = 1
240
+ ... BANANA = 2
241
+ ... CANTALOUPE = 3
242
+ >>> test_config = ManimConfig()
243
+ >>> test_config._set_from_enum("fruit", 1, Fruit)
244
+ >>> test_config._d['fruit']
245
+ <Fruit.APPLE: 1>
246
+ >>> test_config._set_from_enum("fruit", Fruit.BANANA, Fruit)
247
+ >>> test_config._d['fruit']
248
+ <Fruit.BANANA: 2>
249
+ >>> test_config._set_from_enum("fruit", 42, Fruit)
250
+ Traceback (most recent call last):
251
+ ...
252
+ ValueError: 42 is not a valid Fruit
253
+ ```
254
+
255
+ * **Parameters:**
256
+ * **key** (*str*)
257
+ * **enum_value** (*Any*)
258
+ * **enum_class** (*EnumMeta*)
259
+ * **Return type:**
260
+ None
261
+
262
+ #### \_set_from_list(key, val, values)
263
+
264
+ Set `key` to `val` if `val` is contained in `values`.
265
+
266
+ * **Parameters:**
267
+ * **key** (*str*)
268
+ * **val** (*Any*)
269
+ * **values** (*list* *[**Any* *]*)
270
+ * **Return type:**
271
+ None
272
+
273
+ #### \_set_int_between(key, val, lo, hi)
274
+
275
+ Set `key` to `val` if lo <= val <= hi.
276
+
277
+ * **Parameters:**
278
+ * **key** (*str*)
279
+ * **val** (*int*)
280
+ * **lo** (*int*)
281
+ * **hi** (*int*)
282
+ * **Return type:**
283
+ None
284
+
285
+ #### \_set_pos_number(key, val, allow_inf)
286
+
287
+ Set `key` to `val` if `val` is a positive integer.
288
+
289
+ * **Parameters:**
290
+ * **key** (*str*)
291
+ * **val** (*int*)
292
+ * **allow_inf** (*bool*)
293
+ * **Return type:**
294
+ None
295
+
296
+ #### \_set_str(key, val)
297
+
298
+ Set `key` to `val` if `val` is a string.
299
+
300
+ * **Parameters:**
301
+ * **key** (*str*)
302
+ * **val** (*Any*)
303
+ * **Return type:**
304
+ None
305
+
306
+ #### *property* aspect_ratio *: int*
307
+
308
+ Aspect ratio (width / height) in pixels (–resolution, -r).
309
+
310
+ #### *property* assets_dir *: str*
311
+
312
+ Directory to locate video assets (no flag).
313
+
314
+ #### *property* background_color *: [ManimColor](manim.utils.color.core.ManimColor.md#manim.utils.color.core.ManimColor)*
315
+
316
+ Background color of the scene (-c).
317
+
318
+ #### *property* background_opacity *: float*
319
+
320
+ A number between 0.0 (fully transparent) and 1.0 (fully opaque).
321
+
322
+ #### *property* bottom *: [Vector3D](manim.typing.md#manim.typing.Vector3D)*
323
+
324
+ Coordinate at the center bottom of the frame.
325
+
326
+ #### copy()
327
+
328
+ Deepcopy the contents of this ManimConfig.
329
+
330
+ * **Returns:**
331
+ A copy of this object containing no shared references.
332
+ * **Return type:**
333
+ [`ManimConfig`](#manim._config.utils.ManimConfig)
334
+
335
+ #### SEE ALSO
336
+ `tempconfig()`
337
+
338
+ ### Notes
339
+
340
+ This is the main mechanism behind `tempconfig()`.
341
+
342
+ #### *property* custom_folders *: str*
343
+
344
+ Whether to use custom folder output.
345
+
346
+ #### digest_args(args)
347
+
348
+ Process the config options present in CLI arguments.
349
+
350
+ * **Parameters:**
351
+ **args** (*argparse.Namespace*) – An object returned by `main_utils.parse_args()`.
352
+ * **Returns:**
353
+ **self** – This object, after processing the contents of `parser`.
354
+ * **Return type:**
355
+ [`ManimConfig`](#manim._config.utils.ManimConfig)
356
+
357
+ #### SEE ALSO
358
+ `main_utils.parse_args()`, [`digest_parser()`](#manim._config.utils.ManimConfig.digest_parser),
359
+ [`digest_file()`](#manim._config.utils.ManimConfig.digest_file)
360
+
361
+ ### Notes
362
+
363
+ If `args.config_file` is a non-empty string, `ManimConfig` tries to digest the
364
+ contents of said file with [`digest_file()`](#manim._config.utils.ManimConfig.digest_file) before
365
+ digesting any other CLI arguments.
366
+
367
+ #### digest_file(filename)
368
+
369
+ Process the config options present in a `.cfg` file.
370
+
371
+ This method processes a single `.cfg` file, whereas
372
+ [`digest_parser()`](#manim._config.utils.ManimConfig.digest_parser) can process arbitrary parsers, built
373
+ perhaps from multiple `.cfg` files.
374
+
375
+ * **Parameters:**
376
+ **filename** ([*StrPath*](manim.typing.md#manim.typing.StrPath)) – Path to the `.cfg` file.
377
+ * **Returns:**
378
+ **self** – This object, after processing the contents of `filename`.
379
+ * **Return type:**
380
+ [`ManimConfig`](#manim._config.utils.ManimConfig)
381
+
382
+ #### SEE ALSO
383
+ [`digest_file()`](#manim._config.utils.ManimConfig.digest_file), [`digest_args()`](#manim._config.utils.ManimConfig.digest_args), [`make_config_parser()`](manim._config.utils.md#manim._config.utils.make_config_parser)
384
+
385
+ ### Notes
386
+
387
+ If there are multiple `.cfg` files to process, it is always more
388
+ efficient to parse them into a single `ConfigParser` object
389
+ first and digesting them with one call to
390
+ [`digest_parser()`](#manim._config.utils.ManimConfig.digest_parser), instead of calling this method
391
+ multiple times.
392
+
393
+ #### digest_parser(parser)
394
+
395
+ Process the config options present in a `ConfigParser` object.
396
+
397
+ This method processes arbitrary parsers, not only those read from a
398
+ single file, whereas [`digest_file()`](#manim._config.utils.ManimConfig.digest_file) can only process one
399
+ file at a time.
400
+
401
+ * **Parameters:**
402
+ **parser** (*configparser.ConfigParser*) – An object reflecting the contents of one or many `.cfg` files. In
403
+ particular, it may reflect the contents of multiple files that have
404
+ been parsed in a cascading fashion.
405
+ * **Returns:**
406
+ **self** – This object, after processing the contents of `parser`.
407
+ * **Return type:**
408
+ [`ManimConfig`](#manim._config.utils.ManimConfig)
409
+
410
+ #### SEE ALSO
411
+ [`make_config_parser()`](manim._config.utils.md#manim._config.utils.make_config_parser), [`digest_file()`](#manim._config.utils.ManimConfig.digest_file), [`digest_args()`](#manim._config.utils.ManimConfig.digest_args)
412
+
413
+ ### Notes
414
+
415
+ If there are multiple `.cfg` files to process, it is always more
416
+ efficient to parse them into a single `ConfigParser` object
417
+ first, and then call this function once (instead of calling
418
+ [`digest_file()`](#manim._config.utils.ManimConfig.digest_file) multiple times).
419
+
420
+ ### Examples
421
+
422
+ To digest the config options set in two files, first create a
423
+ ConfigParser and parse both files and then digest the parser:
424
+
425
+ ```python
426
+ parser = configparser.ConfigParser()
427
+ parser.read([file1, file2])
428
+ config = ManimConfig().digest_parser(parser)
429
+ ```
430
+
431
+ In fact, the global `config` object is initialized like so:
432
+
433
+ ```python
434
+ parser = make_config_parser()
435
+ config = ManimConfig().digest_parser(parser)
436
+ ```
437
+
438
+ #### *property* disable_caching *: bool*
439
+
440
+ Whether to use scene caching.
441
+
442
+ #### *property* disable_caching_warning *: bool*
443
+
444
+ Whether a warning is raised if there are too much submobjects to hash.
445
+
446
+ #### *property* dry_run *: bool*
447
+
448
+ Whether dry run is enabled.
449
+
450
+ #### *property* enable_gui *: bool*
451
+
452
+ Enable GUI interaction.
453
+
454
+ #### *property* enable_wireframe *: bool*
455
+
456
+ Whether to enable wireframe debugging mode in opengl.
457
+
458
+ #### *property* ffmpeg_loglevel *: str*
459
+
460
+ Verbosity level of ffmpeg (no flag).
461
+
462
+ #### *property* flush_cache *: bool*
463
+
464
+ Whether to delete all the cached partial movie files.
465
+
466
+ #### *property* force_window *: bool*
467
+
468
+ Whether to force window when using the opengl renderer.
469
+
470
+ #### *property* format *: str*
471
+
472
+ File format; “png”, “gif”, “mp4”, “webm” or “mov”.
473
+
474
+ #### *property* frame_height *: float*
475
+
476
+ Frame height in logical units (no flag).
477
+
478
+ #### *property* frame_rate *: float*
479
+
480
+ Frame rate in frames per second.
481
+
482
+ #### *property* frame_size *: tuple[int, int]*
483
+
484
+ Tuple with (pixel width, pixel height) (no flag).
485
+
486
+ #### *property* frame_width *: float*
487
+
488
+ Frame width in logical units (no flag).
489
+
490
+ #### *property* frame_x_radius *: float*
491
+
492
+ Half the frame width (no flag).
493
+
494
+ #### *property* frame_y_radius *: float*
495
+
496
+ Half the frame height (no flag).
497
+
498
+ #### *property* from_animation_number *: int*
499
+
500
+ Start rendering animations at this number (-n).
501
+
502
+ #### *property* fullscreen *: bool*
503
+
504
+ Expand the window to its maximum possible size.
505
+
506
+ #### get_dir(key, \*\*kwargs)
507
+
508
+ Resolve a config option that stores a directory.
509
+
510
+ Config options that store directories may depend on one another. This
511
+ method is used to provide the actual directory to the end user.
512
+
513
+ * **Parameters:**
514
+ * **key** (*str*) – The config option to be resolved. Must be an option ending in
515
+ `'_dir'`, for example `'media_dir'` or `'video_dir'`.
516
+ * **kwargs** (*Any*) – Any strings to be used when resolving the directory.
517
+ * **Returns:**
518
+ Path to the requested directory. If the path resolves to the empty
519
+ string, return `None` instead.
520
+ * **Return type:**
521
+ `pathlib.Path`
522
+ * **Raises:**
523
+ **KeyError** – When `key` is not a config option that stores a directory and
524
+ thus [`get_dir()`](#manim._config.utils.ManimConfig.get_dir) is not appropriate; or when
525
+ `key` is appropriate but there is not enough information to
526
+ resolve the directory.
527
+
528
+ ### Notes
529
+
530
+ Standard `str.format()` syntax is used to resolve the paths so the
531
+ paths may contain arbitrary placeholders using f-string notation.
532
+ However, these will require `kwargs` to contain the required values.
533
+
534
+ ### Examples
535
+
536
+ The value of `config.tex_dir` is `'{media_dir}/Tex'` by default,
537
+ i.e. it is a subfolder of wherever `config.media_dir` is located. In
538
+ order to get the *actual* directory, use [`get_dir()`](#manim._config.utils.ManimConfig.get_dir).
539
+
540
+ ```pycon
541
+ >>> from manim import config as globalconfig
542
+ >>> config = globalconfig.copy()
543
+ >>> config.tex_dir
544
+ '{media_dir}/Tex'
545
+ >>> config.media_dir
546
+ './media'
547
+ >>> config.get_dir("tex_dir").as_posix()
548
+ 'media/Tex'
549
+ ```
550
+
551
+ Resolving directories is done in a lazy way, at the last possible
552
+ moment, to reflect any changes in other config options:
553
+
554
+ ```pycon
555
+ >>> config.media_dir = "my_media_dir"
556
+ >>> config.get_dir("tex_dir").as_posix()
557
+ 'my_media_dir/Tex'
558
+ ```
559
+
560
+ Some directories depend on information that is not available to
561
+ [`ManimConfig`](#manim._config.utils.ManimConfig). For example, the default value of video_dir
562
+ includes the name of the input file and the video quality
563
+ (e.g. 480p15). This informamtion has to be supplied via `kwargs`:
564
+
565
+ ```pycon
566
+ >>> config.video_dir
567
+ '{media_dir}/videos/{module_name}/{quality}'
568
+ >>> config.get_dir("video_dir")
569
+ Traceback (most recent call last):
570
+ KeyError: 'video_dir {media_dir}/videos/{module_name}/{quality} requires the following keyword arguments: module_name'
571
+ >>> config.get_dir("video_dir", module_name="myfile").as_posix()
572
+ 'my_media_dir/videos/myfile/1080p60'
573
+ ```
574
+
575
+ Note the quality does not need to be passed as keyword argument since
576
+ [`ManimConfig`](#manim._config.utils.ManimConfig) does store information about quality.
577
+
578
+ Directories may be recursively defined. For example, the config option
579
+ `partial_movie_dir` depends on `video_dir`, which in turn depends
580
+ on `media_dir`:
581
+
582
+ ```pycon
583
+ >>> config.partial_movie_dir
584
+ '{video_dir}/partial_movie_files/{scene_name}'
585
+ >>> config.get_dir("partial_movie_dir")
586
+ Traceback (most recent call last):
587
+ KeyError: 'partial_movie_dir {video_dir}/partial_movie_files/{scene_name} requires the following keyword arguments: scene_name'
588
+ >>> config.get_dir(
589
+ ... "partial_movie_dir", module_name="myfile", scene_name="myscene"
590
+ ... ).as_posix()
591
+ 'my_media_dir/videos/myfile/1080p60/partial_movie_files/myscene'
592
+ ```
593
+
594
+ Standard f-string syntax is used. Arbitrary names can be used when
595
+ defining directories, as long as the corresponding values are passed to
596
+ [`ManimConfig.get_dir()`](#manim._config.utils.ManimConfig.get_dir) via `kwargs`.
597
+
598
+ ```pycon
599
+ >>> config.media_dir = "{dir1}/{dir2}"
600
+ >>> config.get_dir("media_dir")
601
+ Traceback (most recent call last):
602
+ KeyError: 'media_dir {dir1}/{dir2} requires the following keyword arguments: dir1'
603
+ >>> config.get_dir("media_dir", dir1="foo", dir2="bar").as_posix()
604
+ 'foo/bar'
605
+ >>> config.media_dir = "./media"
606
+ >>> config.get_dir("media_dir").as_posix()
607
+ 'media'
608
+ ```
609
+
610
+ #### *property* gui_location *: tuple[Any]*
611
+
612
+ Enable GUI interaction.
613
+
614
+ #### *property* images_dir *: str*
615
+
616
+ Directory to place images (no flag). See [`ManimConfig.get_dir()`](#manim._config.utils.ManimConfig.get_dir).
617
+
618
+ #### *property* input_file *: str*
619
+
620
+ Input file name.
621
+
622
+ #### *property* left_side *: [Vector3D](manim.typing.md#manim.typing.Vector3D)*
623
+
624
+ Coordinate at the middle left of the frame.
625
+
626
+ #### *property* log_dir *: str*
627
+
628
+ Directory to place logs. See [`ManimConfig.get_dir()`](#manim._config.utils.ManimConfig.get_dir).
629
+
630
+ #### *property* log_to_file *: bool*
631
+
632
+ Whether to save logs to a file.
633
+
634
+ #### *property* max_files_cached *: int*
635
+
636
+ Maximum number of files cached. Use -1 for infinity (no flag).
637
+
638
+ #### *property* media_dir *: str*
639
+
640
+ Main output directory. See [`ManimConfig.get_dir()`](#manim._config.utils.ManimConfig.get_dir).
641
+
642
+ #### *property* media_embed *: bool*
643
+
644
+ Whether to embed videos in Jupyter notebook.
645
+
646
+ #### *property* media_width *: str*
647
+
648
+ Media width in Jupyter notebook.
649
+
650
+ #### *property* movie_file_extension *: str*
651
+
652
+ Either .mp4, .webm or .mov.
653
+
654
+ #### *property* no_latex_cleanup *: bool*
655
+
656
+ Prevents deletion of .aux, .dvi, and .log files produced by Tex and MathTex.
657
+
658
+ #### *property* notify_outdated_version *: bool*
659
+
660
+ Whether to notify if there is a version update available.
661
+
662
+ #### *property* output_file *: str*
663
+
664
+ Output file name (-o).
665
+
666
+ #### *property* partial_movie_dir *: str*
667
+
668
+ Directory to place partial movie files (no flag). See [`ManimConfig.get_dir()`](#manim._config.utils.ManimConfig.get_dir).
669
+
670
+ #### *property* pixel_height *: int*
671
+
672
+ Frame height in pixels (–resolution, -r).
673
+
674
+ #### *property* pixel_width *: int*
675
+
676
+ Frame width in pixels (–resolution, -r).
677
+
678
+ #### *property* plugins *: list[str]*
679
+
680
+ List of plugins to enable.
681
+
682
+ #### *property* preview *: bool*
683
+
684
+ Whether to play the rendered movie (-p).
685
+
686
+ #### *property* progress_bar *: str*
687
+
688
+ Whether to show progress bars while rendering animations.
689
+
690
+ #### *property* quality *: str | None*
691
+
692
+ Video quality (-q).
693
+
694
+ #### *property* renderer *: [RendererType](manim.constants.RendererType.md#manim.constants.RendererType)*
695
+
696
+ The currently active renderer.
697
+
698
+ Populated with one of the available renderers in [`RendererType`](manim.constants.RendererType.md#manim.constants.RendererType).
699
+
700
+ Tests:
701
+
702
+ ```default
703
+ >>> test_config = ManimConfig()
704
+ >>> test_config.renderer is None # a new ManimConfig is unpopulated
705
+ True
706
+ >>> test_config.renderer = 'opengl'
707
+ >>> test_config.renderer
708
+ <RendererType.OPENGL: 'opengl'>
709
+ >>> test_config.renderer = 42
710
+ Traceback (most recent call last):
711
+ ...
712
+ ValueError: 42 is not a valid RendererType
713
+ ```
714
+
715
+ Check that capitalization of renderer types is irrelevant:
716
+
717
+ ```default
718
+ >>> test_config.renderer = 'OpenGL'
719
+ >>> test_config.renderer = 'cAirO'
720
+ ```
721
+
722
+ #### *property* right_side *: [Vector3D](manim.typing.md#manim.typing.Vector3D)*
723
+
724
+ Coordinate at the middle right of the frame.
725
+
726
+ #### *property* save_as_gif *: bool*
727
+
728
+ Whether to save the rendered scene in .gif format (-i).
729
+
730
+ #### *property* save_last_frame *: bool*
731
+
732
+ Whether to save the last frame of the scene as an image file (-s).
733
+
734
+ #### *property* save_pngs *: bool*
735
+
736
+ Whether to save all frames in the scene as images files (-g).
737
+
738
+ #### *property* save_sections *: bool*
739
+
740
+ Whether to save single videos for each section in addition to the movie file.
741
+
742
+ #### *property* scene_names *: list[str]*
743
+
744
+ Scenes to play from file.
745
+
746
+ #### *property* sections_dir *: str*
747
+
748
+ Directory to place section videos (no flag). See [`ManimConfig.get_dir()`](#manim._config.utils.ManimConfig.get_dir).
749
+
750
+ #### *property* show_in_file_browser *: bool*
751
+
752
+ Whether to show the output file in the file browser (-f).
753
+
754
+ #### *property* tex_dir *: str*
755
+
756
+ Directory to place tex (no flag). See [`ManimConfig.get_dir()`](#manim._config.utils.ManimConfig.get_dir).
757
+
758
+ #### *property* tex_template *: [TexTemplate](manim.utils.tex.TexTemplate.md#manim.utils.tex.TexTemplate)*
759
+
760
+ Template used when rendering Tex. See [`TexTemplate`](manim.utils.tex.TexTemplate.md#manim.utils.tex.TexTemplate).
761
+
762
+ #### *property* tex_template_file *: Path*
763
+
764
+ File to read Tex template from (no flag). See [`TexTemplate`](manim.utils.tex.TexTemplate.md#manim.utils.tex.TexTemplate).
765
+
766
+ #### *property* text_dir *: str*
767
+
768
+ Directory to place text (no flag). See [`ManimConfig.get_dir()`](#manim._config.utils.ManimConfig.get_dir).
769
+
770
+ #### *property* top *: [Vector3D](manim.typing.md#manim.typing.Vector3D)*
771
+
772
+ Coordinate at the center top of the frame.
773
+
774
+ #### *property* transparent *: bool*
775
+
776
+ Whether the background opacity is less than 1.0 (-t).
777
+
778
+ #### update(obj)
779
+
780
+ Digest the options found in another [`ManimConfig`](#manim._config.utils.ManimConfig) or in a dict.
781
+
782
+ Similar to `dict.update()`, replaces the values of this object with
783
+ those of `obj`.
784
+
785
+ * **Parameters:**
786
+ **obj** ([*ManimConfig*](#manim._config.utils.ManimConfig) *|* *dict* *[**str* *,* *Any* *]*) – The object to copy values from.
787
+ * **Return type:**
788
+ None
789
+ * **Raises:**
790
+ **AttributeError** – If `obj` is a dict but contains keys that do not belong to any
791
+ config options.
792
+
793
+ #### SEE ALSO
794
+ [`digest_file()`](#manim._config.utils.ManimConfig.digest_file), [`digest_args()`](#manim._config.utils.ManimConfig.digest_args), [`digest_parser()`](#manim._config.utils.ManimConfig.digest_parser)
795
+
796
+ #### *property* upto_animation_number *: int*
797
+
798
+ Stop rendering animations at this number. Use -1 to avoid skipping (-n).
799
+
800
+ #### *property* use_projection_fill_shaders *: bool*
801
+
802
+ Use shaders for OpenGLVMobject fill which are compatible with transformation matrices.
803
+
804
+ #### *property* use_projection_stroke_shaders *: bool*
805
+
806
+ Use shaders for OpenGLVMobject stroke which are compatible with transformation matrices.
807
+
808
+ #### *property* verbosity *: str*
809
+
810
+ Logger verbosity; “DEBUG”, “INFO”, “WARNING”, “ERROR”, or “CRITICAL” (-v).
811
+
812
+ #### *property* video_dir *: str*
813
+
814
+ Directory to place videos (no flag). See [`ManimConfig.get_dir()`](#manim._config.utils.ManimConfig.get_dir).
815
+
816
+ #### *property* window_monitor *: int*
817
+
818
+ The monitor on which the scene will be rendered.
819
+
820
+ #### *property* window_position *: str*
821
+
822
+ Set the position of preview window. You can use directions, e.g. UL/DR/ORIGIN/LEFT…or the position(pixel) of the upper left corner of the window, e.g. ‘960,540’.
823
+
824
+ #### *property* window_size *: str*
825
+
826
+ The size of the opengl window. ‘default’ to automatically scale the window based on the display monitor.
827
+
828
+ #### *property* write_all *: bool*
829
+
830
+ Whether to render all scenes in the input file (-a).
831
+
832
+ #### *property* write_to_movie *: bool*
833
+
834
+ Whether to render the scene to a movie file (-w).
835
+
836
+ #### *property* zero_pad *: int*
837
+
838
+ PNG zero padding. A number between 0 (no zero padding) and 9 (9 columns minimum).
data/rag/manim_docs/manim_core/docs/reference/manim._config.utils.ManimFrame.md ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ManimFrame
2
+
3
+ Qualified name: `manim.\_config.utils.ManimFrame`
4
+
5
+ ### *class* ManimFrame(c)
6
+
7
+ Bases: `Mapping`
8
+
9
+ ### Methods
10
+
11
+ ### Attributes
12
+
13
+ | `DL` | |
14
+ |------------------|----|
15
+ | `DOWN` | |
16
+ | `DR` | |
17
+ | `IN` | |
18
+ | `LEFT` | |
19
+ | `ORIGIN` | |
20
+ | `OUT` | |
21
+ | `RIGHT` | |
22
+ | `UL` | |
23
+ | `UP` | |
24
+ | `UR` | |
25
+ | `X_AXIS` | |
26
+ | `Y_AXIS` | |
27
+ | `Z_AXIS` | |
28
+ | `aspect_ratio` | |
29
+ | `bottom` | |
30
+ | `frame_height` | |
31
+ | `frame_width` | |
32
+ | `frame_x_radius` | |
33
+ | `frame_y_radius` | |
34
+ | `left_side` | |
35
+ | `pixel_height` | |
36
+ | `pixel_width` | |
37
+ | `right_side` | |
38
+ | `top` | |
39
+ * **Parameters:**
40
+ **c** ([*ManimConfig*](manim._config.utils.ManimConfig.md#manim._config.utils.ManimConfig))
data/rag/manim_docs/manim_core/docs/reference/manim._config.utils.md ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # utils
2
+
3
+ Utilities to create and set the config.
4
+
5
+ The main class exported by this module is [`ManimConfig`](manim._config.utils.ManimConfig.md#manim._config.utils.ManimConfig). This class
6
+ contains all configuration options, including frame geometry (e.g. frame
7
+ height/width, frame rate), output (e.g. directories, logging), styling
8
+ (e.g. background color, transparency), and general behavior (e.g. writing a
9
+ movie vs writing a single frame).
10
+
11
+ See [Configuration](../guides/configuration.md) for an introduction to Manim’s configuration system.
12
+
13
+ ### Classes
14
+
15
+ | [`ManimConfig`](manim._config.utils.ManimConfig.md#manim._config.utils.ManimConfig) | Dict-like class storing all config options. |
16
+ |---------------------------------------------------------------------------------------|-----------------------------------------------|
17
+ | [`ManimFrame`](manim._config.utils.ManimFrame.md#manim._config.utils.ManimFrame) | |
18
+
19
+ ### Functions
20
+
21
+ ### config_file_paths()
22
+
23
+ The paths where `.cfg` files will be searched for.
24
+
25
+ When manim is first imported, it processes any `.cfg` files it finds. This
26
+ function returns the locations in which these files are searched for. In
27
+ ascending order of precedence, these are: the library-wide config file, the
28
+ user-wide config file, and the folder-wide config file.
29
+
30
+ The library-wide config file determines manim’s default behavior. The
31
+ user-wide config file is stored in the user’s home folder, and determines
32
+ the behavior of manim whenever the user invokes it from anywhere in the
33
+ system. The folder-wide config file only affects scenes that are in the
34
+ same folder. The latter two files are optional.
35
+
36
+ These files, if they exist, are meant to loaded into a single
37
+ `configparser.ConfigParser` object, and then processed by
38
+ [`ManimConfig`](manim._config.utils.ManimConfig.md#manim._config.utils.ManimConfig).
39
+
40
+ * **Returns:**
41
+ List of paths which may contain `.cfg` files, in ascending order of
42
+ precedence.
43
+ * **Return type:**
44
+ List[`Path`]
45
+
46
+ #### SEE ALSO
47
+ [`make_config_parser()`](#manim._config.utils.make_config_parser), [`ManimConfig.digest_file()`](manim._config.utils.ManimConfig.md#manim._config.utils.ManimConfig.digest_file), [`ManimConfig.digest_parser()`](manim._config.utils.ManimConfig.md#manim._config.utils.ManimConfig.digest_parser)
48
+
49
+ ### Notes
50
+
51
+ The location of the user-wide config file is OS-specific.
52
+
53
+ ### make_config_parser(custom_file=None)
54
+
55
+ Make a `ConfigParser` object and load any `.cfg` files.
56
+
57
+ The user-wide file, if it exists, overrides the library-wide file. The
58
+ folder-wide file, if it exists, overrides the other two.
59
+
60
+ The folder-wide file can be ignored by passing `custom_file`. However,
61
+ the user-wide and library-wide config files cannot be ignored.
62
+
63
+ * **Parameters:**
64
+ **custom_file** ([*StrPath*](manim.typing.md#manim.typing.StrPath) *|* *None*) – Path to a custom config file. If used, the folder-wide file in the
65
+ relevant directory will be ignored, if it exists. If None, the
66
+ folder-wide file will be used, if it exists.
67
+ * **Returns:**
68
+ A parser containing the config options found in the .cfg files that
69
+ were found. It is guaranteed to contain at least the config options
70
+ found in the library-wide file.
71
+ * **Return type:**
72
+ `ConfigParser`
73
+
74
+ #### SEE ALSO
75
+ [`config_file_paths()`](#manim._config.utils.config_file_paths)
data/rag/manim_docs/manim_core/docs/reference/manim.animation.animation.Add.md ADDED
@@ -0,0 +1,206 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Add
2
+
3
+ Qualified name: `manim.animation.animation.Add`
4
+
5
+ ### *class* Add(mobject=None, \*args, use_override=True, \*\*kwargs)
6
+
7
+ Bases: [`Animation`](manim.animation.animation.Animation.md#manim.animation.animation.Animation)
8
+
9
+ Add Mobjects to a scene, without animating them in any other way. This
10
+ is similar to the [`Scene.add()`](manim.scene.scene.Scene.md#manim.scene.scene.Scene.add) method, but [`Add`](#manim.animation.animation.Add) is an
11
+ animation which can be grouped into other animations.
12
+
13
+ * **Parameters:**
14
+ * **mobjects** ([*Mobject*](manim.mobject.mobject.Mobject.md#manim.mobject.mobject.Mobject)) – One [`Mobject`](manim.mobject.mobject.Mobject.md#manim.mobject.mobject.Mobject) or more to add to a scene.
15
+ * **run_time** (*float*) – The duration of the animation after adding the `mobjects`. Defaults
16
+ to 0, which means this is an instant animation without extra wait time
17
+ after adding them.
18
+ * **\*\*kwargs** (*Any*) – Additional arguments to pass to the parent [`Animation`](manim.animation.animation.Animation.md#manim.animation.animation.Animation) class.
19
+
20
+ ### Examples
21
+
22
+ <div id="defaultaddscene" class="admonition admonition-manim-example">
23
+ <p class="admonition-title">Example: DefaultAddScene <a class="headerlink" href="#defaultaddscene">¶</a></p><video
24
+ class="manim-video"
25
+ controls
26
+ loop
27
+ autoplay
28
+ src="./DefaultAddScene-1.mp4">
29
+ </video>
30
+ ```python
31
+ from manim import *
32
+
33
+ class DefaultAddScene(Scene):
34
+ def construct(self):
35
+ text_1 = Text("I was added with Add!")
36
+ text_2 = Text("Me too!")
37
+ text_3 = Text("And me!")
38
+ texts = VGroup(text_1, text_2, text_3).arrange(DOWN)
39
+ rect = SurroundingRectangle(texts, buff=0.5)
40
+
41
+ self.play(
42
+ Create(rect, run_time=3.0),
43
+ Succession(
44
+ Wait(1.0),
45
+ # You can Add a Mobject in the middle of an animation...
46
+ Add(text_1),
47
+ Wait(1.0),
48
+ # ...or multiple Mobjects at once!
49
+ Add(text_2, text_3),
50
+ ),
51
+ )
52
+ self.wait()
53
+ ```
54
+
55
+ <pre data-manim-binder data-manim-classname="DefaultAddScene">
56
+ class DefaultAddScene(Scene):
57
+ def construct(self):
58
+ text_1 = Text("I was added with Add!")
59
+ text_2 = Text("Me too!")
60
+ text_3 = Text("And me!")
61
+ texts = VGroup(text_1, text_2, text_3).arrange(DOWN)
62
+ rect = SurroundingRectangle(texts, buff=0.5)
63
+
64
+ self.play(
65
+ Create(rect, run_time=3.0),
66
+ Succession(
67
+ Wait(1.0),
68
+ # You can Add a Mobject in the middle of an animation...
69
+ Add(text_1),
70
+ Wait(1.0),
71
+ # ...or multiple Mobjects at once!
72
+ Add(text_2, text_3),
73
+ ),
74
+ )
75
+ self.wait()
76
+
77
+ </pre></div><div id="addwithruntimescene" class="admonition admonition-manim-example">
78
+ <p class="admonition-title">Example: AddWithRunTimeScene <a class="headerlink" href="#addwithruntimescene">¶</a></p><video
79
+ class="manim-video"
80
+ controls
81
+ loop
82
+ autoplay
83
+ src="./AddWithRunTimeScene-1.mp4">
84
+ </video>
85
+ ```python
86
+ from manim import *
87
+
88
+ class AddWithRunTimeScene(Scene):
89
+ def construct(self):
90
+ # A 5x5 grid of circles
91
+ circles = VGroup(
92
+ *[Circle(radius=0.5) for _ in range(25)]
93
+ ).arrange_in_grid(5, 5)
94
+
95
+ self.play(
96
+ Succession(
97
+ # Add a run_time of 0.2 to wait for 0.2 seconds after
98
+ # adding the circle, instead of using Wait(0.2) after Add!
99
+ *[Add(circle, run_time=0.2) for circle in circles],
100
+ rate_func=smooth,
101
+ )
102
+ )
103
+ self.wait()
104
+ ```
105
+
106
+ <pre data-manim-binder data-manim-classname="AddWithRunTimeScene">
107
+ class AddWithRunTimeScene(Scene):
108
+ def construct(self):
109
+ # A 5x5 grid of circles
110
+ circles = VGroup(
111
+ \*[Circle(radius=0.5) for \_ in range(25)]
112
+ ).arrange_in_grid(5, 5)
113
+
114
+ self.play(
115
+ Succession(
116
+ # Add a run_time of 0.2 to wait for 0.2 seconds after
117
+ # adding the circle, instead of using Wait(0.2) after Add!
118
+ \*[Add(circle, run_time=0.2) for circle in circles],
119
+ rate_func=smooth,
120
+ )
121
+ )
122
+ self.wait()
123
+
124
+ </pre></div>
125
+
126
+ ### Methods
127
+
128
+ | [`begin`](#manim.animation.animation.Add.begin) | Begin the animation. |
129
+ |-----------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------|
130
+ | [`clean_up_from_scene`](#manim.animation.animation.Add.clean_up_from_scene) | Clean up the [`Scene`](manim.scene.scene.Scene.md#manim.scene.scene.Scene) after finishing the animation. |
131
+ | [`finish`](#manim.animation.animation.Add.finish) | Finish the animation. |
132
+ | [`interpolate`](#manim.animation.animation.Add.interpolate) | Set the animation progress. |
133
+ | [`update_mobjects`](#manim.animation.animation.Add.update_mobjects) | Updates things like starting_mobject, and (for Transforms) target_mobject. |
134
+
135
+ ### Attributes
136
+
137
+ | `run_time` | |
138
+ |--------------|----|
139
+
140
+ #### \_original_\_init_\_(\*mobjects, run_time=0.0, \*\*kwargs)
141
+
142
+ Initialize self. See help(type(self)) for accurate signature.
143
+
144
+ * **Parameters:**
145
+ * **mobjects** ([*Mobject*](manim.mobject.mobject.Mobject.md#manim.mobject.mobject.Mobject))
146
+ * **run_time** (*float*)
147
+ * **kwargs** (*Any*)
148
+ * **Return type:**
149
+ None
150
+
151
+ #### begin()
152
+
153
+ Begin the animation.
154
+
155
+ This method is called right as an animation is being played. As much
156
+ initialization as possible, especially any mobject copying, should live in this
157
+ method.
158
+
159
+ * **Return type:**
160
+ None
161
+
162
+ #### clean_up_from_scene(scene)
163
+
164
+ Clean up the [`Scene`](manim.scene.scene.Scene.md#manim.scene.scene.Scene) after finishing the animation.
165
+
166
+ This includes to [`remove()`](manim.scene.scene.Scene.md#manim.scene.scene.Scene.remove) the Animation’s
167
+ [`Mobject`](manim.mobject.mobject.Mobject.md#manim.mobject.mobject.Mobject) if the animation is a remover.
168
+
169
+ * **Parameters:**
170
+ **scene** ([*Scene*](manim.scene.scene.Scene.md#manim.scene.scene.Scene)) – The scene the animation should be cleaned up from.
171
+ * **Return type:**
172
+ None
173
+
174
+ #### finish()
175
+
176
+ Finish the animation.
177
+
178
+ This method gets called when the animation is over.
179
+
180
+ * **Return type:**
181
+ None
182
+
183
+ #### interpolate(alpha)
184
+
185
+ Set the animation progress.
186
+
187
+ This method gets called for every frame during an animation.
188
+
189
+ * **Parameters:**
190
+ **alpha** (*float*) – The relative time to set the animation to, 0 meaning the start, 1 meaning
191
+ the end.
192
+ * **Return type:**
193
+ None
194
+
195
+ #### update_mobjects(dt)
196
+
197
+ Updates things like starting_mobject, and (for
198
+ Transforms) target_mobject. Note, since typically
199
+ (always?) self.mobject will have its updating
200
+ suspended during the animation, this will do
201
+ nothing to self.mobject.
202
+
203
+ * **Parameters:**
204
+ **dt** (*float*)
205
+ * **Return type:**
206
+ None
data/rag/manim_docs/manim_core/docs/reference/manim.animation.animation.Animation.md ADDED
@@ -0,0 +1,400 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Animation
2
+
3
+ Qualified name: `manim.animation.animation.Animation`
4
+
5
+ ### *class* Animation(mobject=None, \*args, use_override=True, \*\*kwargs)
6
+
7
+ Bases: `object`
8
+
9
+ An animation.
10
+
11
+ Animations have a fixed time span.
12
+
13
+ * **Parameters:**
14
+ * **mobject** – The mobject to be animated. This is not required for all types of animations.
15
+ * **lag_ratio** –
16
+
17
+ Defines the delay after which the animation is applied to submobjects. This lag
18
+ is relative to the duration of the animation.
19
+
20
+ This does not influence the total
21
+ runtime of the animation. Instead the runtime of individual animations is
22
+ adjusted so that the complete animation has the defined run time.
23
+ * **run_time** – The duration of the animation in seconds.
24
+ * **rate_func** –
25
+
26
+ The function defining the animation progress based on the relative runtime (see [`rate_functions`](manim.utils.rate_functions.md#module-manim.utils.rate_functions)) .
27
+
28
+ For example `rate_func(0.5)` is the proportion of the animation that is done
29
+ after half of the animations run time.
30
+ * **Return type:**
31
+ Self
32
+
33
+ reverse_rate_function
34
+ : Reverses the rate function of the animation. Setting `reverse_rate_function`
35
+ does not have any effect on `remover` or `introducer`. These need to be
36
+ set explicitly if an introducer-animation should be turned into a remover one
37
+ and vice versa.
38
+
39
+ name
40
+ : The name of the animation. This gets displayed while rendering the animation.
41
+ Defaults to <class-name>(<Mobject-name>).
42
+
43
+ remover
44
+ : Whether the given mobject should be removed from the scene after this animation.
45
+
46
+ suspend_mobject_updating
47
+ : Whether updaters of the mobject should be suspended during the animation.
48
+
49
+ #### NOTE
50
+ In the current implementation of this class, the specified rate function is applied
51
+ within [`Animation.interpolate_mobject()`](#manim.animation.animation.Animation.interpolate_mobject) call as part of the call to
52
+ `Animation.interpolate_submobject()`. For subclasses of [`Animation`](#manim.animation.animation.Animation)
53
+ that are implemented by overriding [`interpolate_mobject()`](#manim.animation.animation.Animation.interpolate_mobject), the rate function
54
+ has to be applied manually (e.g., by passing `self.rate_func(alpha)` instead
55
+ of just `alpha`).
56
+
57
+ ### Examples
58
+
59
+ <div id="lagratios" class="admonition admonition-manim-example">
60
+ <p class="admonition-title">Example: LagRatios <a class="headerlink" href="#lagratios">¶</a></p><video
61
+ class="manim-video"
62
+ controls
63
+ loop
64
+ autoplay
65
+ src="./LagRatios-1.mp4">
66
+ </video>
67
+ ```python
68
+ from manim import *
69
+
70
+ class LagRatios(Scene):
71
+ def construct(self):
72
+ ratios = [0, 0.1, 0.5, 1, 2] # demonstrated lag_ratios
73
+
74
+ # Create dot groups
75
+ group = VGroup(*[Dot() for _ in range(4)]).arrange_submobjects()
76
+ groups = VGroup(*[group.copy() for _ in ratios]).arrange_submobjects(buff=1)
77
+ self.add(groups)
78
+
79
+ # Label groups
80
+ self.add(Text("lag_ratio = ", font_size=36).next_to(groups, UP, buff=1.5))
81
+ for group, ratio in zip(groups, ratios):
82
+ self.add(Text(str(ratio), font_size=36).next_to(group, UP))
83
+
84
+ #Animate groups with different lag_ratios
85
+ self.play(AnimationGroup(*[
86
+ group.animate(lag_ratio=ratio, run_time=1.5).shift(DOWN * 2)
87
+ for group, ratio in zip(groups, ratios)
88
+ ]))
89
+
90
+ # lag_ratio also works recursively on nested submobjects:
91
+ self.play(groups.animate(run_time=1, lag_ratio=0.1).shift(UP * 2))
92
+ ```
93
+
94
+ <pre data-manim-binder data-manim-classname="LagRatios">
95
+ class LagRatios(Scene):
96
+ def construct(self):
97
+ ratios = [0, 0.1, 0.5, 1, 2] # demonstrated lag_ratios
98
+
99
+ # Create dot groups
100
+ group = VGroup(\*[Dot() for \_ in range(4)]).arrange_submobjects()
101
+ groups = VGroup(\*[group.copy() for \_ in ratios]).arrange_submobjects(buff=1)
102
+ self.add(groups)
103
+
104
+ # Label groups
105
+ self.add(Text("lag_ratio = ", font_size=36).next_to(groups, UP, buff=1.5))
106
+ for group, ratio in zip(groups, ratios):
107
+ self.add(Text(str(ratio), font_size=36).next_to(group, UP))
108
+
109
+ #Animate groups with different lag_ratios
110
+ self.play(AnimationGroup(\*[
111
+ group.animate(lag_ratio=ratio, run_time=1.5).shift(DOWN \* 2)
112
+ for group, ratio in zip(groups, ratios)
113
+ ]))
114
+
115
+ # lag_ratio also works recursively on nested submobjects:
116
+ self.play(groups.animate(run_time=1, lag_ratio=0.1).shift(UP \* 2))
117
+
118
+ </pre></div>
119
+
120
+ ### Methods
121
+
122
+ | [`begin`](#manim.animation.animation.Animation.begin) | Begin the animation. |
123
+ |-------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------|
124
+ | [`clean_up_from_scene`](#manim.animation.animation.Animation.clean_up_from_scene) | Clean up the [`Scene`](manim.scene.scene.Scene.md#manim.scene.scene.Scene) after finishing the animation. |
125
+ | [`copy`](#manim.animation.animation.Animation.copy) | Create a copy of the animation. |
126
+ | `create_starting_mobject` | |
127
+ | [`finish`](#manim.animation.animation.Animation.finish) | Finish the animation. |
128
+ | `get_all_families_zipped` | |
129
+ | [`get_all_mobjects`](#manim.animation.animation.Animation.get_all_mobjects) | Get all mobjects involved in the animation. |
130
+ | [`get_all_mobjects_to_update`](#manim.animation.animation.Animation.get_all_mobjects_to_update) | Get all mobjects to be updated during the animation. |
131
+ | [`get_rate_func`](#manim.animation.animation.Animation.get_rate_func) | Get the rate function of the animation. |
132
+ | [`get_run_time`](#manim.animation.animation.Animation.get_run_time) | Get the run time of the animation. |
133
+ | [`get_sub_alpha`](#manim.animation.animation.Animation.get_sub_alpha) | Get the animation progress of any submobjects subanimation. |
134
+ | [`interpolate`](#manim.animation.animation.Animation.interpolate) | Set the animation progress. |
135
+ | [`interpolate_mobject`](#manim.animation.animation.Animation.interpolate_mobject) | Interpolates the mobject of the [`Animation`](#manim.animation.animation.Animation) based on alpha value. |
136
+ | `interpolate_submobject` | |
137
+ | [`is_introducer`](#manim.animation.animation.Animation.is_introducer) | Test if the animation is an introducer. |
138
+ | [`is_remover`](#manim.animation.animation.Animation.is_remover) | Test if the animation is a remover. |
139
+ | [`set_default`](#manim.animation.animation.Animation.set_default) | Sets the default values of keyword arguments. |
140
+ | [`set_name`](#manim.animation.animation.Animation.set_name) | Set the name of the animation. |
141
+ | [`set_rate_func`](#manim.animation.animation.Animation.set_rate_func) | Set the rate function of the animation. |
142
+ | [`set_run_time`](#manim.animation.animation.Animation.set_run_time) | Set the run time of the animation. |
143
+ | [`update_mobjects`](#manim.animation.animation.Animation.update_mobjects) | Updates things like starting_mobject, and (for Transforms) target_mobject. |
144
+
145
+ ### Attributes
146
+
147
+ | `run_time` | |
148
+ |--------------|----|
149
+
150
+ #### \_setup_scene(scene)
151
+
152
+ Setup up the [`Scene`](manim.scene.scene.Scene.md#manim.scene.scene.Scene) before starting the animation.
153
+
154
+ This includes to [`add()`](manim.scene.scene.Scene.md#manim.scene.scene.Scene.add) the Animation’s
155
+ [`Mobject`](manim.mobject.mobject.Mobject.md#manim.mobject.mobject.Mobject) if the animation is an introducer.
156
+
157
+ * **Parameters:**
158
+ **scene** ([*Scene*](manim.scene.scene.Scene.md#manim.scene.scene.Scene)) – The scene the animation should be cleaned up from.
159
+ * **Return type:**
160
+ None
161
+
162
+ #### begin()
163
+
164
+ Begin the animation.
165
+
166
+ This method is called right as an animation is being played. As much
167
+ initialization as possible, especially any mobject copying, should live in this
168
+ method.
169
+
170
+ * **Return type:**
171
+ None
172
+
173
+ #### clean_up_from_scene(scene)
174
+
175
+ Clean up the [`Scene`](manim.scene.scene.Scene.md#manim.scene.scene.Scene) after finishing the animation.
176
+
177
+ This includes to [`remove()`](manim.scene.scene.Scene.md#manim.scene.scene.Scene.remove) the Animation’s
178
+ [`Mobject`](manim.mobject.mobject.Mobject.md#manim.mobject.mobject.Mobject) if the animation is a remover.
179
+
180
+ * **Parameters:**
181
+ **scene** ([*Scene*](manim.scene.scene.Scene.md#manim.scene.scene.Scene)) – The scene the animation should be cleaned up from.
182
+ * **Return type:**
183
+ None
184
+
185
+ #### copy()
186
+
187
+ Create a copy of the animation.
188
+
189
+ * **Returns:**
190
+ A copy of `self`
191
+ * **Return type:**
192
+ [Animation](#manim.animation.animation.Animation)
193
+
194
+ #### finish()
195
+
196
+ Finish the animation.
197
+
198
+ This method gets called when the animation is over.
199
+
200
+ * **Return type:**
201
+ None
202
+
203
+ #### get_all_mobjects()
204
+
205
+ Get all mobjects involved in the animation.
206
+
207
+ Ordering must match the ordering of arguments to interpolate_submobject
208
+
209
+ * **Returns:**
210
+ The sequence of mobjects.
211
+ * **Return type:**
212
+ Sequence[[Mobject](manim.mobject.mobject.Mobject.md#manim.mobject.mobject.Mobject)]
213
+
214
+ #### get_all_mobjects_to_update()
215
+
216
+ Get all mobjects to be updated during the animation.
217
+
218
+ * **Returns:**
219
+ The list of mobjects to be updated during the animation.
220
+ * **Return type:**
221
+ List[[Mobject](manim.mobject.mobject.Mobject.md#manim.mobject.mobject.Mobject)]
222
+
223
+ #### get_rate_func()
224
+
225
+ Get the rate function of the animation.
226
+
227
+ * **Returns:**
228
+ The rate function of the animation.
229
+ * **Return type:**
230
+ Callable[[float], float]
231
+
232
+ #### get_run_time()
233
+
234
+ Get the run time of the animation.
235
+
236
+ * **Returns:**
237
+ The time the animation takes in seconds.
238
+ * **Return type:**
239
+ float
240
+
241
+ #### get_sub_alpha(alpha, index, num_submobjects)
242
+
243
+ Get the animation progress of any submobjects subanimation.
244
+
245
+ * **Parameters:**
246
+ * **alpha** (*float*) – The overall animation progress
247
+ * **index** (*int*) – The index of the subanimation.
248
+ * **num_submobjects** (*int*) – The total count of subanimations.
249
+ * **Returns:**
250
+ The progress of the subanimation.
251
+ * **Return type:**
252
+ float
253
+
254
+ #### interpolate(alpha)
255
+
256
+ Set the animation progress.
257
+
258
+ This method gets called for every frame during an animation.
259
+
260
+ * **Parameters:**
261
+ **alpha** (*float*) – The relative time to set the animation to, 0 meaning the start, 1 meaning
262
+ the end.
263
+ * **Return type:**
264
+ None
265
+
266
+ #### interpolate_mobject(alpha)
267
+
268
+ Interpolates the mobject of the [`Animation`](#manim.animation.animation.Animation) based on alpha value.
269
+
270
+ * **Parameters:**
271
+ **alpha** (*float*) – A float between 0 and 1 expressing the ratio to which the animation
272
+ is completed. For example, alpha-values of 0, 0.5, and 1 correspond
273
+ to the animation being completed 0%, 50%, and 100%, respectively.
274
+ * **Return type:**
275
+ None
276
+
277
+ #### is_introducer()
278
+
279
+ Test if the animation is an introducer.
280
+
281
+ * **Returns:**
282
+ `True` if the animation is an introducer, `False` otherwise.
283
+ * **Return type:**
284
+ bool
285
+
286
+ #### is_remover()
287
+
288
+ Test if the animation is a remover.
289
+
290
+ * **Returns:**
291
+ `True` if the animation is a remover, `False` otherwise.
292
+ * **Return type:**
293
+ bool
294
+
295
+ #### *classmethod* set_default(\*\*kwargs)
296
+
297
+ Sets the default values of keyword arguments.
298
+
299
+ If this method is called without any additional keyword
300
+ arguments, the original default values of the initialization
301
+ method of this class are restored.
302
+
303
+ * **Parameters:**
304
+ **kwargs** – Passing any keyword argument will update the default
305
+ values of the keyword arguments of the initialization
306
+ function of this class.
307
+ * **Return type:**
308
+ None
309
+
310
+ ### Examples
311
+
312
+ <div id="changedefaultanimation" class="admonition admonition-manim-example">
313
+ <p class="admonition-title">Example: ChangeDefaultAnimation <a class="headerlink" href="#changedefaultanimation">¶</a></p><video
314
+ class="manim-video"
315
+ controls
316
+ loop
317
+ autoplay
318
+ src="./ChangeDefaultAnimation-1.mp4">
319
+ </video>
320
+ ```python
321
+ from manim import *
322
+
323
+ class ChangeDefaultAnimation(Scene):
324
+ def construct(self):
325
+ Rotate.set_default(run_time=2, rate_func=rate_functions.linear)
326
+ Indicate.set_default(color=None)
327
+
328
+ S = Square(color=BLUE, fill_color=BLUE, fill_opacity=0.25)
329
+ self.add(S)
330
+ self.play(Rotate(S, PI))
331
+ self.play(Indicate(S))
332
+
333
+ Rotate.set_default()
334
+ Indicate.set_default()
335
+ ```
336
+
337
+ <pre data-manim-binder data-manim-classname="ChangeDefaultAnimation">
338
+ class ChangeDefaultAnimation(Scene):
339
+ def construct(self):
340
+ Rotate.set_default(run_time=2, rate_func=rate_functions.linear)
341
+ Indicate.set_default(color=None)
342
+
343
+ S = Square(color=BLUE, fill_color=BLUE, fill_opacity=0.25)
344
+ self.add(S)
345
+ self.play(Rotate(S, PI))
346
+ self.play(Indicate(S))
347
+
348
+ Rotate.set_default()
349
+ Indicate.set_default()
350
+
351
+ </pre></div>
352
+
353
+ #### set_name(name)
354
+
355
+ Set the name of the animation.
356
+
357
+ * **Parameters:**
358
+ **name** (*str*) – The new name of the animation.
359
+ * **Returns:**
360
+ `self`
361
+ * **Return type:**
362
+ [Animation](#manim.animation.animation.Animation)
363
+
364
+ #### set_rate_func(rate_func)
365
+
366
+ Set the rate function of the animation.
367
+
368
+ * **Parameters:**
369
+ **rate_func** (*Callable* *[* *[**float* *]* *,* *float* *]*) – The new function defining the animation progress based on the
370
+ relative runtime (see [`rate_functions`](manim.utils.rate_functions.md#module-manim.utils.rate_functions)).
371
+ * **Returns:**
372
+ `self`
373
+ * **Return type:**
374
+ [Animation](#manim.animation.animation.Animation)
375
+
376
+ #### set_run_time(run_time)
377
+
378
+ Set the run time of the animation.
379
+
380
+ * **Parameters:**
381
+ * **run_time** (*float*) – The new time the animation should take in seconds.
382
+ * **note::** ( *..*) – The run_time of an animation should not be changed while it is already
383
+ running.
384
+ * **Returns:**
385
+ `self`
386
+ * **Return type:**
387
+ [Animation](#manim.animation.animation.Animation)
388
+
389
+ #### update_mobjects(dt)
390
+
391
+ Updates things like starting_mobject, and (for
392
+ Transforms) target_mobject. Note, since typically
393
+ (always?) self.mobject will have its updating
394
+ suspended during the animation, this will do
395
+ nothing to self.mobject.
396
+
397
+ * **Parameters:**
398
+ **dt** (*float*)
399
+ * **Return type:**
400
+ None
data/rag/manim_docs/manim_core/docs/reference/manim.animation.animation.Wait.md ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Wait
2
+
3
+ Qualified name: `manim.animation.animation.Wait`
4
+
5
+ ### *class* Wait(mobject=None, \*args, use_override=True, \*\*kwargs)
6
+
7
+ Bases: [`Animation`](manim.animation.animation.Animation.md#manim.animation.animation.Animation)
8
+
9
+ A “no operation” animation.
10
+
11
+ * **Parameters:**
12
+ * **run_time** (*float*) – The amount of time that should pass.
13
+ * **stop_condition** (*Callable* *[* *[* *]* *,* *bool* *]* *|* *None*) – A function without positional arguments that evaluates to a boolean.
14
+ The function is evaluated after every new frame has been rendered.
15
+ Playing the animation stops after the return value is truthy, or
16
+ after the specified `run_time` has passed.
17
+ * **frozen_frame** (*bool* *|* *None*) – Controls whether or not the wait animation is static, i.e., corresponds
18
+ to a frozen frame. If `False` is passed, the render loop still
19
+ progresses through the animation as usual and (among other things)
20
+ continues to call updater functions. If `None` (the default value),
21
+ the [`Scene.play()`](manim.scene.scene.Scene.md#manim.scene.scene.Scene.play) call tries to determine whether the Wait call
22
+ can be static or not itself via `Scene.should_mobjects_update()`.
23
+ * **kwargs** – Keyword arguments to be passed to the parent class, [`Animation`](manim.animation.animation.Animation.md#manim.animation.animation.Animation).
24
+ * **rate_func** (*Callable* *[* *[**float* *]* *,* *float* *]*)
25
+
26
+ ### Methods
27
+
28
+ | [`begin`](#manim.animation.animation.Wait.begin) | Begin the animation. |
29
+ |------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------|
30
+ | [`clean_up_from_scene`](#manim.animation.animation.Wait.clean_up_from_scene) | Clean up the [`Scene`](manim.scene.scene.Scene.md#manim.scene.scene.Scene) after finishing the animation. |
31
+ | [`finish`](#manim.animation.animation.Wait.finish) | Finish the animation. |
32
+ | [`interpolate`](#manim.animation.animation.Wait.interpolate) | Set the animation progress. |
33
+ | [`update_mobjects`](#manim.animation.animation.Wait.update_mobjects) | Updates things like starting_mobject, and (for Transforms) target_mobject. |
34
+
35
+ ### Attributes
36
+
37
+ | `run_time` | |
38
+ |--------------|----|
39
+
40
+ #### \_original_\_init_\_(run_time=1, stop_condition=None, frozen_frame=None, rate_func=<function linear>, \*\*kwargs)
41
+
42
+ Initialize self. See help(type(self)) for accurate signature.
43
+
44
+ * **Parameters:**
45
+ * **run_time** (*float*)
46
+ * **stop_condition** (*Callable* *[* *[* *]* *,* *bool* *]* *|* *None*)
47
+ * **frozen_frame** (*bool* *|* *None*)
48
+ * **rate_func** (*Callable* *[* *[**float* *]* *,* *float* *]*)
49
+
50
+ #### begin()
51
+
52
+ Begin the animation.
53
+
54
+ This method is called right as an animation is being played. As much
55
+ initialization as possible, especially any mobject copying, should live in this
56
+ method.
57
+
58
+ * **Return type:**
59
+ None
60
+
61
+ #### clean_up_from_scene(scene)
62
+
63
+ Clean up the [`Scene`](manim.scene.scene.Scene.md#manim.scene.scene.Scene) after finishing the animation.
64
+
65
+ This includes to [`remove()`](manim.scene.scene.Scene.md#manim.scene.scene.Scene.remove) the Animation’s
66
+ [`Mobject`](manim.mobject.mobject.Mobject.md#manim.mobject.mobject.Mobject) if the animation is a remover.
67
+
68
+ * **Parameters:**
69
+ **scene** ([*Scene*](manim.scene.scene.Scene.md#manim.scene.scene.Scene)) – The scene the animation should be cleaned up from.
70
+ * **Return type:**
71
+ None
72
+
73
+ #### finish()
74
+
75
+ Finish the animation.
76
+
77
+ This method gets called when the animation is over.
78
+
79
+ * **Return type:**
80
+ None
81
+
82
+ #### interpolate(alpha)
83
+
84
+ Set the animation progress.
85
+
86
+ This method gets called for every frame during an animation.
87
+
88
+ * **Parameters:**
89
+ **alpha** (*float*) – The relative time to set the animation to, 0 meaning the start, 1 meaning
90
+ the end.
91
+ * **Return type:**
92
+ None
93
+
94
+ #### update_mobjects(dt)
95
+
96
+ Updates things like starting_mobject, and (for
97
+ Transforms) target_mobject. Note, since typically
98
+ (always?) self.mobject will have its updating
99
+ suspended during the animation, this will do
100
+ nothing to self.mobject.
101
+
102
+ * **Parameters:**
103
+ **dt** (*float*)
104
+ * **Return type:**
105
+ None
data/rag/manim_docs/manim_core/docs/reference/manim.animation.animation.md ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # animation
2
+
3
+ Animate mobjects.
4
+
5
+ ### Classes
6
+
7
+ | [`Add`](manim.animation.animation.Add.md#manim.animation.animation.Add) | Add Mobjects to a scene, without animating them in any other way. |
8
+ |-------------------------------------------------------------------------------------------|---------------------------------------------------------------------|
9
+ | [`Animation`](manim.animation.animation.Animation.md#manim.animation.animation.Animation) | An animation. |
10
+ | [`Wait`](manim.animation.animation.Wait.md#manim.animation.animation.Wait) | A "no operation" animation. |
11
+
12
+ ### Functions
13
+
14
+ ### override_animation(animation_class)
15
+
16
+ Decorator used to mark methods as overrides for specific [`Animation`](manim.animation.animation.Animation.md#manim.animation.animation.Animation) types.
17
+
18
+ Should only be used to decorate methods of classes derived from [`Mobject`](manim.mobject.mobject.Mobject.md#manim.mobject.mobject.Mobject).
19
+ `Animation` overrides get inherited to subclasses of the `Mobject` who defined
20
+ them. They don’t override subclasses of the `Animation` they override.
21
+
22
+ #### SEE ALSO
23
+ [`add_animation_override()`](manim.mobject.mobject.Mobject.md#manim.mobject.mobject.Mobject.add_animation_override)
24
+
25
+ * **Parameters:**
26
+ **animation_class** (*type* *[*[*Animation*](manim.animation.animation.Animation.md#manim.animation.animation.Animation) *]*) – The animation to be overridden.
27
+ * **Returns:**
28
+ The actual decorator. This marks the method as overriding an animation.
29
+ * **Return type:**
30
+ Callable[[Callable], Callable]
31
+
32
+ ### Examples
33
+
34
+ <div id="overrideanimationexample" class="admonition admonition-manim-example">
35
+ <p class="admonition-title">Example: OverrideAnimationExample <a class="headerlink" href="#overrideanimationexample">¶</a></p><video
36
+ class="manim-video"
37
+ controls
38
+ loop
39
+ autoplay
40
+ src="./OverrideAnimationExample-1.mp4">
41
+ </video>
42
+ ```python
43
+ from manim import *
44
+
45
+ class MySquare(Square):
46
+ @override_animation(FadeIn)
47
+ def _fade_in_override(self, **kwargs):
48
+ return Create(self, **kwargs)
49
+
50
+ class OverrideAnimationExample(Scene):
51
+ def construct(self):
52
+ self.play(FadeIn(MySquare()))
53
+ ```
54
+
55
+ <pre data-manim-binder data-manim-classname="OverrideAnimationExample">
56
+ class MySquare(Square):
57
+ @override_animation(FadeIn)
58
+ def \_fade_in_override(self, \*\*kwargs):
59
+ return Create(self, \*\*kwargs)
60
+
61
+ class OverrideAnimationExample(Scene):
62
+ def construct(self):
63
+ self.play(FadeIn(MySquare()))
64
+
65
+ </pre></div>
66
+
67
+ ### prepare_animation(anim)
68
+
69
+ Returns either an unchanged animation, or the animation built
70
+ from a passed animation factory.
71
+
72
+ ### Examples
73
+
74
+ ```default
75
+ >>> from manim import Square, FadeIn
76
+ >>> s = Square()
77
+ >>> prepare_animation(FadeIn(s))
78
+ FadeIn(Square)
79
+ ```
80
+
81
+ ```default
82
+ >>> prepare_animation(s.animate.scale(2).rotate(42))
83
+ _MethodAnimation(Square)
84
+ ```
85
+
86
+ ```default
87
+ >>> prepare_animation(42)
88
+ Traceback (most recent call last):
89
+ ...
90
+ TypeError: Object 42 cannot be converted to an animation
91
+ ```
92
+
93
+ * **Parameters:**
94
+ **anim** ([*Animation*](manim.animation.animation.Animation.md#manim.animation.animation.Animation) *|* *\_AnimationBuilder*)
95
+ * **Return type:**
96
+ [*Animation*](manim.animation.animation.Animation.md#manim.animation.animation.Animation)
data/rag/manim_docs/manim_core/docs/reference/manim.animation.changing.AnimatedBoundary.md ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # AnimatedBoundary
2
+
3
+ Qualified name: `manim.animation.changing.AnimatedBoundary`
4
+
5
+ ### *class* AnimatedBoundary(vmobject, colors=[ManimColor('#29ABCA'), ManimColor('#9CDCEB'), ManimColor('#236B8E'), ManimColor('#736357')], max_stroke_width=3, cycle_rate=0.5, back_and_forth=True, draw_rate_func=<function smooth>, fade_rate_func=<function smooth>, \*\*kwargs)
6
+
7
+ Bases: [`VGroup`](manim.mobject.types.vectorized_mobject.VGroup.md#manim.mobject.types.vectorized_mobject.VGroup)
8
+
9
+ Boundary of a [`VMobject`](manim.mobject.types.vectorized_mobject.VMobject.md#manim.mobject.types.vectorized_mobject.VMobject) with animated color change.
10
+
11
+ ### Examples
12
+
13
+ <div id="animatedboundaryexample" class="admonition admonition-manim-example">
14
+ <p class="admonition-title">Example: AnimatedBoundaryExample <a class="headerlink" href="#animatedboundaryexample">¶</a></p><video
15
+ class="manim-video"
16
+ controls
17
+ loop
18
+ autoplay
19
+ src="./AnimatedBoundaryExample-1.mp4">
20
+ </video>
21
+ ```python
22
+ from manim import *
23
+
24
+ class AnimatedBoundaryExample(Scene):
25
+ def construct(self):
26
+ text = Text("So shiny!")
27
+ boundary = AnimatedBoundary(text, colors=[RED, GREEN, BLUE],
28
+ cycle_rate=3)
29
+ self.add(text, boundary)
30
+ self.wait(2)
31
+ ```
32
+
33
+ <pre data-manim-binder data-manim-classname="AnimatedBoundaryExample">
34
+ class AnimatedBoundaryExample(Scene):
35
+ def construct(self):
36
+ text = Text("So shiny!")
37
+ boundary = AnimatedBoundary(text, colors=[RED, GREEN, BLUE],
38
+ cycle_rate=3)
39
+ self.add(text, boundary)
40
+ self.wait(2)
41
+
42
+ </pre></div>
43
+
44
+ ### Methods
45
+
46
+ | `full_family_become_partial` | |
47
+ |--------------------------------|----|
48
+ | `update_boundary_copies` | |
49
+
50
+ ### Attributes
51
+
52
+ | `animate` | Used to animate the application of any method of `self`. |
53
+ |-----------------------|------------------------------------------------------------------------|
54
+ | `animation_overrides` | |
55
+ | `color` | |
56
+ | `depth` | The depth of the mobject. |
57
+ | `fill_color` | If there are multiple colors (for gradient) this returns the first one |
58
+ | `height` | The height of the mobject. |
59
+ | `n_points_per_curve` | |
60
+ | `sheen_factor` | |
61
+ | `stroke_color` | |
62
+ | `width` | The width of the mobject. |
63
+
64
+ #### \_original_\_init_\_(vmobject, colors=[ManimColor('#29ABCA'), ManimColor('#9CDCEB'), ManimColor('#236B8E'), ManimColor('#736357')], max_stroke_width=3, cycle_rate=0.5, back_and_forth=True, draw_rate_func=<function smooth>, fade_rate_func=<function smooth>, \*\*kwargs)
65
+
66
+ Initialize self. See help(type(self)) for accurate signature.
data/rag/manim_docs/manim_core/docs/reference/manim.animation.changing.TracedPath.md ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # TracedPath
2
+
3
+ Qualified name: `manim.animation.changing.TracedPath`
4
+
5
+ ### *class* TracedPath(traced_point_func, stroke_width=2, stroke_color=ManimColor('#FFFFFF'), dissipating_time=None, \*\*kwargs)
6
+
7
+ Bases: [`VMobject`](manim.mobject.types.vectorized_mobject.VMobject.md#manim.mobject.types.vectorized_mobject.VMobject)
8
+
9
+ Traces the path of a point returned by a function call.
10
+
11
+ * **Parameters:**
12
+ * **traced_point_func** (*Callable*) – The function to be traced.
13
+ * **stroke_width** (*float*) – The width of the trace.
14
+ * **stroke_color** ([*ParsableManimColor*](manim.utils.color.core.md#manim.utils.color.core.ParsableManimColor) *|* *None*) – The color of the trace.
15
+ * **dissipating_time** (*float* *|* *None*) – The time taken for the path to dissipate. Default set to `None`
16
+ which disables dissipation.
17
+
18
+ ### Examples
19
+
20
+ <div id="tracedpathexample" class="admonition admonition-manim-example">
21
+ <p class="admonition-title">Example: TracedPathExample <a class="headerlink" href="#tracedpathexample">¶</a></p><video
22
+ class="manim-video"
23
+ controls
24
+ loop
25
+ autoplay
26
+ src="./TracedPathExample-1.mp4">
27
+ </video>
28
+ ```python
29
+ from manim import *
30
+
31
+ class TracedPathExample(Scene):
32
+ def construct(self):
33
+ circ = Circle(color=RED).shift(4*LEFT)
34
+ dot = Dot(color=RED).move_to(circ.get_start())
35
+ rolling_circle = VGroup(circ, dot)
36
+ trace = TracedPath(circ.get_start)
37
+ rolling_circle.add_updater(lambda m: m.rotate(-0.3))
38
+ self.add(trace, rolling_circle)
39
+ self.play(rolling_circle.animate.shift(8*RIGHT), run_time=4, rate_func=linear)
40
+ ```
41
+
42
+ <pre data-manim-binder data-manim-classname="TracedPathExample">
43
+ class TracedPathExample(Scene):
44
+ def construct(self):
45
+ circ = Circle(color=RED).shift(4\*LEFT)
46
+ dot = Dot(color=RED).move_to(circ.get_start())
47
+ rolling_circle = VGroup(circ, dot)
48
+ trace = TracedPath(circ.get_start)
49
+ rolling_circle.add_updater(lambda m: m.rotate(-0.3))
50
+ self.add(trace, rolling_circle)
51
+ self.play(rolling_circle.animate.shift(8\*RIGHT), run_time=4, rate_func=linear)
52
+
53
+ </pre></div><div id="dissipatingpathexample" class="admonition admonition-manim-example">
54
+ <p class="admonition-title">Example: DissipatingPathExample <a class="headerlink" href="#dissipatingpathexample">¶</a></p><video
55
+ class="manim-video"
56
+ controls
57
+ loop
58
+ autoplay
59
+ src="./DissipatingPathExample-1.mp4">
60
+ </video>
61
+ ```python
62
+ from manim import *
63
+
64
+ class DissipatingPathExample(Scene):
65
+ def construct(self):
66
+ a = Dot(RIGHT * 2)
67
+ b = TracedPath(a.get_center, dissipating_time=0.5, stroke_opacity=[0, 1])
68
+ self.add(a, b)
69
+ self.play(a.animate(path_arc=PI / 4).shift(LEFT * 2))
70
+ self.play(a.animate(path_arc=-PI / 4).shift(LEFT * 2))
71
+ self.wait()
72
+ ```
73
+
74
+ <pre data-manim-binder data-manim-classname="DissipatingPathExample">
75
+ class DissipatingPathExample(Scene):
76
+ def construct(self):
77
+ a = Dot(RIGHT \* 2)
78
+ b = TracedPath(a.get_center, dissipating_time=0.5, stroke_opacity=[0, 1])
79
+ self.add(a, b)
80
+ self.play(a.animate(path_arc=PI / 4).shift(LEFT \* 2))
81
+ self.play(a.animate(path_arc=-PI / 4).shift(LEFT \* 2))
82
+ self.wait()
83
+
84
+ </pre></div>
85
+
86
+ ### Methods
87
+
88
+ | `update_path` | |
89
+ |-----------------|----|
90
+
91
+ ### Attributes
92
+
93
+ | `animate` | Used to animate the application of any method of `self`. |
94
+ |-----------------------|------------------------------------------------------------------------|
95
+ | `animation_overrides` | |
96
+ | `color` | |
97
+ | `depth` | The depth of the mobject. |
98
+ | `fill_color` | If there are multiple colors (for gradient) this returns the first one |
99
+ | `height` | The height of the mobject. |
100
+ | `n_points_per_curve` | |
101
+ | `sheen_factor` | |
102
+ | `stroke_color` | |
103
+ | `width` | The width of the mobject. |
104
+
105
+ #### \_original_\_init_\_(traced_point_func, stroke_width=2, stroke_color=ManimColor('#FFFFFF'), dissipating_time=None, \*\*kwargs)
106
+
107
+ Initialize self. See help(type(self)) for accurate signature.
108
+
109
+ * **Parameters:**
110
+ * **traced_point_func** (*Callable*)
111
+ * **stroke_width** (*float*)
112
+ * **stroke_color** ([*ParsableManimColor*](manim.utils.color.core.md#manim.utils.color.core.ParsableManimColor) *|* *None*)
113
+ * **dissipating_time** (*float* *|* *None*)
data/rag/manim_docs/manim_core/docs/reference/manim.animation.changing.md ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ # changing
2
+
3
+ Animation of a mobject boundary and tracing of points.
4
+
5
+ ### Classes
6
+
7
+ | [`AnimatedBoundary`](manim.animation.changing.AnimatedBoundary.md#manim.animation.changing.AnimatedBoundary) | Boundary of a [`VMobject`](manim.mobject.types.vectorized_mobject.VMobject.md#manim.mobject.types.vectorized_mobject.VMobject) with animated color change. |
8
+ |----------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------|
9
+ | [`TracedPath`](manim.animation.changing.TracedPath.md#manim.animation.changing.TracedPath) | Traces the path of a point returned by a function call. |
data/rag/manim_docs/manim_core/docs/reference/manim.animation.composition.AnimationGroup.md ADDED
@@ -0,0 +1,153 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # AnimationGroup
2
+
3
+ Qualified name: `manim.animation.composition.AnimationGroup`
4
+
5
+ ### *class* AnimationGroup(mobject=None, \*args, use_override=True, \*\*kwargs)
6
+
7
+ Bases: [`Animation`](manim.animation.animation.Animation.md#manim.animation.animation.Animation)
8
+
9
+ Plays a group or series of [`Animation`](manim.animation.animation.Animation.md#manim.animation.animation.Animation).
10
+
11
+ * **Parameters:**
12
+ * **animations** ([*Animation*](manim.animation.animation.Animation.md#manim.animation.animation.Animation) *|* *Iterable* *[*[*Animation*](manim.animation.animation.Animation.md#manim.animation.animation.Animation) *]* *|* *types.GeneratorType* *[*[*Animation*](manim.animation.animation.Animation.md#manim.animation.animation.Animation) *]*) – Sequence of [`Animation`](manim.animation.animation.Animation.md#manim.animation.animation.Animation) objects to be played.
13
+ * **group** ([*Group*](manim.mobject.mobject.Group.md#manim.mobject.mobject.Group) *|* [*VGroup*](manim.mobject.types.vectorized_mobject.VGroup.md#manim.mobject.types.vectorized_mobject.VGroup) *|* *OpenGLGroup* *|* *OpenGLVGroup*) – A group of multiple [`Mobject`](manim.mobject.mobject.Mobject.md#manim.mobject.mobject.Mobject).
14
+ * **run_time** (*float* *|* *None*) – The duration of the animation in seconds.
15
+ * **rate_func** (*Callable* *[* *[**float* *]* *,* *float* *]*) – The function defining the animation progress based on the relative
16
+ runtime (see [`rate_functions`](manim.utils.rate_functions.md#module-manim.utils.rate_functions)) .
17
+ * **lag_ratio** (*float*) –
18
+
19
+ Defines the delay after which the animation is applied to submobjects. A lag_ratio of
20
+ `n.nn` means the next animation will play when `nnn%` of the current animation has played.
21
+ Defaults to 0.0, meaning that all animations will be played together.
22
+
23
+ This does not influence the total runtime of the animation. Instead the runtime
24
+ of individual animations is adjusted so that the complete animation has the defined
25
+ run time.
26
+
27
+ ### Methods
28
+
29
+ | [`begin`](#manim.animation.composition.AnimationGroup.begin) | Begin the animation. |
30
+ |--------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------|
31
+ | [`build_animations_with_timings`](#manim.animation.composition.AnimationGroup.build_animations_with_timings) | Creates a list of triplets of the form (anim, start_time, end_time). |
32
+ | [`clean_up_from_scene`](#manim.animation.composition.AnimationGroup.clean_up_from_scene) | Clean up the [`Scene`](manim.scene.scene.Scene.md#manim.scene.scene.Scene) after finishing the animation. |
33
+ | [`finish`](#manim.animation.composition.AnimationGroup.finish) | Finish the animation. |
34
+ | [`get_all_mobjects`](#manim.animation.composition.AnimationGroup.get_all_mobjects) | Get all mobjects involved in the animation. |
35
+ | [`init_run_time`](#manim.animation.composition.AnimationGroup.init_run_time) | Calculates the run time of the animation, if different from `run_time`. |
36
+ | [`interpolate`](#manim.animation.composition.AnimationGroup.interpolate) | Set the animation progress. |
37
+ | [`update_mobjects`](#manim.animation.composition.AnimationGroup.update_mobjects) | Updates things like starting_mobject, and (for Transforms) target_mobject. |
38
+
39
+ ### Attributes
40
+
41
+ | `run_time` | |
42
+ |--------------|----|
43
+
44
+ #### \_original_\_init_\_(\*animations, group=None, run_time=None, rate_func=<function linear>, lag_ratio=0, \*\*kwargs)
45
+
46
+ Initialize self. See help(type(self)) for accurate signature.
47
+
48
+ * **Parameters:**
49
+ * **animations** ([*Animation*](manim.animation.animation.Animation.md#manim.animation.animation.Animation) *|* *Iterable* *[*[*Animation*](manim.animation.animation.Animation.md#manim.animation.animation.Animation) *]* *|* *types.GeneratorType* *[*[*Animation*](manim.animation.animation.Animation.md#manim.animation.animation.Animation) *]*)
50
+ * **group** ([*Group*](manim.mobject.mobject.Group.md#manim.mobject.mobject.Group) *|* [*VGroup*](manim.mobject.types.vectorized_mobject.VGroup.md#manim.mobject.types.vectorized_mobject.VGroup) *|* *OpenGLGroup* *|* *OpenGLVGroup*)
51
+ * **run_time** (*float* *|* *None*)
52
+ * **rate_func** (*Callable* *[* *[**float* *]* *,* *float* *]*)
53
+ * **lag_ratio** (*float*)
54
+ * **Return type:**
55
+ None
56
+
57
+ #### \_setup_scene(scene)
58
+
59
+ Setup up the [`Scene`](manim.scene.scene.Scene.md#manim.scene.scene.Scene) before starting the animation.
60
+
61
+ This includes to [`add()`](manim.scene.scene.Scene.md#manim.scene.scene.Scene.add) the Animation’s
62
+ [`Mobject`](manim.mobject.mobject.Mobject.md#manim.mobject.mobject.Mobject) if the animation is an introducer.
63
+
64
+ * **Parameters:**
65
+ **scene** – The scene the animation should be cleaned up from.
66
+ * **Return type:**
67
+ None
68
+
69
+ #### begin()
70
+
71
+ Begin the animation.
72
+
73
+ This method is called right as an animation is being played. As much
74
+ initialization as possible, especially any mobject copying, should live in this
75
+ method.
76
+
77
+ * **Return type:**
78
+ None
79
+
80
+ #### build_animations_with_timings()
81
+
82
+ Creates a list of triplets of the form (anim, start_time, end_time).
83
+
84
+ * **Return type:**
85
+ None
86
+
87
+ #### clean_up_from_scene(scene)
88
+
89
+ Clean up the [`Scene`](manim.scene.scene.Scene.md#manim.scene.scene.Scene) after finishing the animation.
90
+
91
+ This includes to [`remove()`](manim.scene.scene.Scene.md#manim.scene.scene.Scene.remove) the Animation’s
92
+ [`Mobject`](manim.mobject.mobject.Mobject.md#manim.mobject.mobject.Mobject) if the animation is a remover.
93
+
94
+ * **Parameters:**
95
+ **scene** ([*Scene*](manim.scene.scene.Scene.md#manim.scene.scene.Scene)) – The scene the animation should be cleaned up from.
96
+ * **Return type:**
97
+ None
98
+
99
+ #### finish()
100
+
101
+ Finish the animation.
102
+
103
+ This method gets called when the animation is over.
104
+
105
+ * **Return type:**
106
+ None
107
+
108
+ #### get_all_mobjects()
109
+
110
+ Get all mobjects involved in the animation.
111
+
112
+ Ordering must match the ordering of arguments to interpolate_submobject
113
+
114
+ * **Returns:**
115
+ The sequence of mobjects.
116
+ * **Return type:**
117
+ Sequence[[Mobject](manim.mobject.mobject.Mobject.md#manim.mobject.mobject.Mobject)]
118
+
119
+ #### init_run_time(run_time)
120
+
121
+ Calculates the run time of the animation, if different from `run_time`.
122
+
123
+ * **Parameters:**
124
+ **run_time** – The duration of the animation in seconds.
125
+ * **Returns:**
126
+ The duration of the animation in seconds.
127
+ * **Return type:**
128
+ run_time
129
+
130
+ #### interpolate(alpha)
131
+
132
+ Set the animation progress.
133
+
134
+ This method gets called for every frame during an animation.
135
+
136
+ * **Parameters:**
137
+ **alpha** (*float*) – The relative time to set the animation to, 0 meaning the start, 1 meaning
138
+ the end.
139
+ * **Return type:**
140
+ None
141
+
142
+ #### update_mobjects(dt)
143
+
144
+ Updates things like starting_mobject, and (for
145
+ Transforms) target_mobject. Note, since typically
146
+ (always?) self.mobject will have its updating
147
+ suspended during the animation, this will do
148
+ nothing to self.mobject.
149
+
150
+ * **Parameters:**
151
+ **dt** (*float*)
152
+ * **Return type:**
153
+ None
data/rag/manim_docs/manim_core/docs/reference/manim.animation.composition.LaggedStart.md ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # LaggedStart
2
+
3
+ Qualified name: `manim.animation.composition.LaggedStart`
4
+
5
+ ### *class* LaggedStart(mobject=None, \*args, use_override=True, \*\*kwargs)
6
+
7
+ Bases: [`AnimationGroup`](manim.animation.composition.AnimationGroup.md#manim.animation.composition.AnimationGroup)
8
+
9
+ Adjusts the timing of a series of [`Animation`](manim.animation.animation.Animation.md#manim.animation.animation.Animation) according to `lag_ratio`.
10
+
11
+ * **Parameters:**
12
+ * **animations** ([*Animation*](manim.animation.animation.Animation.md#manim.animation.animation.Animation)) – Sequence of [`Animation`](manim.animation.animation.Animation.md#manim.animation.animation.Animation) objects to be played.
13
+ * **lag_ratio** (*float*) –
14
+
15
+ Defines the delay after which the animation is applied to submobjects. A lag_ratio of
16
+ `n.nn` means the next animation will play when `nnn%` of the current animation has played.
17
+ Defaults to 0.05, meaning that the next animation will begin when 5% of the current
18
+ animation has played.
19
+
20
+ This does not influence the total runtime of the animation. Instead the runtime
21
+ of individual animations is adjusted so that the complete animation has the defined
22
+ run time.
23
+
24
+ ### Examples
25
+
26
+ <div id="laggedstartexample" class="admonition admonition-manim-example">
27
+ <p class="admonition-title">Example: LaggedStartExample <a class="headerlink" href="#laggedstartexample">¶</a></p><video
28
+ class="manim-video"
29
+ controls
30
+ loop
31
+ autoplay
32
+ src="./LaggedStartExample-1.mp4">
33
+ </video>
34
+ ```python
35
+ from manim import *
36
+
37
+ class LaggedStartExample(Scene):
38
+ def construct(self):
39
+ title = Text("lag_ratio = 0.25").to_edge(UP)
40
+
41
+ dot1 = Dot(point=LEFT * 2 + UP, radius=0.16)
42
+ dot2 = Dot(point=LEFT * 2, radius=0.16)
43
+ dot3 = Dot(point=LEFT * 2 + DOWN, radius=0.16)
44
+ line_25 = DashedLine(
45
+ start=LEFT + UP * 2,
46
+ end=LEFT + DOWN * 2,
47
+ color=RED
48
+ )
49
+ label = Text("25%", font_size=24).next_to(line_25, UP)
50
+ self.add(title, dot1, dot2, dot3, line_25, label)
51
+
52
+ self.play(LaggedStart(
53
+ dot1.animate.shift(RIGHT * 4),
54
+ dot2.animate.shift(RIGHT * 4),
55
+ dot3.animate.shift(RIGHT * 4),
56
+ lag_ratio=0.25,
57
+ run_time=4
58
+ ))
59
+ ```
60
+
61
+ <pre data-manim-binder data-manim-classname="LaggedStartExample">
62
+ class LaggedStartExample(Scene):
63
+ def construct(self):
64
+ title = Text("lag_ratio = 0.25").to_edge(UP)
65
+
66
+ dot1 = Dot(point=LEFT \* 2 + UP, radius=0.16)
67
+ dot2 = Dot(point=LEFT \* 2, radius=0.16)
68
+ dot3 = Dot(point=LEFT \* 2 + DOWN, radius=0.16)
69
+ line_25 = DashedLine(
70
+ start=LEFT + UP \* 2,
71
+ end=LEFT + DOWN \* 2,
72
+ color=RED
73
+ )
74
+ label = Text("25%", font_size=24).next_to(line_25, UP)
75
+ self.add(title, dot1, dot2, dot3, line_25, label)
76
+
77
+ self.play(LaggedStart(
78
+ dot1.animate.shift(RIGHT \* 4),
79
+ dot2.animate.shift(RIGHT \* 4),
80
+ dot3.animate.shift(RIGHT \* 4),
81
+ lag_ratio=0.25,
82
+ run_time=4
83
+ ))
84
+
85
+ </pre></div>
86
+
87
+ ### Methods
88
+
89
+ ### Attributes
90
+
91
+ | `run_time` | |
92
+ |--------------|----|
93
+
94
+ #### \_original_\_init_\_(\*animations, lag_ratio=0.05, \*\*kwargs)
95
+
96
+ Initialize self. See help(type(self)) for accurate signature.
97
+
98
+ * **Parameters:**
99
+ * **animations** ([*Animation*](manim.animation.animation.Animation.md#manim.animation.animation.Animation))
100
+ * **lag_ratio** (*float*)
data/rag/manim_docs/manim_core/docs/reference/manim.animation.composition.LaggedStartMap.md ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # LaggedStartMap
2
+
3
+ Qualified name: `manim.animation.composition.LaggedStartMap`
4
+
5
+ ### *class* LaggedStartMap(mobject=None, \*args, use_override=True, \*\*kwargs)
6
+
7
+ Bases: [`LaggedStart`](manim.animation.composition.LaggedStart.md#manim.animation.composition.LaggedStart)
8
+
9
+ Plays a series of [`Animation`](manim.animation.animation.Animation.md#manim.animation.animation.Animation) while mapping a function to submobjects.
10
+
11
+ * **Parameters:**
12
+ * **AnimationClass** (*Callable* *[* *...* *,* [*Animation*](manim.animation.animation.Animation.md#manim.animation.animation.Animation) *]*) – [`Animation`](manim.animation.animation.Animation.md#manim.animation.animation.Animation) to apply to mobject.
13
+ * **mobject** ([*Mobject*](manim.mobject.mobject.Mobject.md#manim.mobject.mobject.Mobject)) – [`Mobject`](manim.mobject.mobject.Mobject.md#manim.mobject.mobject.Mobject) whose submobjects the animation, and optionally the function,
14
+ are to be applied.
15
+ * **arg_creator** (*Callable* *[* *[*[*Mobject*](manim.mobject.mobject.Mobject.md#manim.mobject.mobject.Mobject) *]* *,* *str* *]*) – Function which will be applied to [`Mobject`](manim.mobject.mobject.Mobject.md#manim.mobject.mobject.Mobject).
16
+ * **run_time** (*float*) – The duration of the animation in seconds.
17
+
18
+ ### Examples
19
+
20
+ <div id="laggedstartmapexample" class="admonition admonition-manim-example">
21
+ <p class="admonition-title">Example: LaggedStartMapExample <a class="headerlink" href="#laggedstartmapexample">¶</a></p><video
22
+ class="manim-video"
23
+ controls
24
+ loop
25
+ autoplay
26
+ src="./LaggedStartMapExample-1.mp4">
27
+ </video>
28
+ ```python
29
+ from manim import *
30
+
31
+ class LaggedStartMapExample(Scene):
32
+ def construct(self):
33
+ title = Tex("LaggedStartMap").to_edge(UP, buff=LARGE_BUFF)
34
+ dots = VGroup(
35
+ *[Dot(radius=0.16) for _ in range(35)]
36
+ ).arrange_in_grid(rows=5, cols=7, buff=MED_LARGE_BUFF)
37
+ self.add(dots, title)
38
+
39
+ # Animate yellow ripple effect
40
+ for mob in dots, title:
41
+ self.play(LaggedStartMap(
42
+ ApplyMethod, mob,
43
+ lambda m : (m.set_color, YELLOW),
44
+ lag_ratio = 0.1,
45
+ rate_func = there_and_back,
46
+ run_time = 2
47
+ ))
48
+ ```
49
+
50
+ <pre data-manim-binder data-manim-classname="LaggedStartMapExample">
51
+ class LaggedStartMapExample(Scene):
52
+ def construct(self):
53
+ title = Tex("LaggedStartMap").to_edge(UP, buff=LARGE_BUFF)
54
+ dots = VGroup(
55
+ \*[Dot(radius=0.16) for \_ in range(35)]
56
+ ).arrange_in_grid(rows=5, cols=7, buff=MED_LARGE_BUFF)
57
+ self.add(dots, title)
58
+
59
+ # Animate yellow ripple effect
60
+ for mob in dots, title:
61
+ self.play(LaggedStartMap(
62
+ ApplyMethod, mob,
63
+ lambda m : (m.set_color, YELLOW),
64
+ lag_ratio = 0.1,
65
+ rate_func = there_and_back,
66
+ run_time = 2
67
+ ))
68
+
69
+ </pre></div>
70
+
71
+ ### Methods
72
+
73
+ ### Attributes
74
+
75
+ | `run_time` | |
76
+ |--------------|----|
77
+
78
+ #### \_original_\_init_\_(AnimationClass, mobject, arg_creator=None, run_time=2, \*\*kwargs)
79
+
80
+ Initialize self. See help(type(self)) for accurate signature.
81
+
82
+ * **Parameters:**
83
+ * **AnimationClass** (*Callable* *[* *[* *...* *]* *,* [*Animation*](manim.animation.animation.Animation.md#manim.animation.animation.Animation) *]*)
84
+ * **mobject** ([*Mobject*](manim.mobject.mobject.Mobject.md#manim.mobject.mobject.Mobject))
85
+ * **arg_creator** (*Callable* *[* *[*[*Mobject*](manim.mobject.mobject.Mobject.md#manim.mobject.mobject.Mobject) *]* *,* *str* *]*)
86
+ * **run_time** (*float*)
87
+ * **Return type:**
88
+ None
data/rag/manim_docs/manim_core/docs/reference/manim.animation.composition.Succession.md ADDED
@@ -0,0 +1,160 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Succession
2
+
3
+ Qualified name: `manim.animation.composition.Succession`
4
+
5
+ ### *class* Succession(mobject=None, \*args, use_override=True, \*\*kwargs)
6
+
7
+ Bases: [`AnimationGroup`](manim.animation.composition.AnimationGroup.md#manim.animation.composition.AnimationGroup)
8
+
9
+ Plays a series of animations in succession.
10
+
11
+ * **Parameters:**
12
+ * **animations** ([*Animation*](manim.animation.animation.Animation.md#manim.animation.animation.Animation)) – Sequence of [`Animation`](manim.animation.animation.Animation.md#manim.animation.animation.Animation) objects to be played.
13
+ * **lag_ratio** (*float*) –
14
+
15
+ Defines the delay after which the animation is applied to submobjects. A lag_ratio of
16
+ `n.nn` means the next animation will play when `nnn%` of the current animation has played.
17
+ Defaults to 1.0, meaning that the next animation will begin when 100% of the current
18
+ animation has played.
19
+
20
+ This does not influence the total runtime of the animation. Instead the runtime
21
+ of individual animations is adjusted so that the complete animation has the defined
22
+ run time.
23
+
24
+ ### Examples
25
+
26
+ <div id="successionexample" class="admonition admonition-manim-example">
27
+ <p class="admonition-title">Example: SuccessionExample <a class="headerlink" href="#successionexample">¶</a></p><video
28
+ class="manim-video"
29
+ controls
30
+ loop
31
+ autoplay
32
+ src="./SuccessionExample-1.mp4">
33
+ </video>
34
+ ```python
35
+ from manim import *
36
+
37
+ class SuccessionExample(Scene):
38
+ def construct(self):
39
+ dot1 = Dot(point=LEFT * 2 + UP * 2, radius=0.16, color=BLUE)
40
+ dot2 = Dot(point=LEFT * 2 + DOWN * 2, radius=0.16, color=MAROON)
41
+ dot3 = Dot(point=RIGHT * 2 + DOWN * 2, radius=0.16, color=GREEN)
42
+ dot4 = Dot(point=RIGHT * 2 + UP * 2, radius=0.16, color=YELLOW)
43
+ self.add(dot1, dot2, dot3, dot4)
44
+
45
+ self.play(Succession(
46
+ dot1.animate.move_to(dot2),
47
+ dot2.animate.move_to(dot3),
48
+ dot3.animate.move_to(dot4),
49
+ dot4.animate.move_to(dot1)
50
+ ))
51
+ ```
52
+
53
+ <pre data-manim-binder data-manim-classname="SuccessionExample">
54
+ class SuccessionExample(Scene):
55
+ def construct(self):
56
+ dot1 = Dot(point=LEFT \* 2 + UP \* 2, radius=0.16, color=BLUE)
57
+ dot2 = Dot(point=LEFT \* 2 + DOWN \* 2, radius=0.16, color=MAROON)
58
+ dot3 = Dot(point=RIGHT \* 2 + DOWN \* 2, radius=0.16, color=GREEN)
59
+ dot4 = Dot(point=RIGHT \* 2 + UP \* 2, radius=0.16, color=YELLOW)
60
+ self.add(dot1, dot2, dot3, dot4)
61
+
62
+ self.play(Succession(
63
+ dot1.animate.move_to(dot2),
64
+ dot2.animate.move_to(dot3),
65
+ dot3.animate.move_to(dot4),
66
+ dot4.animate.move_to(dot1)
67
+ ))
68
+
69
+ </pre></div>
70
+
71
+ ### Methods
72
+
73
+ | [`begin`](#manim.animation.composition.Succession.begin) | Begin the animation. |
74
+ |------------------------------------------------------------------------------|----------------------------------------------------------------------------|
75
+ | [`finish`](#manim.animation.composition.Succession.finish) | Finish the animation. |
76
+ | [`interpolate`](#manim.animation.composition.Succession.interpolate) | Set the animation progress. |
77
+ | [`next_animation`](#manim.animation.composition.Succession.next_animation) | Proceeds to the next animation. |
78
+ | `update_active_animation` | |
79
+ | [`update_mobjects`](#manim.animation.composition.Succession.update_mobjects) | Updates things like starting_mobject, and (for Transforms) target_mobject. |
80
+
81
+ ### Attributes
82
+
83
+ | `run_time` | |
84
+ |--------------|----|
85
+
86
+ #### \_original_\_init_\_(\*animations, lag_ratio=1, \*\*kwargs)
87
+
88
+ Initialize self. See help(type(self)) for accurate signature.
89
+
90
+ * **Parameters:**
91
+ * **animations** ([*Animation*](manim.animation.animation.Animation.md#manim.animation.animation.Animation))
92
+ * **lag_ratio** (*float*)
93
+ * **Return type:**
94
+ None
95
+
96
+ #### \_setup_scene(scene)
97
+
98
+ Setup up the [`Scene`](manim.scene.scene.Scene.md#manim.scene.scene.Scene) before starting the animation.
99
+
100
+ This includes to [`add()`](manim.scene.scene.Scene.md#manim.scene.scene.Scene.add) the Animation’s
101
+ [`Mobject`](manim.mobject.mobject.Mobject.md#manim.mobject.mobject.Mobject) if the animation is an introducer.
102
+
103
+ * **Parameters:**
104
+ **scene** – The scene the animation should be cleaned up from.
105
+ * **Return type:**
106
+ None
107
+
108
+ #### begin()
109
+
110
+ Begin the animation.
111
+
112
+ This method is called right as an animation is being played. As much
113
+ initialization as possible, especially any mobject copying, should live in this
114
+ method.
115
+
116
+ * **Return type:**
117
+ None
118
+
119
+ #### finish()
120
+
121
+ Finish the animation.
122
+
123
+ This method gets called when the animation is over.
124
+
125
+ * **Return type:**
126
+ None
127
+
128
+ #### interpolate(alpha)
129
+
130
+ Set the animation progress.
131
+
132
+ This method gets called for every frame during an animation.
133
+
134
+ * **Parameters:**
135
+ **alpha** (*float*) – The relative time to set the animation to, 0 meaning the start, 1 meaning
136
+ the end.
137
+ * **Return type:**
138
+ None
139
+
140
+ #### next_animation()
141
+
142
+ Proceeds to the next animation.
143
+
144
+ This method is called right when the active animation finishes.
145
+
146
+ * **Return type:**
147
+ None
148
+
149
+ #### update_mobjects(dt)
150
+
151
+ Updates things like starting_mobject, and (for
152
+ Transforms) target_mobject. Note, since typically
153
+ (always?) self.mobject will have its updating
154
+ suspended during the animation, this will do
155
+ nothing to self.mobject.
156
+
157
+ * **Parameters:**
158
+ **dt** (*float*)
159
+ * **Return type:**
160
+ None
data/rag/manim_docs/manim_core/docs/reference/manim.animation.composition.md ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # composition
2
+
3
+ Tools for displaying multiple animations at once.
4
+
5
+ ### Classes
6
+
7
+ | [`AnimationGroup`](manim.animation.composition.AnimationGroup.md#manim.animation.composition.AnimationGroup) | Plays a group or series of [`Animation`](manim.animation.animation.Animation.md#manim.animation.animation.Animation). |
8
+ |----------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------|
9
+ | [`LaggedStart`](manim.animation.composition.LaggedStart.md#manim.animation.composition.LaggedStart) | Adjusts the timing of a series of [`Animation`](manim.animation.animation.Animation.md#manim.animation.animation.Animation) according to `lag_ratio`. |
10
+ | [`LaggedStartMap`](manim.animation.composition.LaggedStartMap.md#manim.animation.composition.LaggedStartMap) | Plays a series of [`Animation`](manim.animation.animation.Animation.md#manim.animation.animation.Animation) while mapping a function to submobjects. |
11
+ | [`Succession`](manim.animation.composition.Succession.md#manim.animation.composition.Succession) | Plays a series of animations in succession. |
data/rag/manim_docs/manim_core/docs/reference/manim.animation.creation.AddTextLetterByLetter.md ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # AddTextLetterByLetter
2
+
3
+ Qualified name: `manim.animation.creation.AddTextLetterByLetter`
4
+
5
+ ### *class* AddTextLetterByLetter(mobject=None, \*args, use_override=True, \*\*kwargs)
6
+
7
+ Bases: [`ShowIncreasingSubsets`](manim.animation.creation.ShowIncreasingSubsets.md#manim.animation.creation.ShowIncreasingSubsets)
8
+
9
+ Show a [`Text`](manim.mobject.text.text_mobject.Text.md#manim.mobject.text.text_mobject.Text) letter by letter on the scene.
10
+
11
+ * **Parameters:**
12
+ * **time_per_char** (*float*) – Frequency of appearance of the letters.
13
+ * **tip::** ( *..*) – This is currently only possible for class:~.Text and not for class:~.MathTex
14
+ * **text** ([*Text*](manim.mobject.text.text_mobject.Text.md#manim.mobject.text.text_mobject.Text))
15
+ * **suspend_mobject_updating** (*bool*)
16
+ * **int_func** (*Callable* *[* *[**np.ndarray* *]* *,* *np.ndarray* *]*)
17
+ * **rate_func** (*Callable* *[* *[**float* *]* *,* *float* *]*)
18
+ * **run_time** (*float* *|* *None*)
19
+
20
+ ### Methods
21
+
22
+ ### Attributes
23
+
24
+ | `run_time` | |
25
+ |--------------|----|
26
+
27
+ #### \_original_\_init_\_(text, suspend_mobject_updating=False, int_func=<ufunc 'ceil'>, rate_func=<function linear>, time_per_char=0.1, run_time=None, reverse_rate_function=False, introducer=True, \*\*kwargs)
28
+
29
+ Initialize self. See help(type(self)) for accurate signature.
30
+
31
+ * **Parameters:**
32
+ * **text** ([*Text*](manim.mobject.text.text_mobject.Text.md#manim.mobject.text.text_mobject.Text))
33
+ * **suspend_mobject_updating** (*bool*)
34
+ * **int_func** (*Callable* *[* *[**np.ndarray* *]* *,* *np.ndarray* *]*)
35
+ * **rate_func** (*Callable* *[* *[**float* *]* *,* *float* *]*)
36
+ * **time_per_char** (*float*)
37
+ * **run_time** (*float* *|* *None*)
38
+ * **Return type:**
39
+ None
data/rag/manim_docs/manim_core/docs/reference/manim.animation.creation.AddTextWordByWord.md ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # AddTextWordByWord
2
+
3
+ Qualified name: `manim.animation.creation.AddTextWordByWord`
4
+
5
+ ### *class* AddTextWordByWord(mobject=None, \*args, use_override=True, \*\*kwargs)
6
+
7
+ Bases: [`Succession`](manim.animation.composition.Succession.md#manim.animation.composition.Succession)
8
+
9
+ Show a [`Text`](manim.mobject.text.text_mobject.Text.md#manim.mobject.text.text_mobject.Text) word by word on the scene. Note: currently broken.
10
+
11
+ ### Methods
12
+
13
+ ### Attributes
14
+
15
+ | `run_time` | |
16
+ |--------------|----|
17
+ * **Parameters:**
18
+ * **text_mobject** ([*Text*](manim.mobject.text.text_mobject.Text.md#manim.mobject.text.text_mobject.Text))
19
+ * **run_time** (*float*)
20
+ * **time_per_char** (*float*)
21
+
22
+ #### \_original_\_init_\_(text_mobject, run_time=None, time_per_char=0.06, \*\*kwargs)
23
+
24
+ Initialize self. See help(type(self)) for accurate signature.
25
+
26
+ * **Parameters:**
27
+ * **text_mobject** ([*Text*](manim.mobject.text.text_mobject.Text.md#manim.mobject.text.text_mobject.Text))
28
+ * **run_time** (*float*)
29
+ * **time_per_char** (*float*)
30
+ * **Return type:**
31
+ None
data/rag/manim_docs/manim_core/docs/reference/manim.animation.creation.Create.md ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Create
2
+
3
+ Qualified name: `manim.animation.creation.Create`
4
+
5
+ ### *class* Create(mobject=None, \*args, use_override=True, \*\*kwargs)
6
+
7
+ Bases: [`ShowPartial`](manim.animation.creation.ShowPartial.md#manim.animation.creation.ShowPartial)
8
+
9
+ Incrementally show a VMobject.
10
+
11
+ * **Parameters:**
12
+ * **mobject** ([*VMobject*](manim.mobject.types.vectorized_mobject.VMobject.md#manim.mobject.types.vectorized_mobject.VMobject) *|* *OpenGLVMobject* *|* *OpenGLSurface*) – The VMobject to animate.
13
+ * **lag_ratio** (*float*)
14
+ * **introducer** (*bool*)
15
+ * **Raises:**
16
+ **TypeError** – If `mobject` is not an instance of [`VMobject`](manim.mobject.types.vectorized_mobject.VMobject.md#manim.mobject.types.vectorized_mobject.VMobject).
17
+
18
+ ### Examples
19
+
20
+ <div id="createscene" class="admonition admonition-manim-example">
21
+ <p class="admonition-title">Example: CreateScene <a class="headerlink" href="#createscene">¶</a></p><video
22
+ class="manim-video"
23
+ controls
24
+ loop
25
+ autoplay
26
+ src="./CreateScene-1.mp4">
27
+ </video>
28
+ ```python
29
+ from manim import *
30
+
31
+ class CreateScene(Scene):
32
+ def construct(self):
33
+ self.play(Create(Square()))
34
+ ```
35
+
36
+ <pre data-manim-binder data-manim-classname="CreateScene">
37
+ class CreateScene(Scene):
38
+ def construct(self):
39
+ self.play(Create(Square()))
40
+
41
+ </pre></div>
42
+
43
+ #### SEE ALSO
44
+ [`ShowPassingFlash`](manim.animation.indication.ShowPassingFlash.md#manim.animation.indication.ShowPassingFlash)
45
+
46
+ ### Methods
47
+
48
+ ### Attributes
49
+
50
+ | `run_time` | |
51
+ |--------------|----|
52
+
53
+ #### \_original_\_init_\_(mobject, lag_ratio=1.0, introducer=True, \*\*kwargs)
54
+
55
+ Initialize self. See help(type(self)) for accurate signature.
56
+
57
+ * **Parameters:**
58
+ * **mobject** ([*VMobject*](manim.mobject.types.vectorized_mobject.VMobject.md#manim.mobject.types.vectorized_mobject.VMobject) *|* *OpenGLVMobject* *|* *OpenGLSurface*)
59
+ * **lag_ratio** (*float*)
60
+ * **introducer** (*bool*)
61
+ * **Return type:**
62
+ None
data/rag/manim_docs/manim_core/docs/reference/manim.animation.creation.DrawBorderThenFill.md ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # DrawBorderThenFill
2
+
3
+ Qualified name: `manim.animation.creation.DrawBorderThenFill`
4
+
5
+ ### *class* DrawBorderThenFill(mobject=None, \*args, use_override=True, \*\*kwargs)
6
+
7
+ Bases: [`Animation`](manim.animation.animation.Animation.md#manim.animation.animation.Animation)
8
+
9
+ Draw the border first and then show the fill.
10
+
11
+ ### Examples
12
+
13
+ <div id="showdrawborderthenfill" class="admonition admonition-manim-example">
14
+ <p class="admonition-title">Example: ShowDrawBorderThenFill <a class="headerlink" href="#showdrawborderthenfill">¶</a></p><video
15
+ class="manim-video"
16
+ controls
17
+ loop
18
+ autoplay
19
+ src="./ShowDrawBorderThenFill-1.mp4">
20
+ </video>
21
+ ```python
22
+ from manim import *
23
+
24
+ class ShowDrawBorderThenFill(Scene):
25
+ def construct(self):
26
+ self.play(DrawBorderThenFill(Square(fill_opacity=1, fill_color=ORANGE)))
27
+ ```
28
+
29
+ <pre data-manim-binder data-manim-classname="ShowDrawBorderThenFill">
30
+ class ShowDrawBorderThenFill(Scene):
31
+ def construct(self):
32
+ self.play(DrawBorderThenFill(Square(fill_opacity=1, fill_color=ORANGE)))
33
+
34
+ </pre></div>
35
+
36
+ ### Methods
37
+
38
+ | [`begin`](#manim.animation.creation.DrawBorderThenFill.begin) | Begin the animation. |
39
+ |-------------------------------------------------------------------------------------|---------------------------------------------|
40
+ | [`get_all_mobjects`](#manim.animation.creation.DrawBorderThenFill.get_all_mobjects) | Get all mobjects involved in the animation. |
41
+ | `get_outline` | |
42
+ | `get_stroke_color` | |
43
+ | `interpolate_submobject` | |
44
+
45
+ ### Attributes
46
+
47
+ | `run_time` | |
48
+ |--------------|----|
49
+ * **Parameters:**
50
+ * **vmobject** ([*VMobject*](manim.mobject.types.vectorized_mobject.VMobject.md#manim.mobject.types.vectorized_mobject.VMobject) *|* *OpenGLVMobject*)
51
+ * **run_time** (*float*)
52
+ * **rate_func** (*Callable* *[* *[**float* *]* *,* *float* *]*)
53
+ * **stroke_width** (*float*)
54
+ * **stroke_color** (*str*)
55
+ * **draw_border_animation_config** (*dict*)
56
+ * **fill_animation_config** (*dict*)
57
+ * **introducer** (*bool*)
58
+
59
+ #### \_original_\_init_\_(vmobject, run_time=2, rate_func=<function double_smooth>, stroke_width=2, stroke_color=None, draw_border_animation_config={}, fill_animation_config={}, introducer=True, \*\*kwargs)
60
+
61
+ Initialize self. See help(type(self)) for accurate signature.
62
+
63
+ * **Parameters:**
64
+ * **vmobject** ([*VMobject*](manim.mobject.types.vectorized_mobject.VMobject.md#manim.mobject.types.vectorized_mobject.VMobject) *|* *OpenGLVMobject*)
65
+ * **run_time** (*float*)
66
+ * **rate_func** (*Callable* *[* *[**float* *]* *,* *float* *]*)
67
+ * **stroke_width** (*float*)
68
+ * **stroke_color** (*str*)
69
+ * **draw_border_animation_config** (*dict*)
70
+ * **fill_animation_config** (*dict*)
71
+ * **introducer** (*bool*)
72
+ * **Return type:**
73
+ None
74
+
75
+ #### begin()
76
+
77
+ Begin the animation.
78
+
79
+ This method is called right as an animation is being played. As much
80
+ initialization as possible, especially any mobject copying, should live in this
81
+ method.
82
+
83
+ * **Return type:**
84
+ None
85
+
86
+ #### get_all_mobjects()
87
+
88
+ Get all mobjects involved in the animation.
89
+
90
+ Ordering must match the ordering of arguments to interpolate_submobject
91
+
92
+ * **Returns:**
93
+ The sequence of mobjects.
94
+ * **Return type:**
95
+ Sequence[[Mobject](manim.mobject.mobject.Mobject.md#manim.mobject.mobject.Mobject)]
data/rag/manim_docs/manim_core/docs/reference/manim.animation.creation.RemoveTextLetterByLetter.md ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # RemoveTextLetterByLetter
2
+
3
+ Qualified name: `manim.animation.creation.RemoveTextLetterByLetter`
4
+
5
+ ### *class* RemoveTextLetterByLetter(mobject=None, \*args, use_override=True, \*\*kwargs)
6
+
7
+ Bases: [`AddTextLetterByLetter`](manim.animation.creation.AddTextLetterByLetter.md#manim.animation.creation.AddTextLetterByLetter)
8
+
9
+ Remove a [`Text`](manim.mobject.text.text_mobject.Text.md#manim.mobject.text.text_mobject.Text) letter by letter from the scene.
10
+
11
+ * **Parameters:**
12
+ * **time_per_char** (*float*) – Frequency of appearance of the letters.
13
+ * **tip::** ( *..*) – This is currently only possible for class:~.Text and not for class:~.MathTex
14
+ * **text** ([*Text*](manim.mobject.text.text_mobject.Text.md#manim.mobject.text.text_mobject.Text))
15
+ * **suspend_mobject_updating** (*bool*)
16
+ * **int_func** (*Callable* *[* *[**np.ndarray* *]* *,* *np.ndarray* *]*)
17
+ * **rate_func** (*Callable* *[* *[**float* *]* *,* *float* *]*)
18
+ * **run_time** (*float* *|* *None*)
19
+
20
+ ### Methods
21
+
22
+ ### Attributes
23
+
24
+ | `run_time` | |
25
+ |--------------|----|
26
+
27
+ #### \_original_\_init_\_(text, suspend_mobject_updating=False, int_func=<ufunc 'ceil'>, rate_func=<function linear>, time_per_char=0.1, run_time=None, reverse_rate_function=True, introducer=False, remover=True, \*\*kwargs)
28
+
29
+ Initialize self. See help(type(self)) for accurate signature.
30
+
31
+ * **Parameters:**
32
+ * **text** ([*Text*](manim.mobject.text.text_mobject.Text.md#manim.mobject.text.text_mobject.Text))
33
+ * **suspend_mobject_updating** (*bool*)
34
+ * **int_func** (*Callable* *[* *[**np.ndarray* *]* *,* *np.ndarray* *]*)
35
+ * **rate_func** (*Callable* *[* *[**float* *]* *,* *float* *]*)
36
+ * **time_per_char** (*float*)
37
+ * **run_time** (*float* *|* *None*)
38
+ * **Return type:**
39
+ None
data/rag/manim_docs/manim_core/docs/reference/manim.animation.creation.ShowIncreasingSubsets.md ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ShowIncreasingSubsets
2
+
3
+ Qualified name: `manim.animation.creation.ShowIncreasingSubsets`
4
+
5
+ ### *class* ShowIncreasingSubsets(mobject=None, \*args, use_override=True, \*\*kwargs)
6
+
7
+ Bases: [`Animation`](manim.animation.animation.Animation.md#manim.animation.animation.Animation)
8
+
9
+ Show one submobject at a time, leaving all previous ones displayed on screen.
10
+
11
+ ### Examples
12
+
13
+ <div id="showincreasingsubsetsscene" class="admonition admonition-manim-example">
14
+ <p class="admonition-title">Example: ShowIncreasingSubsetsScene <a class="headerlink" href="#showincreasingsubsetsscene">¶</a></p><video
15
+ class="manim-video"
16
+ controls
17
+ loop
18
+ autoplay
19
+ src="./ShowIncreasingSubsetsScene-1.mp4">
20
+ </video>
21
+ ```python
22
+ from manim import *
23
+
24
+ class ShowIncreasingSubsetsScene(Scene):
25
+ def construct(self):
26
+ p = VGroup(Dot(), Square(), Triangle())
27
+ self.add(p)
28
+ self.play(ShowIncreasingSubsets(p))
29
+ self.wait()
30
+ ```
31
+
32
+ <pre data-manim-binder data-manim-classname="ShowIncreasingSubsetsScene">
33
+ class ShowIncreasingSubsetsScene(Scene):
34
+ def construct(self):
35
+ p = VGroup(Dot(), Square(), Triangle())
36
+ self.add(p)
37
+ self.play(ShowIncreasingSubsets(p))
38
+ self.wait()
39
+
40
+ </pre></div>
41
+
42
+ ### Methods
43
+
44
+ | [`interpolate_mobject`](#manim.animation.creation.ShowIncreasingSubsets.interpolate_mobject) | Interpolates the mobject of the `Animation` based on alpha value. |
45
+ |------------------------------------------------------------------------------------------------|---------------------------------------------------------------------|
46
+ | `update_submobject_list` | |
47
+
48
+ ### Attributes
49
+
50
+ | `run_time` | |
51
+ |--------------|----|
52
+ * **Parameters:**
53
+ * **group** ([*Mobject*](manim.mobject.mobject.Mobject.md#manim.mobject.mobject.Mobject))
54
+ * **suspend_mobject_updating** (*bool*)
55
+ * **int_func** (*Callable* *[* *[**np.ndarray* *]* *,* *np.ndarray* *]*)
56
+
57
+ #### \_original_\_init_\_(group, suspend_mobject_updating=False, int_func=<ufunc 'floor'>, reverse_rate_function=False, \*\*kwargs)
58
+
59
+ Initialize self. See help(type(self)) for accurate signature.
60
+
61
+ * **Parameters:**
62
+ * **group** ([*Mobject*](manim.mobject.mobject.Mobject.md#manim.mobject.mobject.Mobject))
63
+ * **suspend_mobject_updating** (*bool*)
64
+ * **int_func** (*Callable* *[* *[**ndarray* *]* *,* *ndarray* *]*)
65
+ * **Return type:**
66
+ None
67
+
68
+ #### interpolate_mobject(alpha)
69
+
70
+ Interpolates the mobject of the `Animation` based on alpha value.
71
+
72
+ * **Parameters:**
73
+ **alpha** (*float*) – A float between 0 and 1 expressing the ratio to which the animation
74
+ is completed. For example, alpha-values of 0, 0.5, and 1 correspond
75
+ to the animation being completed 0%, 50%, and 100%, respectively.
76
+ * **Return type:**
77
+ None
data/rag/manim_docs/manim_core/docs/reference/manim.animation.creation.ShowPartial.md ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ShowPartial
2
+
3
+ Qualified name: `manim.animation.creation.ShowPartial`
4
+
5
+ ### *class* ShowPartial(mobject=None, \*args, use_override=True, \*\*kwargs)
6
+
7
+ Bases: [`Animation`](manim.animation.animation.Animation.md#manim.animation.animation.Animation)
8
+
9
+ Abstract class for Animations that show the VMobject partially.
10
+
11
+ * **Raises:**
12
+ **TypeError** – If `mobject` is not an instance of [`VMobject`](manim.mobject.types.vectorized_mobject.VMobject.md#manim.mobject.types.vectorized_mobject.VMobject).
13
+ * **Parameters:**
14
+ **mobject** ([*VMobject*](manim.mobject.types.vectorized_mobject.VMobject.md#manim.mobject.types.vectorized_mobject.VMobject) *|* *OpenGLVMobject* *|* *OpenGLSurface* *|* *None*)
15
+
16
+ #### SEE ALSO
17
+ [`Create`](manim.animation.creation.Create.md#manim.animation.creation.Create), [`ShowPassingFlash`](manim.animation.indication.ShowPassingFlash.md#manim.animation.indication.ShowPassingFlash)
18
+
19
+ ### Methods
20
+
21
+ | `interpolate_submobject` | |
22
+ |----------------------------|----|
23
+
24
+ ### Attributes
25
+
26
+ | `run_time` | |
27
+ |--------------|----|
28
+
29
+ #### \_original_\_init_\_(mobject, \*\*kwargs)
30
+
31
+ Initialize self. See help(type(self)) for accurate signature.
32
+
33
+ * **Parameters:**
34
+ **mobject** ([*VMobject*](manim.mobject.types.vectorized_mobject.VMobject.md#manim.mobject.types.vectorized_mobject.VMobject) *|* *OpenGLVMobject* *|* *OpenGLSurface* *|* *None*)
data/rag/manim_docs/manim_core/docs/reference/manim.animation.creation.ShowSubmobjectsOneByOne.md ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ShowSubmobjectsOneByOne
2
+
3
+ Qualified name: `manim.animation.creation.ShowSubmobjectsOneByOne`
4
+
5
+ ### *class* ShowSubmobjectsOneByOne(mobject=None, \*args, use_override=True, \*\*kwargs)
6
+
7
+ Bases: [`ShowIncreasingSubsets`](manim.animation.creation.ShowIncreasingSubsets.md#manim.animation.creation.ShowIncreasingSubsets)
8
+
9
+ Show one submobject at a time, removing all previously displayed ones from screen.
10
+
11
+ ### Methods
12
+
13
+ | `update_submobject_list` | |
14
+ |----------------------------|----|
15
+
16
+ ### Attributes
17
+
18
+ | `run_time` | |
19
+ |--------------|----|
20
+ * **Parameters:**
21
+ * **group** (*Iterable* *[*[*Mobject*](manim.mobject.mobject.Mobject.md#manim.mobject.mobject.Mobject) *]*)
22
+ * **int_func** (*Callable* *[* *[**np.ndarray* *]* *,* *np.ndarray* *]*)
23
+
24
+ #### \_original_\_init_\_(group, int_func=<ufunc 'ceil'>, \*\*kwargs)
25
+
26
+ Initialize self. See help(type(self)) for accurate signature.
27
+
28
+ * **Parameters:**
29
+ * **group** (*Iterable* *[*[*Mobject*](manim.mobject.mobject.Mobject.md#manim.mobject.mobject.Mobject) *]*)
30
+ * **int_func** (*Callable* *[* *[**ndarray* *]* *,* *ndarray* *]*)
31
+ * **Return type:**
32
+ None
data/rag/manim_docs/manim_core/docs/reference/manim.animation.creation.SpiralIn.md ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SpiralIn
2
+
3
+ Qualified name: `manim.animation.creation.SpiralIn`
4
+
5
+ ### *class* SpiralIn(mobject=None, \*args, use_override=True, \*\*kwargs)
6
+
7
+ Bases: [`Animation`](manim.animation.animation.Animation.md#manim.animation.animation.Animation)
8
+
9
+ Create the Mobject with sub-Mobjects flying in on spiral trajectories.
10
+
11
+ * **Parameters:**
12
+ * **shapes** ([*Mobject*](manim.mobject.mobject.Mobject.md#manim.mobject.mobject.Mobject)) – The Mobject on which to be operated.
13
+ * **scale_factor** (*float*) – The factor used for scaling the effect.
14
+ * **fade_in_fraction** – Fractional duration of initial fade-in of sub-Mobjects as they fly inward.
15
+
16
+ ### Examples
17
+
18
+ <div id="spiralinexample" class="admonition admonition-manim-example">
19
+ <p class="admonition-title">Example: SpiralInExample <a class="headerlink" href="#spiralinexample">¶</a></p><video
20
+ class="manim-video"
21
+ controls
22
+ loop
23
+ autoplay
24
+ src="./SpiralInExample-1.mp4">
25
+ </video>
26
+ ```python
27
+ from manim import *
28
+
29
+ class SpiralInExample(Scene):
30
+ def construct(self):
31
+ pi = MathTex(r"\pi").scale(7)
32
+ pi.shift(2.25 * LEFT + 1.5 * UP)
33
+ circle = Circle(color=GREEN_C, fill_opacity=1).shift(LEFT)
34
+ square = Square(color=BLUE_D, fill_opacity=1).shift(UP)
35
+ shapes = VGroup(pi, circle, square)
36
+ self.play(SpiralIn(shapes))
37
+ ```
38
+
39
+ <pre data-manim-binder data-manim-classname="SpiralInExample">
40
+ class SpiralInExample(Scene):
41
+ def construct(self):
42
+ pi = MathTex(r"\\pi").scale(7)
43
+ pi.shift(2.25 \* LEFT + 1.5 \* UP)
44
+ circle = Circle(color=GREEN_C, fill_opacity=1).shift(LEFT)
45
+ square = Square(color=BLUE_D, fill_opacity=1).shift(UP)
46
+ shapes = VGroup(pi, circle, square)
47
+ self.play(SpiralIn(shapes))
48
+
49
+ </pre></div>
50
+
51
+ ### Methods
52
+
53
+ | [`interpolate_mobject`](#manim.animation.creation.SpiralIn.interpolate_mobject) | Interpolates the mobject of the `Animation` based on alpha value. |
54
+ |-----------------------------------------------------------------------------------|---------------------------------------------------------------------|
55
+
56
+ ### Attributes
57
+
58
+ | `run_time` | |
59
+ |--------------|----|
60
+
61
+ #### \_original_\_init_\_(shapes, scale_factor=8, fade_in_fraction=0.3, \*\*kwargs)
62
+
63
+ Initialize self. See help(type(self)) for accurate signature.
64
+
65
+ * **Parameters:**
66
+ * **shapes** ([*Mobject*](manim.mobject.mobject.Mobject.md#manim.mobject.mobject.Mobject))
67
+ * **scale_factor** (*float*)
68
+ * **Return type:**
69
+ None
70
+
71
+ #### interpolate_mobject(alpha)
72
+
73
+ Interpolates the mobject of the `Animation` based on alpha value.
74
+
75
+ * **Parameters:**
76
+ **alpha** (*float*) – A float between 0 and 1 expressing the ratio to which the animation
77
+ is completed. For example, alpha-values of 0, 0.5, and 1 correspond
78
+ to the animation being completed 0%, 50%, and 100%, respectively.
79
+ * **Return type:**
80
+ None
data/rag/manim_docs/manim_core/docs/reference/manim.animation.creation.TypeWithCursor.md ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # TypeWithCursor
2
+
3
+ Qualified name: `manim.animation.creation.TypeWithCursor`
4
+
5
+ ### *class* TypeWithCursor(mobject=None, \*args, use_override=True, \*\*kwargs)
6
+
7
+ Bases: [`AddTextLetterByLetter`](manim.animation.creation.AddTextLetterByLetter.md#manim.animation.creation.AddTextLetterByLetter)
8
+
9
+ Similar to [`AddTextLetterByLetter`](manim.animation.creation.AddTextLetterByLetter.md#manim.animation.creation.AddTextLetterByLetter) , but with an additional cursor mobject at the end.
10
+
11
+ * **Parameters:**
12
+ * **time_per_char** (*float*) – Frequency of appearance of the letters.
13
+ * **cursor** ([*Mobject*](manim.mobject.mobject.Mobject.md#manim.mobject.mobject.Mobject)) – [`Mobject`](manim.mobject.mobject.Mobject.md#manim.mobject.mobject.Mobject) shown after the last added letter.
14
+ * **buff** (*float*) – Controls how far away the cursor is to the right of the last added letter.
15
+ * **keep_cursor_y** (*bool*) – If `True`, the cursor’s y-coordinate is set to the center of the `Text` and remains the same throughout the animation. Otherwise, it is set to the center of the last added letter.
16
+ * **leave_cursor_on** (*bool*) – Whether to show the cursor after the animation.
17
+ * **tip::** ( *..*) – This is currently only possible for class:~.Text and not for class:~.MathTex.
18
+ * **text** ([*Text*](manim.mobject.text.text_mobject.Text.md#manim.mobject.text.text_mobject.Text))
19
+
20
+ ### Examples
21
+
22
+ <div id="insertingtextexample" class="admonition admonition-manim-example">
23
+ <p class="admonition-title">Example: InsertingTextExample <a class="headerlink" href="#insertingtextexample">¶</a></p><video
24
+ class="manim-video"
25
+ controls
26
+ loop
27
+ autoplay
28
+ src="./InsertingTextExample-1.mp4">
29
+ </video>
30
+ ```python
31
+ from manim import *
32
+
33
+ class InsertingTextExample(Scene):
34
+ def construct(self):
35
+ text = Text("Inserting", color=PURPLE).scale(1.5).to_edge(LEFT)
36
+ cursor = Rectangle(
37
+ color = GREY_A,
38
+ fill_color = GREY_A,
39
+ fill_opacity = 1.0,
40
+ height = 1.1,
41
+ width = 0.5,
42
+ ).move_to(text[0]) # Position the cursor
43
+
44
+ self.play(TypeWithCursor(text, cursor))
45
+ self.play(Blink(cursor, blinks=2))
46
+ ```
47
+
48
+ <pre data-manim-binder data-manim-classname="InsertingTextExample">
49
+ class InsertingTextExample(Scene):
50
+ def construct(self):
51
+ text = Text("Inserting", color=PURPLE).scale(1.5).to_edge(LEFT)
52
+ cursor = Rectangle(
53
+ color = GREY_A,
54
+ fill_color = GREY_A,
55
+ fill_opacity = 1.0,
56
+ height = 1.1,
57
+ width = 0.5,
58
+ ).move_to(text[0]) # Position the cursor
59
+
60
+ self.play(TypeWithCursor(text, cursor))
61
+ self.play(Blink(cursor, blinks=2))
62
+
63
+ </pre>
64
+
65
+ References: [`Blink`](manim.animation.indication.Blink.md#manim.animation.indication.Blink)
66
+
67
+ </div>
68
+
69
+ ### Methods
70
+
71
+ | [`begin`](#manim.animation.creation.TypeWithCursor.begin) | Begin the animation. |
72
+ |---------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------|
73
+ | [`clean_up_from_scene`](#manim.animation.creation.TypeWithCursor.clean_up_from_scene) | Clean up the [`Scene`](manim.scene.scene.Scene.md#manim.scene.scene.Scene) after finishing the animation. |
74
+ | [`finish`](#manim.animation.creation.TypeWithCursor.finish) | Finish the animation. |
75
+ | `update_submobject_list` | |
76
+
77
+ ### Attributes
78
+
79
+ | `run_time` | |
80
+ |--------------|----|
81
+
82
+ #### \_original_\_init_\_(text, cursor, buff=0.1, keep_cursor_y=True, leave_cursor_on=True, time_per_char=0.1, reverse_rate_function=False, introducer=True, \*\*kwargs)
83
+
84
+ Initialize self. See help(type(self)) for accurate signature.
85
+
86
+ * **Parameters:**
87
+ * **text** ([*Text*](manim.mobject.text.text_mobject.Text.md#manim.mobject.text.text_mobject.Text))
88
+ * **cursor** ([*Mobject*](manim.mobject.mobject.Mobject.md#manim.mobject.mobject.Mobject))
89
+ * **buff** (*float*)
90
+ * **keep_cursor_y** (*bool*)
91
+ * **leave_cursor_on** (*bool*)
92
+ * **time_per_char** (*float*)
93
+ * **Return type:**
94
+ None
95
+
96
+ #### begin()
97
+
98
+ Begin the animation.
99
+
100
+ This method is called right as an animation is being played. As much
101
+ initialization as possible, especially any mobject copying, should live in this
102
+ method.
103
+
104
+ * **Return type:**
105
+ None
106
+
107
+ #### clean_up_from_scene(scene)
108
+
109
+ Clean up the [`Scene`](manim.scene.scene.Scene.md#manim.scene.scene.Scene) after finishing the animation.
110
+
111
+ This includes to [`remove()`](manim.scene.scene.Scene.md#manim.scene.scene.Scene.remove) the Animation’s
112
+ [`Mobject`](manim.mobject.mobject.Mobject.md#manim.mobject.mobject.Mobject) if the animation is a remover.
113
+
114
+ * **Parameters:**
115
+ **scene** ([*Scene*](manim.scene.scene.Scene.md#manim.scene.scene.Scene)) – The scene the animation should be cleaned up from.
116
+ * **Return type:**
117
+ None
118
+
119
+ #### finish()
120
+
121
+ Finish the animation.
122
+
123
+ This method gets called when the animation is over.
124
+
125
+ * **Return type:**
126
+ None
data/rag/manim_docs/manim_core/docs/reference/manim.animation.creation.Uncreate.md ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Uncreate
2
+
3
+ Qualified name: `manim.animation.creation.Uncreate`
4
+
5
+ ### *class* Uncreate(mobject=None, \*args, use_override=True, \*\*kwargs)
6
+
7
+ Bases: [`Create`](manim.animation.creation.Create.md#manim.animation.creation.Create)
8
+
9
+ Like [`Create`](manim.animation.creation.Create.md#manim.animation.creation.Create) but in reverse.
10
+
11
+ ### Examples
12
+
13
+ <div id="showuncreate" class="admonition admonition-manim-example">
14
+ <p class="admonition-title">Example: ShowUncreate <a class="headerlink" href="#showuncreate">¶</a></p><video
15
+ class="manim-video"
16
+ controls
17
+ loop
18
+ autoplay
19
+ src="./ShowUncreate-1.mp4">
20
+ </video>
21
+ ```python
22
+ from manim import *
23
+
24
+ class ShowUncreate(Scene):
25
+ def construct(self):
26
+ self.play(Uncreate(Square()))
27
+ ```
28
+
29
+ <pre data-manim-binder data-manim-classname="ShowUncreate">
30
+ class ShowUncreate(Scene):
31
+ def construct(self):
32
+ self.play(Uncreate(Square()))
33
+
34
+ </pre></div>
35
+
36
+ #### SEE ALSO
37
+ [`Create`](manim.animation.creation.Create.md#manim.animation.creation.Create)
38
+
39
+ ### Methods
40
+
41
+ ### Attributes
42
+
43
+ | `run_time` | |
44
+ |--------------|----|
45
+ * **Parameters:**
46
+ * **mobject** ([*VMobject*](manim.mobject.types.vectorized_mobject.VMobject.md#manim.mobject.types.vectorized_mobject.VMobject) *|* *OpenGLVMobject*)
47
+ * **reverse_rate_function** (*bool*)
48
+ * **remover** (*bool*)
49
+
50
+ #### \_original_\_init_\_(mobject, reverse_rate_function=True, remover=True, \*\*kwargs)
51
+
52
+ Initialize self. See help(type(self)) for accurate signature.
53
+
54
+ * **Parameters:**
55
+ * **mobject** ([*VMobject*](manim.mobject.types.vectorized_mobject.VMobject.md#manim.mobject.types.vectorized_mobject.VMobject) *|* *OpenGLVMobject*)
56
+ * **reverse_rate_function** (*bool*)
57
+ * **remover** (*bool*)
58
+ * **Return type:**
59
+ None
data/rag/manim_docs/manim_core/docs/reference/manim.animation.creation.UntypeWithCursor.md ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # UntypeWithCursor
2
+
3
+ Qualified name: `manim.animation.creation.UntypeWithCursor`
4
+
5
+ ### *class* UntypeWithCursor(mobject=None, \*args, use_override=True, \*\*kwargs)
6
+
7
+ Bases: [`TypeWithCursor`](manim.animation.creation.TypeWithCursor.md#manim.animation.creation.TypeWithCursor)
8
+
9
+ Similar to [`RemoveTextLetterByLetter`](manim.animation.creation.RemoveTextLetterByLetter.md#manim.animation.creation.RemoveTextLetterByLetter) , but with an additional cursor mobject at the end.
10
+
11
+ * **Parameters:**
12
+ * **time_per_char** (*float*) – Frequency of appearance of the letters.
13
+ * **cursor** ([*VMobject*](manim.mobject.types.vectorized_mobject.VMobject.md#manim.mobject.types.vectorized_mobject.VMobject) *|* *None*) – [`Mobject`](manim.mobject.mobject.Mobject.md#manim.mobject.mobject.Mobject) shown after the last added letter.
14
+ * **buff** – Controls how far away the cursor is to the right of the last added letter.
15
+ * **keep_cursor_y** – If `True`, the cursor’s y-coordinate is set to the center of the `Text` and remains the same throughout the animation. Otherwise, it is set to the center of the last added letter.
16
+ * **leave_cursor_on** – Whether to show the cursor after the animation.
17
+ * **tip::** ( *..*) – This is currently only possible for class:~.Text and not for class:~.MathTex.
18
+ * **text** ([*Text*](manim.mobject.text.text_mobject.Text.md#manim.mobject.text.text_mobject.Text))
19
+
20
+ ### Examples
21
+
22
+ <div id="deletingtextexample" class="admonition admonition-manim-example">
23
+ <p class="admonition-title">Example: DeletingTextExample <a class="headerlink" href="#deletingtextexample">¶</a></p><video
24
+ class="manim-video"
25
+ controls
26
+ loop
27
+ autoplay
28
+ src="./DeletingTextExample-1.mp4">
29
+ </video>
30
+ ```python
31
+ from manim import *
32
+
33
+ class DeletingTextExample(Scene):
34
+ def construct(self):
35
+ text = Text("Deleting", color=PURPLE).scale(1.5).to_edge(LEFT)
36
+ cursor = Rectangle(
37
+ color = GREY_A,
38
+ fill_color = GREY_A,
39
+ fill_opacity = 1.0,
40
+ height = 1.1,
41
+ width = 0.5,
42
+ ).move_to(text[0]) # Position the cursor
43
+
44
+ self.play(UntypeWithCursor(text, cursor))
45
+ self.play(Blink(cursor, blinks=2))
46
+ ```
47
+
48
+ <pre data-manim-binder data-manim-classname="DeletingTextExample">
49
+ class DeletingTextExample(Scene):
50
+ def construct(self):
51
+ text = Text("Deleting", color=PURPLE).scale(1.5).to_edge(LEFT)
52
+ cursor = Rectangle(
53
+ color = GREY_A,
54
+ fill_color = GREY_A,
55
+ fill_opacity = 1.0,
56
+ height = 1.1,
57
+ width = 0.5,
58
+ ).move_to(text[0]) # Position the cursor
59
+
60
+ self.play(UntypeWithCursor(text, cursor))
61
+ self.play(Blink(cursor, blinks=2))
62
+
63
+ </pre>
64
+
65
+ References: [`Blink`](manim.animation.indication.Blink.md#manim.animation.indication.Blink)
66
+
67
+ </div>
68
+
69
+ ### Methods
70
+
71
+ ### Attributes
72
+
73
+ | `run_time` | |
74
+ |--------------|----|
75
+
76
+ #### \_original_\_init_\_(text, cursor=None, time_per_char=0.1, reverse_rate_function=True, introducer=False, remover=True, \*\*kwargs)
77
+
78
+ Initialize self. See help(type(self)) for accurate signature.
79
+
80
+ * **Parameters:**
81
+ * **text** ([*Text*](manim.mobject.text.text_mobject.Text.md#manim.mobject.text.text_mobject.Text))
82
+ * **cursor** ([*VMobject*](manim.mobject.types.vectorized_mobject.VMobject.md#manim.mobject.types.vectorized_mobject.VMobject) *|* *None*)
83
+ * **time_per_char** (*float*)
84
+ * **Return type:**
85
+ None
data/rag/manim_docs/manim_core/docs/reference/manim.animation.creation.Unwrite.md ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Unwrite
2
+
3
+ Qualified name: `manim.animation.creation.Unwrite`
4
+
5
+ ### *class* Unwrite(mobject=None, \*args, use_override=True, \*\*kwargs)
6
+
7
+ Bases: [`Write`](manim.animation.creation.Write.md#manim.animation.creation.Write)
8
+
9
+ Simulate erasing by hand a [`Text`](manim.mobject.text.text_mobject.Text.md#manim.mobject.text.text_mobject.Text) or a [`VMobject`](manim.mobject.types.vectorized_mobject.VMobject.md#manim.mobject.types.vectorized_mobject.VMobject).
10
+
11
+ * **Parameters:**
12
+ * **reverse** (*bool*) – Set True to have the animation start erasing from the last submobject first.
13
+ * **vmobject** ([*VMobject*](manim.mobject.types.vectorized_mobject.VMobject.md#manim.mobject.types.vectorized_mobject.VMobject))
14
+ * **rate_func** (*Callable* *[* *[**float* *]* *,* *float* *]*)
15
+
16
+ ### Examples
17
+
18
+ <div id="unwritereversetrue" class="admonition admonition-manim-example">
19
+ <p class="admonition-title">Example: UnwriteReverseTrue <a class="headerlink" href="#unwritereversetrue">¶</a></p><video
20
+ class="manim-video"
21
+ controls
22
+ loop
23
+ autoplay
24
+ src="./UnwriteReverseTrue-1.mp4">
25
+ </video>
26
+ ```python
27
+ from manim import *
28
+
29
+ class UnwriteReverseTrue(Scene):
30
+ def construct(self):
31
+ text = Tex("Alice and Bob").scale(3)
32
+ self.add(text)
33
+ self.play(Unwrite(text))
34
+ ```
35
+
36
+ <pre data-manim-binder data-manim-classname="UnwriteReverseTrue">
37
+ class UnwriteReverseTrue(Scene):
38
+ def construct(self):
39
+ text = Tex("Alice and Bob").scale(3)
40
+ self.add(text)
41
+ self.play(Unwrite(text))
42
+
43
+ </pre></div><div id="unwritereversefalse" class="admonition admonition-manim-example">
44
+ <p class="admonition-title">Example: UnwriteReverseFalse <a class="headerlink" href="#unwritereversefalse">¶</a></p><video
45
+ class="manim-video"
46
+ controls
47
+ loop
48
+ autoplay
49
+ src="./UnwriteReverseFalse-1.mp4">
50
+ </video>
51
+ ```python
52
+ from manim import *
53
+
54
+ class UnwriteReverseFalse(Scene):
55
+ def construct(self):
56
+ text = Tex("Alice and Bob").scale(3)
57
+ self.add(text)
58
+ self.play(Unwrite(text, reverse=False))
59
+ ```
60
+
61
+ <pre data-manim-binder data-manim-classname="UnwriteReverseFalse">
62
+ class UnwriteReverseFalse(Scene):
63
+ def construct(self):
64
+ text = Tex("Alice and Bob").scale(3)
65
+ self.add(text)
66
+ self.play(Unwrite(text, reverse=False))
67
+
68
+ </pre></div>
69
+
70
+ ### Methods
71
+
72
+ ### Attributes
73
+
74
+ | `run_time` | |
75
+ |--------------|----|
76
+
77
+ #### \_original_\_init_\_(vmobject, rate_func=<function linear>, reverse=True, \*\*kwargs)
78
+
79
+ Initialize self. See help(type(self)) for accurate signature.
80
+
81
+ * **Parameters:**
82
+ * **vmobject** ([*VMobject*](manim.mobject.types.vectorized_mobject.VMobject.md#manim.mobject.types.vectorized_mobject.VMobject))
83
+ * **rate_func** (*Callable* *[* *[**float* *]* *,* *float* *]*)
84
+ * **reverse** (*bool*)
85
+ * **Return type:**
86
+ None
data/rag/manim_docs/manim_core/docs/reference/manim.animation.creation.Write.md ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Write
2
+
3
+ Qualified name: `manim.animation.creation.Write`
4
+
5
+ ### *class* Write(mobject=None, \*args, use_override=True, \*\*kwargs)
6
+
7
+ Bases: [`DrawBorderThenFill`](manim.animation.creation.DrawBorderThenFill.md#manim.animation.creation.DrawBorderThenFill)
8
+
9
+ Simulate hand-writing a [`Text`](manim.mobject.text.text_mobject.Text.md#manim.mobject.text.text_mobject.Text) or hand-drawing a [`VMobject`](manim.mobject.types.vectorized_mobject.VMobject.md#manim.mobject.types.vectorized_mobject.VMobject).
10
+
11
+ ### Examples
12
+
13
+ <div id="showwrite" class="admonition admonition-manim-example">
14
+ <p class="admonition-title">Example: ShowWrite <a class="headerlink" href="#showwrite">¶</a></p><video
15
+ class="manim-video"
16
+ controls
17
+ loop
18
+ autoplay
19
+ src="./ShowWrite-1.mp4">
20
+ </video>
21
+ ```python
22
+ from manim import *
23
+
24
+ class ShowWrite(Scene):
25
+ def construct(self):
26
+ self.play(Write(Text("Hello", font_size=144)))
27
+ ```
28
+
29
+ <pre data-manim-binder data-manim-classname="ShowWrite">
30
+ class ShowWrite(Scene):
31
+ def construct(self):
32
+ self.play(Write(Text("Hello", font_size=144)))
33
+
34
+ </pre></div><div id="showwritereversed" class="admonition admonition-manim-example">
35
+ <p class="admonition-title">Example: ShowWriteReversed <a class="headerlink" href="#showwritereversed">¶</a></p><video
36
+ class="manim-video"
37
+ controls
38
+ loop
39
+ autoplay
40
+ src="./ShowWriteReversed-1.mp4">
41
+ </video>
42
+ ```python
43
+ from manim import *
44
+
45
+ class ShowWriteReversed(Scene):
46
+ def construct(self):
47
+ self.play(Write(Text("Hello", font_size=144), reverse=True, remover=False))
48
+ ```
49
+
50
+ <pre data-manim-binder data-manim-classname="ShowWriteReversed">
51
+ class ShowWriteReversed(Scene):
52
+ def construct(self):
53
+ self.play(Write(Text("Hello", font_size=144), reverse=True, remover=False))
54
+
55
+ </pre></div>
56
+
57
+ ### Tests
58
+
59
+ Check that creating empty [`Write`](#manim.animation.creation.Write) animations works:
60
+
61
+ ```default
62
+ >>> from manim import Write, Text
63
+ >>> Write(Text(''))
64
+ Write(Text(''))
65
+ ```
66
+
67
+ ### Methods
68
+
69
+ | [`begin`](#manim.animation.creation.Write.begin) | Begin the animation. |
70
+ |----------------------------------------------------|------------------------|
71
+ | [`finish`](#manim.animation.creation.Write.finish) | Finish the animation. |
72
+ | `reverse_submobjects` | |
73
+
74
+ ### Attributes
75
+
76
+ | `run_time` | |
77
+ |--------------|----|
78
+ * **Parameters:**
79
+ * **vmobject** ([*VMobject*](manim.mobject.types.vectorized_mobject.VMobject.md#manim.mobject.types.vectorized_mobject.VMobject) *|* *OpenGLVMobject*)
80
+ * **rate_func** (*Callable* *[* *[**float* *]* *,* *float* *]*)
81
+ * **reverse** (*bool*)
82
+
83
+ #### \_original_\_init_\_(vmobject, rate_func=<function linear>, reverse=False, \*\*kwargs)
84
+
85
+ Initialize self. See help(type(self)) for accurate signature.
86
+
87
+ * **Parameters:**
88
+ * **vmobject** ([*VMobject*](manim.mobject.types.vectorized_mobject.VMobject.md#manim.mobject.types.vectorized_mobject.VMobject) *|* *OpenGLVMobject*)
89
+ * **rate_func** (*Callable* *[* *[**float* *]* *,* *float* *]*)
90
+ * **reverse** (*bool*)
91
+ * **Return type:**
92
+ None
93
+
94
+ #### begin()
95
+
96
+ Begin the animation.
97
+
98
+ This method is called right as an animation is being played. As much
99
+ initialization as possible, especially any mobject copying, should live in this
100
+ method.
101
+
102
+ * **Return type:**
103
+ None
104
+
105
+ #### finish()
106
+
107
+ Finish the animation.
108
+
109
+ This method gets called when the animation is over.
110
+
111
+ * **Return type:**
112
+ None
data/rag/manim_docs/manim_core/docs/reference/manim.animation.creation.md ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # creation
2
+
3
+ Animate the display or removal of a mobject from a scene.
4
+
5
+ <video
6
+ class="manim-video"
7
+ controls
8
+ loop
9
+ autoplay
10
+ src="./CreationModule-1.mp4">
11
+ </video>
12
+
13
+ ### Classes
14
+
15
+ | [`AddTextLetterByLetter`](manim.animation.creation.AddTextLetterByLetter.md#manim.animation.creation.AddTextLetterByLetter) | Show a [`Text`](manim.mobject.text.text_mobject.Text.md#manim.mobject.text.text_mobject.Text) letter by letter on the scene. |
16
+ |--------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
17
+ | [`AddTextWordByWord`](manim.animation.creation.AddTextWordByWord.md#manim.animation.creation.AddTextWordByWord) | Show a [`Text`](manim.mobject.text.text_mobject.Text.md#manim.mobject.text.text_mobject.Text) word by word on the scene. |
18
+ | [`Create`](manim.animation.creation.Create.md#manim.animation.creation.Create) | Incrementally show a VMobject. |
19
+ | [`DrawBorderThenFill`](manim.animation.creation.DrawBorderThenFill.md#manim.animation.creation.DrawBorderThenFill) | Draw the border first and then show the fill. |
20
+ | [`RemoveTextLetterByLetter`](manim.animation.creation.RemoveTextLetterByLetter.md#manim.animation.creation.RemoveTextLetterByLetter) | Remove a [`Text`](manim.mobject.text.text_mobject.Text.md#manim.mobject.text.text_mobject.Text) letter by letter from the scene. |
21
+ | [`ShowIncreasingSubsets`](manim.animation.creation.ShowIncreasingSubsets.md#manim.animation.creation.ShowIncreasingSubsets) | Show one submobject at a time, leaving all previous ones displayed on screen. |
22
+ | [`ShowPartial`](manim.animation.creation.ShowPartial.md#manim.animation.creation.ShowPartial) | Abstract class for Animations that show the VMobject partially. |
23
+ | [`ShowSubmobjectsOneByOne`](manim.animation.creation.ShowSubmobjectsOneByOne.md#manim.animation.creation.ShowSubmobjectsOneByOne) | Show one submobject at a time, removing all previously displayed ones from screen. |
24
+ | [`SpiralIn`](manim.animation.creation.SpiralIn.md#manim.animation.creation.SpiralIn) | Create the Mobject with sub-Mobjects flying in on spiral trajectories. |
25
+ | [`TypeWithCursor`](manim.animation.creation.TypeWithCursor.md#manim.animation.creation.TypeWithCursor) | Similar to [`AddTextLetterByLetter`](manim.animation.creation.AddTextLetterByLetter.md#manim.animation.creation.AddTextLetterByLetter) , but with an additional cursor mobject at the end. |
26
+ | [`Uncreate`](manim.animation.creation.Uncreate.md#manim.animation.creation.Uncreate) | Like [`Create`](manim.animation.creation.Create.md#manim.animation.creation.Create) but in reverse. |
27
+ | [`UntypeWithCursor`](manim.animation.creation.UntypeWithCursor.md#manim.animation.creation.UntypeWithCursor) | Similar to [`RemoveTextLetterByLetter`](manim.animation.creation.RemoveTextLetterByLetter.md#manim.animation.creation.RemoveTextLetterByLetter) , but with an additional cursor mobject at the end. |
28
+ | [`Unwrite`](manim.animation.creation.Unwrite.md#manim.animation.creation.Unwrite) | Simulate erasing by hand a [`Text`](manim.mobject.text.text_mobject.Text.md#manim.mobject.text.text_mobject.Text) or a [`VMobject`](manim.mobject.types.vectorized_mobject.VMobject.md#manim.mobject.types.vectorized_mobject.VMobject). |
29
+ | [`Write`](manim.animation.creation.Write.md#manim.animation.creation.Write) | Simulate hand-writing a [`Text`](manim.mobject.text.text_mobject.Text.md#manim.mobject.text.text_mobject.Text) or hand-drawing a [`VMobject`](manim.mobject.types.vectorized_mobject.VMobject.md#manim.mobject.types.vectorized_mobject.VMobject). |
data/rag/manim_docs/manim_core/docs/reference/manim.animation.fading.FadeIn.md ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # FadeIn
2
+
3
+ Qualified name: `manim.animation.fading.FadeIn`
4
+
5
+ ### *class* FadeIn(mobject=None, \*args, use_override=True, \*\*kwargs)
6
+
7
+ Bases: `_Fade`
8
+
9
+ Fade in [`Mobject`](manim.mobject.mobject.Mobject.md#manim.mobject.mobject.Mobject) s.
10
+
11
+ * **Parameters:**
12
+ * **mobjects** ([*Mobject*](manim.mobject.mobject.Mobject.md#manim.mobject.mobject.Mobject)) – The mobjects to be faded in.
13
+ * **shift** – The vector by which the mobject shifts while being faded in.
14
+ * **target_position** – The position from which the mobject starts while being faded in. In case
15
+ another mobject is given as target position, its center is used.
16
+ * **scale** – The factor by which the mobject is scaled initially before being rescaling to
17
+ its original size while being faded in.
18
+
19
+ ### Examples
20
+
21
+ <div id="fadeinexample" class="admonition admonition-manim-example">
22
+ <p class="admonition-title">Example: FadeInExample <a class="headerlink" href="#fadeinexample">¶</a></p><video
23
+ class="manim-video"
24
+ controls
25
+ loop
26
+ autoplay
27
+ src="./FadeInExample-1.mp4">
28
+ </video>
29
+ ```python
30
+ from manim import *
31
+
32
+ class FadeInExample(Scene):
33
+ def construct(self):
34
+ dot = Dot(UP * 2 + LEFT)
35
+ self.add(dot)
36
+ tex = Tex(
37
+ "FadeIn with ", "shift ", r" or target\_position", " and scale"
38
+ ).scale(1)
39
+ animations = [
40
+ FadeIn(tex[0]),
41
+ FadeIn(tex[1], shift=DOWN),
42
+ FadeIn(tex[2], target_position=dot),
43
+ FadeIn(tex[3], scale=1.5),
44
+ ]
45
+ self.play(AnimationGroup(*animations, lag_ratio=0.5))
46
+ ```
47
+
48
+ <pre data-manim-binder data-manim-classname="FadeInExample">
49
+ class FadeInExample(Scene):
50
+ def construct(self):
51
+ dot = Dot(UP \* 2 + LEFT)
52
+ self.add(dot)
53
+ tex = Tex(
54
+ "FadeIn with ", "shift ", r" or target\\_position", " and scale"
55
+ ).scale(1)
56
+ animations = [
57
+ FadeIn(tex[0]),
58
+ FadeIn(tex[1], shift=DOWN),
59
+ FadeIn(tex[2], target_position=dot),
60
+ FadeIn(tex[3], scale=1.5),
61
+ ]
62
+ self.play(AnimationGroup(\*animations, lag_ratio=0.5))
63
+
64
+ </pre></div>
65
+
66
+ ### Methods
67
+
68
+ | `create_starting_mobject` | |
69
+ |-----------------------------|----|
70
+ | `create_target` | |
71
+
72
+ ### Attributes
73
+
74
+ | `path_arc` | |
75
+ |--------------|----|
76
+ | `path_func` | |
77
+ | `run_time` | |
78
+
79
+ #### \_original_\_init_\_(\*mobjects, \*\*kwargs)
80
+
81
+ Initialize self. See help(type(self)) for accurate signature.
82
+
83
+ * **Parameters:**
84
+ **mobjects** ([*Mobject*](manim.mobject.mobject.Mobject.md#manim.mobject.mobject.Mobject))
85
+ * **Return type:**
86
+ None
data/rag/manim_docs/manim_core/docs/reference/manim.animation.fading.FadeOut.md ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # FadeOut
2
+
3
+ Qualified name: `manim.animation.fading.FadeOut`
4
+
5
+ ### *class* FadeOut(mobject=None, \*args, use_override=True, \*\*kwargs)
6
+
7
+ Bases: `_Fade`
8
+
9
+ Fade out [`Mobject`](manim.mobject.mobject.Mobject.md#manim.mobject.mobject.Mobject) s.
10
+
11
+ * **Parameters:**
12
+ * **mobjects** ([*Mobject*](manim.mobject.mobject.Mobject.md#manim.mobject.mobject.Mobject)) – The mobjects to be faded out.
13
+ * **shift** – The vector by which the mobject shifts while being faded out.
14
+ * **target_position** – The position to which the mobject moves while being faded out. In case another
15
+ mobject is given as target position, its center is used.
16
+ * **scale** – The factor by which the mobject is scaled while being faded out.
17
+
18
+ ### Examples
19
+
20
+ <div id="fadeinexample" class="admonition admonition-manim-example">
21
+ <p class="admonition-title">Example: FadeInExample <a class="headerlink" href="#fadeinexample">¶</a></p><video
22
+ class="manim-video"
23
+ controls
24
+ loop
25
+ autoplay
26
+ src="./FadeInExample-2.mp4">
27
+ </video>
28
+ ```python
29
+ from manim import *
30
+
31
+ class FadeInExample(Scene):
32
+ def construct(self):
33
+ dot = Dot(UP * 2 + LEFT)
34
+ self.add(dot)
35
+ tex = Tex(
36
+ "FadeOut with ", "shift ", r" or target\_position", " and scale"
37
+ ).scale(1)
38
+ animations = [
39
+ FadeOut(tex[0]),
40
+ FadeOut(tex[1], shift=DOWN),
41
+ FadeOut(tex[2], target_position=dot),
42
+ FadeOut(tex[3], scale=0.5),
43
+ ]
44
+ self.play(AnimationGroup(*animations, lag_ratio=0.5))
45
+ ```
46
+
47
+ <pre data-manim-binder data-manim-classname="FadeInExample">
48
+ class FadeInExample(Scene):
49
+ def construct(self):
50
+ dot = Dot(UP \* 2 + LEFT)
51
+ self.add(dot)
52
+ tex = Tex(
53
+ "FadeOut with ", "shift ", r" or target\\_position", " and scale"
54
+ ).scale(1)
55
+ animations = [
56
+ FadeOut(tex[0]),
57
+ FadeOut(tex[1], shift=DOWN),
58
+ FadeOut(tex[2], target_position=dot),
59
+ FadeOut(tex[3], scale=0.5),
60
+ ]
61
+ self.play(AnimationGroup(\*animations, lag_ratio=0.5))
62
+
63
+ </pre></div>
64
+
65
+ ### Methods
66
+
67
+ | [`clean_up_from_scene`](#manim.animation.fading.FadeOut.clean_up_from_scene) | Clean up the [`Scene`](manim.scene.scene.Scene.md#manim.scene.scene.Scene) after finishing the animation. |
68
+ |--------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------|
69
+ | `create_target` | |
70
+
71
+ ### Attributes
72
+
73
+ | `path_arc` | |
74
+ |--------------|----|
75
+ | `path_func` | |
76
+ | `run_time` | |
77
+
78
+ #### \_original_\_init_\_(\*mobjects, \*\*kwargs)
79
+
80
+ Initialize self. See help(type(self)) for accurate signature.
81
+
82
+ * **Parameters:**
83
+ **mobjects** ([*Mobject*](manim.mobject.mobject.Mobject.md#manim.mobject.mobject.Mobject))
84
+ * **Return type:**
85
+ None
86
+
87
+ #### clean_up_from_scene(scene=None)
88
+
89
+ Clean up the [`Scene`](manim.scene.scene.Scene.md#manim.scene.scene.Scene) after finishing the animation.
90
+
91
+ This includes to [`remove()`](manim.scene.scene.Scene.md#manim.scene.scene.Scene.remove) the Animation’s
92
+ [`Mobject`](manim.mobject.mobject.Mobject.md#manim.mobject.mobject.Mobject) if the animation is a remover.
93
+
94
+ * **Parameters:**
95
+ **scene** ([*Scene*](manim.scene.scene.Scene.md#manim.scene.scene.Scene)) – The scene the animation should be cleaned up from.
96
+ * **Return type:**
97
+ None
data/rag/manim_docs/manim_core/docs/reference/manim.animation.fading.md ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # fading
2
+
3
+ Fading in and out of view.
4
+
5
+ <div id="fading" class="admonition admonition-manim-example">
6
+ <p class="admonition-title">Example: Fading <a class="headerlink" href="#fading">¶</a></p><video
7
+ class="manim-video"
8
+ controls
9
+ loop
10
+ autoplay
11
+ src="./Fading-1.mp4">
12
+ </video>
13
+ ```python
14
+ from manim import *
15
+
16
+ class Fading(Scene):
17
+ def construct(self):
18
+ tex_in = Tex("Fade", "In").scale(3)
19
+ tex_out = Tex("Fade", "Out").scale(3)
20
+ self.play(FadeIn(tex_in, shift=DOWN, scale=0.66))
21
+ self.play(ReplacementTransform(tex_in, tex_out))
22
+ self.play(FadeOut(tex_out, shift=DOWN * 2, scale=1.5))
23
+ ```
24
+
25
+ <pre data-manim-binder data-manim-classname="Fading">
26
+ class Fading(Scene):
27
+ def construct(self):
28
+ tex_in = Tex("Fade", "In").scale(3)
29
+ tex_out = Tex("Fade", "Out").scale(3)
30
+ self.play(FadeIn(tex_in, shift=DOWN, scale=0.66))
31
+ self.play(ReplacementTransform(tex_in, tex_out))
32
+ self.play(FadeOut(tex_out, shift=DOWN \* 2, scale=1.5))
33
+
34
+ </pre></div>
35
+
36
+ ### Classes
37
+
38
+ | [`FadeIn`](manim.animation.fading.FadeIn.md#manim.animation.fading.FadeIn) | Fade in [`Mobject`](manim.mobject.mobject.Mobject.md#manim.mobject.mobject.Mobject) s. |
39
+ |-------------------------------------------------------------------------------|------------------------------------------------------------------------------------------|
40
+ | [`FadeOut`](manim.animation.fading.FadeOut.md#manim.animation.fading.FadeOut) | Fade out [`Mobject`](manim.mobject.mobject.Mobject.md#manim.mobject.mobject.Mobject) s. |
data/rag/manim_docs/manim_core/docs/reference/manim.animation.growing.GrowArrow.md ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # GrowArrow
2
+
3
+ Qualified name: `manim.animation.growing.GrowArrow`
4
+
5
+ ### *class* GrowArrow(mobject=None, \*args, use_override=True, \*\*kwargs)
6
+
7
+ Bases: [`GrowFromPoint`](manim.animation.growing.GrowFromPoint.md#manim.animation.growing.GrowFromPoint)
8
+
9
+ Introduce an [`Arrow`](manim.mobject.geometry.line.Arrow.md#manim.mobject.geometry.line.Arrow) by growing it from its start toward its tip.
10
+
11
+ * **Parameters:**
12
+ * **arrow** ([*Arrow*](manim.mobject.geometry.line.Arrow.md#manim.mobject.geometry.line.Arrow)) – The arrow to be introduced.
13
+ * **point_color** (*str*) – Initial color of the arrow before growing to its full size. Leave empty to match arrow’s color.
14
+
15
+ ### Examples
16
+
17
+ <div id="growarrowexample" class="admonition admonition-manim-example">
18
+ <p class="admonition-title">Example: GrowArrowExample <a class="headerlink" href="#growarrowexample">¶</a></p><video
19
+ class="manim-video"
20
+ controls
21
+ loop
22
+ autoplay
23
+ src="./GrowArrowExample-1.mp4">
24
+ </video>
25
+ ```python
26
+ from manim import *
27
+
28
+ class GrowArrowExample(Scene):
29
+ def construct(self):
30
+ arrows = [Arrow(2 * LEFT, 2 * RIGHT), Arrow(2 * DR, 2 * UL)]
31
+ VGroup(*arrows).set_x(0).arrange(buff=2)
32
+ self.play(GrowArrow(arrows[0]))
33
+ self.play(GrowArrow(arrows[1], point_color=RED))
34
+ ```
35
+
36
+ <pre data-manim-binder data-manim-classname="GrowArrowExample">
37
+ class GrowArrowExample(Scene):
38
+ def construct(self):
39
+ arrows = [Arrow(2 \* LEFT, 2 \* RIGHT), Arrow(2 \* DR, 2 \* UL)]
40
+ VGroup(\*arrows).set_x(0).arrange(buff=2)
41
+ self.play(GrowArrow(arrows[0]))
42
+ self.play(GrowArrow(arrows[1], point_color=RED))
43
+
44
+ </pre></div>
45
+
46
+ ### Methods
47
+
48
+ | `create_starting_mobject` | |
49
+ |-----------------------------|----|
50
+
51
+ ### Attributes
52
+
53
+ | `path_arc` | |
54
+ |--------------|----|
55
+ | `path_func` | |
56
+ | `run_time` | |
57
+
58
+ #### \_original_\_init_\_(arrow, point_color=None, \*\*kwargs)
59
+
60
+ Initialize self. See help(type(self)) for accurate signature.
61
+
62
+ * **Parameters:**
63
+ * **arrow** ([*Arrow*](manim.mobject.geometry.line.Arrow.md#manim.mobject.geometry.line.Arrow))
64
+ * **point_color** (*str*)
65
+ * **Return type:**
66
+ None
data/rag/manim_docs/manim_core/docs/reference/manim.animation.growing.GrowFromCenter.md ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # GrowFromCenter
2
+
3
+ Qualified name: `manim.animation.growing.GrowFromCenter`
4
+
5
+ ### *class* GrowFromCenter(mobject=None, \*args, use_override=True, \*\*kwargs)
6
+
7
+ Bases: [`GrowFromPoint`](manim.animation.growing.GrowFromPoint.md#manim.animation.growing.GrowFromPoint)
8
+
9
+ Introduce an [`Mobject`](manim.mobject.mobject.Mobject.md#manim.mobject.mobject.Mobject) by growing it from its center.
10
+
11
+ * **Parameters:**
12
+ * **mobject** ([*Mobject*](manim.mobject.mobject.Mobject.md#manim.mobject.mobject.Mobject)) – The mobjects to be introduced.
13
+ * **point_color** (*str*) – Initial color of the mobject before growing to its full size. Leave empty to match mobject’s color.
14
+
15
+ ### Examples
16
+
17
+ <div id="growfromcenterexample" class="admonition admonition-manim-example">
18
+ <p class="admonition-title">Example: GrowFromCenterExample <a class="headerlink" href="#growfromcenterexample">¶</a></p><video
19
+ class="manim-video"
20
+ controls
21
+ loop
22
+ autoplay
23
+ src="./GrowFromCenterExample-1.mp4">
24
+ </video>
25
+ ```python
26
+ from manim import *
27
+
28
+ class GrowFromCenterExample(Scene):
29
+ def construct(self):
30
+ squares = [Square() for _ in range(2)]
31
+ VGroup(*squares).set_x(0).arrange(buff=2)
32
+ self.play(GrowFromCenter(squares[0]))
33
+ self.play(GrowFromCenter(squares[1], point_color=RED))
34
+ ```
35
+
36
+ <pre data-manim-binder data-manim-classname="GrowFromCenterExample">
37
+ class GrowFromCenterExample(Scene):
38
+ def construct(self):
39
+ squares = [Square() for \_ in range(2)]
40
+ VGroup(\*squares).set_x(0).arrange(buff=2)
41
+ self.play(GrowFromCenter(squares[0]))
42
+ self.play(GrowFromCenter(squares[1], point_color=RED))
43
+
44
+ </pre></div>
45
+
46
+ ### Methods
47
+
48
+ ### Attributes
49
+
50
+ | `path_arc` | |
51
+ |--------------|----|
52
+ | `path_func` | |
53
+ | `run_time` | |
54
+
55
+ #### \_original_\_init_\_(mobject, point_color=None, \*\*kwargs)
56
+
57
+ Initialize self. See help(type(self)) for accurate signature.
58
+
59
+ * **Parameters:**
60
+ * **mobject** ([*Mobject*](manim.mobject.mobject.Mobject.md#manim.mobject.mobject.Mobject))
61
+ * **point_color** (*str*)
62
+ * **Return type:**
63
+ None
data/rag/manim_docs/manim_core/docs/reference/manim.animation.growing.GrowFromEdge.md ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # GrowFromEdge
2
+
3
+ Qualified name: `manim.animation.growing.GrowFromEdge`
4
+
5
+ ### *class* GrowFromEdge(mobject=None, \*args, use_override=True, \*\*kwargs)
6
+
7
+ Bases: [`GrowFromPoint`](manim.animation.growing.GrowFromPoint.md#manim.animation.growing.GrowFromPoint)
8
+
9
+ Introduce an [`Mobject`](manim.mobject.mobject.Mobject.md#manim.mobject.mobject.Mobject) by growing it from one of its bounding box edges.
10
+
11
+ * **Parameters:**
12
+ * **mobject** ([*Mobject*](manim.mobject.mobject.Mobject.md#manim.mobject.mobject.Mobject)) – The mobjects to be introduced.
13
+ * **edge** (*np.ndarray*) – The direction to seek bounding box edge of mobject.
14
+ * **point_color** (*str*) – Initial color of the mobject before growing to its full size. Leave empty to match mobject’s color.
15
+
16
+ ### Examples
17
+
18
+ <div id="growfromedgeexample" class="admonition admonition-manim-example">
19
+ <p class="admonition-title">Example: GrowFromEdgeExample <a class="headerlink" href="#growfromedgeexample">¶</a></p><video
20
+ class="manim-video"
21
+ controls
22
+ loop
23
+ autoplay
24
+ src="./GrowFromEdgeExample-1.mp4">
25
+ </video>
26
+ ```python
27
+ from manim import *
28
+
29
+ class GrowFromEdgeExample(Scene):
30
+ def construct(self):
31
+ squares = [Square() for _ in range(4)]
32
+ VGroup(*squares).set_x(0).arrange(buff=1)
33
+ self.play(GrowFromEdge(squares[0], DOWN))
34
+ self.play(GrowFromEdge(squares[1], RIGHT))
35
+ self.play(GrowFromEdge(squares[2], UR))
36
+ self.play(GrowFromEdge(squares[3], UP, point_color=RED))
37
+ ```
38
+
39
+ <pre data-manim-binder data-manim-classname="GrowFromEdgeExample">
40
+ class GrowFromEdgeExample(Scene):
41
+ def construct(self):
42
+ squares = [Square() for \_ in range(4)]
43
+ VGroup(\*squares).set_x(0).arrange(buff=1)
44
+ self.play(GrowFromEdge(squares[0], DOWN))
45
+ self.play(GrowFromEdge(squares[1], RIGHT))
46
+ self.play(GrowFromEdge(squares[2], UR))
47
+ self.play(GrowFromEdge(squares[3], UP, point_color=RED))
48
+
49
+ </pre></div>
50
+
51
+ ### Methods
52
+
53
+ ### Attributes
54
+
55
+ | `path_arc` | |
56
+ |--------------|----|
57
+ | `path_func` | |
58
+ | `run_time` | |
59
+
60
+ #### \_original_\_init_\_(mobject, edge, point_color=None, \*\*kwargs)
61
+
62
+ Initialize self. See help(type(self)) for accurate signature.
63
+
64
+ * **Parameters:**
65
+ * **mobject** ([*Mobject*](manim.mobject.mobject.Mobject.md#manim.mobject.mobject.Mobject))
66
+ * **edge** (*np.ndarray*)
67
+ * **point_color** (*str*)
68
+ * **Return type:**
69
+ None
data/rag/manim_docs/manim_core/docs/reference/manim.animation.growing.GrowFromPoint.md ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # GrowFromPoint
2
+
3
+ Qualified name: `manim.animation.growing.GrowFromPoint`
4
+
5
+ ### *class* GrowFromPoint(mobject=None, \*args, use_override=True, \*\*kwargs)
6
+
7
+ Bases: [`Transform`](manim.animation.transform.Transform.md#manim.animation.transform.Transform)
8
+
9
+ Introduce an [`Mobject`](manim.mobject.mobject.Mobject.md#manim.mobject.mobject.Mobject) by growing it from a point.
10
+
11
+ * **Parameters:**
12
+ * **mobject** ([*Mobject*](manim.mobject.mobject.Mobject.md#manim.mobject.mobject.Mobject)) – The mobjects to be introduced.
13
+ * **point** (*np.ndarray*) – The point from which the mobject grows.
14
+ * **point_color** (*str*) – Initial color of the mobject before growing to its full size. Leave empty to match mobject’s color.
15
+
16
+ ### Examples
17
+
18
+ <div id="growfrompointexample" class="admonition admonition-manim-example">
19
+ <p class="admonition-title">Example: GrowFromPointExample <a class="headerlink" href="#growfrompointexample">¶</a></p><video
20
+ class="manim-video"
21
+ controls
22
+ loop
23
+ autoplay
24
+ src="./GrowFromPointExample-1.mp4">
25
+ </video>
26
+ ```python
27
+ from manim import *
28
+
29
+ class GrowFromPointExample(Scene):
30
+ def construct(self):
31
+ dot = Dot(3 * UR, color=GREEN)
32
+ squares = [Square() for _ in range(4)]
33
+ VGroup(*squares).set_x(0).arrange(buff=1)
34
+ self.add(dot)
35
+ self.play(GrowFromPoint(squares[0], ORIGIN))
36
+ self.play(GrowFromPoint(squares[1], [-2, 2, 0]))
37
+ self.play(GrowFromPoint(squares[2], [3, -2, 0], RED))
38
+ self.play(GrowFromPoint(squares[3], dot, dot.get_color()))
39
+ ```
40
+
41
+ <pre data-manim-binder data-manim-classname="GrowFromPointExample">
42
+ class GrowFromPointExample(Scene):
43
+ def construct(self):
44
+ dot = Dot(3 \* UR, color=GREEN)
45
+ squares = [Square() for \_ in range(4)]
46
+ VGroup(\*squares).set_x(0).arrange(buff=1)
47
+ self.add(dot)
48
+ self.play(GrowFromPoint(squares[0], ORIGIN))
49
+ self.play(GrowFromPoint(squares[1], [-2, 2, 0]))
50
+ self.play(GrowFromPoint(squares[2], [3, -2, 0], RED))
51
+ self.play(GrowFromPoint(squares[3], dot, dot.get_color()))
52
+
53
+ </pre></div>
54
+
55
+ ### Methods
56
+
57
+ | `create_starting_mobject` | |
58
+ |-----------------------------|----|
59
+ | `create_target` | |
60
+
61
+ ### Attributes
62
+
63
+ | `path_arc` | |
64
+ |--------------|----|
65
+ | `path_func` | |
66
+ | `run_time` | |
67
+
68
+ #### \_original_\_init_\_(mobject, point, point_color=None, \*\*kwargs)
69
+
70
+ Initialize self. See help(type(self)) for accurate signature.
71
+
72
+ * **Parameters:**
73
+ * **mobject** ([*Mobject*](manim.mobject.mobject.Mobject.md#manim.mobject.mobject.Mobject))
74
+ * **point** (*np.ndarray*)
75
+ * **point_color** (*str*)
76
+ * **Return type:**
77
+ None