A community-maintained Python framework for creating mathematical animations.
Quick reference to modules (#1362)
kolibril13f95f183c68e5
diff --git a/docs/source/index.rst b/docs/source/index.rstindex b40c7975f..5ab5eff8f 100644--- a/docs/source/index.rst+++ b/docs/source/index.rst@@ -20,6 +20,27 @@ information here will make it easier for newcomers to get started usingAll content of the docs is licensed under the MIT license. Especially for the examplesyou encounter: Feel free to use this code in your own projects!+.. note::++ As a quick reference, here are some often used modules, classes and methods:++ Modules:+ :mod:`~.moving_camera_scene`,+ :mod:`~.tex_mobject`,+ :mod:`~.geometry`,++ Classes:+ :class:`~.Mobject` ,+ :class:`~.VMobject`,+ :class:`~.ValueTracker`,+ :class:`~.MathTex`,+ :class:`~.Angle`,+ :class:`~.Tex`,+ :class:`~.Text`,++ Methods:+ :meth:`~.Mobject.add_updater`,+.. toctree:::maxdepth: 2@@ -34,6 +55,7 @@ information here will make it easier for newcomers to get started usingconduct+Navigation==================diff --git a/manim/mobject/geometry.py b/manim/mobject/geometry.pyindex de2838965..ff3e9fc68 100644--- a/manim/mobject/geometry.py+++ b/manim/mobject/geometry.py@@ -60,6 +60,7 @@ __all__ = [import mathimport warnings+from typing import Sequenceimport numpy as np@@ -812,7 +813,27 @@ class Line(TipableVMobject):return mob.get_boundary_point(direction)return np.array(mob_or_point)- def put_start_and_end_on(self, start, end):+ def put_start_and_end_on(self, start: Sequence[float], end: Sequence[float]):+ """Sets starts and end coordinates of a line.+ Examples+ --------+ .. manim:: LineExample++ class LineExample(Scene):+ def construct(self):+ d = VGroup()+ for i in range(0,10):+ d.add(Dot())+ d.arrange_in_grid(buff=1)+ self.add(d)+ l= Line(d[0], d[1])+ self.add(l)+ self.wait()+ l.put_start_and_end_on(d[1].get_center(), d[2].get_center())+ self.wait()+ l.put_start_and_end_on(d[4].get_center(), d[7].get_center())+ self.wait()+ """curr_start, curr_end = self.get_start_and_end()if np.all(curr_start == curr_end):# TODO, any problems with resettingdiff --git a/manim/mobject/value_tracker.py b/manim/mobject/value_tracker.pyindex 41eb41f8c..927918f52 100644--- a/manim/mobject/value_tracker.py+++ b/manim/mobject/value_tracker.py@@ -30,23 +30,39 @@ class ValueTracker(Mobject):pointer = Vector(DOWN)label = MathTex("x").add_updater(lambda m: m.next_to(pointer, UP))- pointer_value = ValueTracker(0)+ pointer_tracker = ValueTracker(0)pointer.add_updater(lambda m: m.next_to(- number_line.n2p(pointer_value.get_value()),+ number_line.n2p(pointer_tracker.get_value()),UP))self.add(number_line, pointer,label)- pointer_value += 1.5+ pointer_tracker += 1.5self.wait(1)- pointer_value -= 4+ pointer_tracker -= 4self.wait(0.5)- self.play(pointer_value.animate.set_value(5)),+ self.play(pointer_tracker.animate.set_value(5)),self.wait(0.5)- self.play(pointer_value.animate.set_value(3))- self.play(pointer_value.animate.increment_value(-2))+ self.play(pointer_tracker.animate.set_value(3))+ self.play(pointer_tracker.animate.increment_value(-2))self.wait(0.5)++ .. note::++ You can also link ValueTrackers to updaters. In this case, you have to make sure that the ValueTracker is added to the scene by ``add``++ .. manim:: ValueTrackerExample++ class ValueTrackerExample(Scene):+ def construct(self):+ pointer_tracker = ValueTracker(0)+ label = Dot(radius=3).add_updater(lambda x : x.set_x(pointer_tracker.get_value()))+ self.add(label)+ self.add(pointer_tracker)+ pointer_tracker.add_updater(lambda mobject, dt: mobject.increment_value(dt))+ self.wait(2)+"""def __init__(self, value=0, **kwargs):