Skip to content

Commit 7ea765a

Browse files
authored
Optimize Mobject.become() (#4357)
1 parent 21fe73b commit 7ea765a

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

manim/mobject/mobject.py

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3103,21 +3103,22 @@ def construct(self):
31033103
--------
31043104
:meth:`~.Mobject.align_data`, :meth:`~.VMobject.interpolate_color`
31053105
"""
3106-
mobject = mobject.copy()
3107-
if stretch:
3108-
mobject.stretch_to_fit_height(self.height)
3109-
mobject.stretch_to_fit_width(self.width)
3110-
mobject.stretch_to_fit_depth(self.depth)
3111-
else:
3112-
if match_height:
3113-
mobject.match_height(self)
3114-
if match_width:
3115-
mobject.match_width(self)
3116-
if match_depth:
3117-
mobject.match_depth(self)
3118-
3119-
if match_center:
3120-
mobject.move_to(self.get_center())
3106+
if stretch or match_height or match_width or match_depth or match_center:
3107+
mobject = mobject.copy()
3108+
if stretch:
3109+
mobject.stretch_to_fit_height(self.height)
3110+
mobject.stretch_to_fit_width(self.width)
3111+
mobject.stretch_to_fit_depth(self.depth)
3112+
else:
3113+
if match_height:
3114+
mobject.match_height(self)
3115+
if match_width:
3116+
mobject.match_width(self)
3117+
if match_depth:
3118+
mobject.match_depth(self)
3119+
3120+
if match_center:
3121+
mobject.move_to(self.get_center())
31213122

31223123
self.align_data(mobject, skip_point_alignment=True)
31233124
for sm1, sm2 in zip(self.get_family(), mobject.get_family()):

0 commit comments

Comments
 (0)