Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Clarify the docs for MObject.animate, MObject.set and Variable. (#2407)

BorisTheBrave6d15ca5e745e
diff --git a/manim/mobject/mobject.py b/manim/mobject/mobject.py
index 7d25a5c38..97c70eb0f 100644
--- a/manim/mobject/mobject.py
+++ b/manim/mobject/mobject.py
@@ -225,7 +225,19 @@ class Mobject:
@property
def animate(self):
- """Used to animate the application of a method.
+ """Used to animate the application of any method of :code:`self`.
+
+ Any method called on :code:`animate` is converted to an animation of applying
+ that method on the mobject itself.
+
+ For example, :code:`square.set_fill(WHITE)` sets the fill color of a square,
+ while :code:`sqaure.animate.set_fill(WHITE)` animates this action.
+
+ Multiple methods can be put in a single animation once via chaining:
+
+ ::
+
+ self.play(my_mobject.animate.shift(RIGHT).rotate(PI))
.. warning::
@@ -237,9 +249,7 @@ class Mobject:
self.play(my_mobject.animate.shift(RIGHT), my_mobject.animate.rotate(PI))
- make use of method chaining for ``animate``, meaning::
-
- self.play(my_mobject.animate.shift(RIGHT).rotate(PI))
+ make use of method chaining.
Keyword arguments that can be passed to :meth:`.Scene.play` can be passed
directly after accessing ``.animate``, like so::
@@ -511,7 +521,9 @@ class Mobject:
def set(self, **kwargs) -> "Mobject":
"""Sets attributes.
- Mainly to be used along with :attr:`animate` to
+ I.e. ``my_mobject.set(foo=1)`` applies ``my_mobject.foo = 1``.
+
+ This is a convenience to be used along with :attr:`animate` to
animate setting attributes.
In addition to this method, there is a compatibility
diff --git a/manim/mobject/numbers.py b/manim/mobject/numbers.py
index 58a1ac3e9..521b89d4f 100644
--- a/manim/mobject/numbers.py
+++ b/manim/mobject/numbers.py
@@ -293,17 +293,15 @@ class Integer(DecimalNumber):
class Variable(VMobject, metaclass=ConvertToOpenGL):
- """A class for displaying text that continuously updates to reflect the value of a python variable.
-
- Automatically adds the text for the label and the value when instantiated and added to the screen.
+ """A class for displaying text that shows "label = value" with
+ the value continuously updated from a :class:`~.ValueTracker`.
Parameters
----------
var : Union[:class:`int`, :class:`float`]
- The python variable you need to keep track of and display.
+ The initial value you need to keep track of and display.
label : Union[:class:`str`, :class:`~.Tex`, :class:`~.MathTex`, :class:`~.Text`, :class:`~.TexSymbol`, :class:`~.SingleStringMathTex`]
- The label for your variable, for example ``x = ...``. To use math mode, for e.g.
- subscripts, superscripts, etc. simply pass in a raw string.
+ The label for your variable. Raw strings are convertex to :class:`~.MathTex` objects.
var_type : Union[:class:`DecimalNumber`, :class:`Integer`], optional
The class used for displaying the number. Defaults to :class:`DecimalNumber`.
num_decimal_places : :class:`int`, optional