@@ -882,7 +882,7 @@ def has_time_based_updater(self) -> bool:
882882
883883 Returns
884884 -------
885- class:`bool`
885+ : class:`bool`
886886 ``True`` if at least one updater uses the ``dt`` parameter, ``False``
887887 otherwise.
888888
@@ -1905,7 +1905,17 @@ def fade(self, darkness: float = 0.5, family: bool = True) -> Self:
19051905 return self
19061906
19071907 def get_color (self ) -> ManimColor :
1908- """Returns the color of the :class:`~.Mobject`"""
1908+ """Returns the color of the :class:`~.Mobject`
1909+
1910+ Examples
1911+ --------
1912+ ::
1913+
1914+ >>> from manim import Square, RED
1915+ >>> Square(color=RED).get_color() == RED
1916+ True
1917+
1918+ """
19091919 return self .color
19101920
19111921 ##
@@ -2700,13 +2710,13 @@ def push_self_into_submobjects(self) -> Self:
27002710
27012711 def add_n_more_submobjects (self , n : int ) -> Self | None :
27022712 if n == 0 :
2703- return
2713+ return None
27042714
27052715 curr = len (self .submobjects )
27062716 if curr == 0 :
27072717 # If empty, simply add n point mobjects
27082718 self .submobjects = [self .get_point_mobject () for k in range (n )]
2709- return
2719+ return None
27102720
27112721 target = curr + n
27122722 # TODO, factor this out to utils so as to reuse
@@ -2761,7 +2771,6 @@ def interpolate_color(self, mobject1: Mobject, mobject2: Mobject, alpha: float):
27612771 def become (
27622772 self ,
27632773 mobject : Mobject ,
2764- copy_submobjects : bool = True ,
27652774 match_height : bool = False ,
27662775 match_width : bool = False ,
27672776 match_depth : bool = False ,
@@ -2774,20 +2783,25 @@ def become(
27742783 .. note::
27752784
27762785 If both match_height and match_width are ``True`` then the transformed :class:`~.Mobject`
2777- will match the height first and then the width
2786+ will match the height first and then the width.
27782787
27792788 Parameters
27802789 ----------
27812790 match_height
2782- If ``True``, then the transformed :class:`~.Mobject` will match the height of the original
2791+ Whether or not to preserve the height of the original
2792+ :class:`~.Mobject`.
27832793 match_width
2784- If ``True``, then the transformed :class:`~.Mobject` will match the width of the original
2794+ Whether or not to preserve the width of the original
2795+ :class:`~.Mobject`.
27852796 match_depth
2786- If ``True``, then the transformed :class:`~.Mobject` will match the depth of the original
2797+ Whether or not to preserve the depth of the original
2798+ :class:`~.Mobject`.
27872799 match_center
2788- If ``True``, then the transformed :class:`~.Mobject` will match the center of the original
2800+ Whether or not to preserve the center of the original
2801+ :class:`~.Mobject`.
27892802 stretch
2790- If ``True``, then the transformed :class:`~.Mobject` will stretch to fit the proportions of the original
2803+ Whether or not to stretch the target mobject to match the
2804+ the proportions of the original :class:`~.Mobject`.
27912805
27922806 Examples
27932807 --------
@@ -2801,8 +2815,62 @@ def construct(self):
28012815 self.wait(0.5)
28022816 circ.become(square)
28032817 self.wait(0.5)
2804- """
28052818
2819+
2820+ The following examples illustrate how mobject measurements
2821+ change when using the ``match_...`` and ``stretch`` arguments.
2822+ We start with a rectangle that is 2 units high and 4 units wide,
2823+ which we want to turn into a circle of radius 3::
2824+
2825+ >>> from manim import Rectangle, Circle
2826+ >>> import numpy as np
2827+ >>> rect = Rectangle(height=2, width=4)
2828+ >>> circ = Circle(radius=3)
2829+
2830+ With ``stretch=True``, the target circle is deformed to match
2831+ the proportions of the rectangle, which results in the target
2832+ mobject being an ellipse with height 2 and width 4. We can
2833+ check that the resulting points satisfy the ellipse equation
2834+ :math:`x^2/a^2 + y^2/b^2 = 1` with :math:`a = 4/2` and :math:`b = 2/2`
2835+ being the semi-axes::
2836+
2837+ >>> result = rect.copy().become(circ, stretch=True)
2838+ >>> result.height, result.width
2839+ (2.0, 4.0)
2840+ >>> ellipse_eq = np.sum(result.get_anchors()**2 * [1/4, 1, 0], axis=1)
2841+ >>> np.allclose(ellipse_eq, 1)
2842+ True
2843+
2844+ With ``match_height=True`` and ``match_width=True`` the circle is
2845+ scaled such that the height or the width of the rectangle will
2846+ be preserved, respectively.
2847+ The points of the resulting mobject satisfy the circle equation
2848+ :math:`x^2 + y^2 = r^2` for the corresponding radius :math:`r`::
2849+
2850+ >>> result = rect.copy().become(circ, match_height=True)
2851+ >>> result.height, result.width
2852+ (2.0, 2.0)
2853+ >>> circle_eq = np.sum(result.get_anchors()**2, axis=1)
2854+ >>> np.allclose(circle_eq, 1)
2855+ True
2856+ >>> result = rect.copy().become(circ, match_width=True)
2857+ >>> result.height, result.width
2858+ (4.0, 4.0)
2859+ >>> circle_eq = np.sum(result.get_anchors()**2, axis=1)
2860+ >>> np.allclose(circle_eq, 2**2)
2861+ True
2862+
2863+ With ``match_center=True``, the resulting mobject is moved such that
2864+ its center is the same as the center of the original mobject::
2865+
2866+ >>> rect = rect.shift(np.array([0, 1, 0]))
2867+ >>> np.allclose(rect.get_center(), circ.get_center())
2868+ False
2869+ >>> result = rect.copy().become(circ, match_center=True)
2870+ >>> np.allclose(rect.get_center(), result.get_center())
2871+ True
2872+ """
2873+ mobject = mobject .copy ()
28062874 if stretch :
28072875 mobject .stretch_to_fit_height (self .height )
28082876 mobject .stretch_to_fit_width (self .width )
0 commit comments