Repository: ManimCommunity/manim
File: manim/mobject/mobject.py (Python)

Code before:
        self,
        mobject: "Mobject",
        copy_submobjects: bool = True,
        match_center: bool = False,
        match_height: bool = False,
        match_width: bool = False,
    ):
        """Edit points, colors and submobjects to be identical
        to another :class:`~.Mobject`

        Examples
        --------
        .. manim:: BecomeScene

            class BecomeScene(Scene):
                def construct(self):
                    circ = Circle(fill_color=RED, fill_opacity=0.8)
                    square = Square(fill_color=BLUE, fill_opacity=0.2)
                    self.add(circ)
                    self.wait(0.5)
                    circ.become(square)
                    self.wait(0.5)
        """
        # changes the new mobject's center, height, or width to the original's before transformation
        # if both width and height are matched then the object is stretched to fit both
        if match_height and match_width:
            mobject.stretch_to_fit_height(self.height)
            mobject.stretch_to_fit_width(self.width)
        elif match_height:
            mobject.match_height(self)
        elif match_width:
            mobject.match_width(self)
        if match_center:
            mobject.move_to(self.get_center())

        self.align_data(mobject)
        for sm1, sm2 in zip(self.get_family(), mobject.get_family()):
            sm1.points = np.array(sm2.points)
            sm1.interpolate_color(sm1, sm2, 1)
        return self

    def match_points(self, mobject: "Mobject", copy_submobjects: bool = True):
        """Edit points, positions, and submobjects to be identical
        to another :class:`~.Mobject`, while keeping the style unchanged.

        Examples
        --------
        .. manim:: MatchPointsScene

            class MatchPointsScene(Scene):
                def construct(self):

Review comment (suggestion):
Without having tested it: is this separate clause really necessary? If so, what is the difference to
```py
if match_height:
    mobject.match_height(self)
if match_width:
    mobject.match_width(self)
```

Code after:
        raise NotImplementedError("Please override in a child class.")

    def become(
        self,
        mobject: "Mobject",
        copy_submobjects: bool = True,
        match_height: bool = False,
        match_width: bool = False,
        match_depth: bool = False,
        match_center: bool = False,
        stretch: bool = False,
    ):
        """Edit points, colors and submobjects to be identical
        to another :class:`~.Mobject`

        .. note::

            If both match_height and match_width are ``True`` then the transformed :class:`~.Mobject`
            will match the height first and then the width

        Parameters
        ----------
        match_height
            If ``True``, then the transformed :class:`~.Mobject` will match the height of the original
        match_width
            If ``True``, then the transformed :class:`~.Mobject` will match the width of the original
        match_depth
            If ``True``, then the transformed :class:`~.Mobject` will match the depth of the original
        match_center
            If ``True``, then the transformed :class:`~.Mobject` will match the center of the original
        stretch
            If ``True``, then the transformed :class:`~.Mobject` will stretch to fit the proportions of the original

        Examples
        --------
        .. manim:: BecomeScene

            class BecomeScene(Scene):
                def construct(self):
                    circ = Circle(fill_color=RED, fill_opacity=0.8)
                    square = Square(fill_color=BLUE, fill_opacity=0.2)
                    self.add(circ)
                    self.wait(0.5)
                    circ.become(square)
                    self.wait(0.5)
        """

        if stretch:
            mobject.stretch_to_fit_height(self.height)
            mobject.stretch_to_fit_width(self.width)
            mobject.stretch_to_fit_depth(self.depth)