From 9fdf79c4fe8f33a54bad88761323eb0b3cb36425 Mon Sep 17 00:00:00 2001 From: GoThrones Date: Tue, 24 Mar 2026 02:46:55 +0530 Subject: [PATCH 1/7] fix: space_out_submobjects method improved --- manim/mobject/mobject.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/manim/mobject/mobject.py b/manim/mobject/mobject.py index 14738d22a7..ca6026b5fa 100644 --- a/manim/mobject/mobject.py +++ b/manim/mobject/mobject.py @@ -1871,10 +1871,21 @@ def set_z(self, z: float, direction: Vector3DLike = ORIGIN) -> Self: """Set z value of the center of the :class:`~.Mobject` (``int`` or ``float``)""" return self.set_coord(z, 2, direction) - def space_out_submobjects(self, factor: float = 1.5, **kwargs) -> Self: - self.scale(factor, **kwargs) - for submob in self.submobjects: - submob.scale(1.0 / factor) + def space_out_submobjects(self, factor: float = 2.5, direction = RIGHT, **kwargs): + mobject_centre = self.get_center() # store the coordinate of centre of the Mobject + + actual_submobjects = [submobject for submobject in self.get_family() if len(submobject.submobjects)==0] # list of all the submobjects which do not have submobjectes of their own + + # store the coordinates of all the submobjects before they are spaced out. + submobject_center = [submobject.get_center() for submobject in actual_submobjects] + + for i,submobject in enumerate(actual_submobjects): + # How far is this submobject from the group center + offset = submobject_center[i] - mobject_centre + + # Calculate how much to shift it from it's current position, but only in x direction, since we are multiplying offset by direction: RIGHT, i.e. by [1,0,0] + submobject.shift(direction * offset * (factor - 1)) + return self def move_to( From 633835c7a10d9515af1a140fcfadb316c42eb564 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 23 Mar 2026 21:32:59 +0000 Subject: [PATCH 2/7] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- manim/mobject/mobject.py | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/manim/mobject/mobject.py b/manim/mobject/mobject.py index add9a5235b..56c022f3d8 100644 --- a/manim/mobject/mobject.py +++ b/manim/mobject/mobject.py @@ -1890,21 +1890,29 @@ def set_z(self, z: float, direction: Vector3DLike = ORIGIN) -> Self: """Set z value of the center of the :class:`~.Mobject` (``int`` or ``float``)""" return self.set_coord(z, 2, direction) - def space_out_submobjects(self, factor: float = 2.5, direction = RIGHT, **kwargs): - mobject_centre = self.get_center() # store the coordinate of centre of the Mobject + def space_out_submobjects(self, factor: float = 2.5, direction=RIGHT, **kwargs): + mobject_centre = ( + self.get_center() + ) # store the coordinate of centre of the Mobject - actual_submobjects = [submobject for submobject in self.get_family() if len(submobject.submobjects)==0] # list of all the submobjects which do not have submobjectes of their own + actual_submobjects = [ + submobject + for submobject in self.get_family() + if len(submobject.submobjects) == 0 + ] # list of all the submobjects which do not have submobjectes of their own # store the coordinates of all the submobjects before they are spaced out. - submobject_center = [submobject.get_center() for submobject in actual_submobjects] - - for i,submobject in enumerate(actual_submobjects): + submobject_center = [ + submobject.get_center() for submobject in actual_submobjects + ] + + for i, submobject in enumerate(actual_submobjects): # How far is this submobject from the group center - offset = submobject_center[i] - mobject_centre - + offset = submobject_center[i] - mobject_centre + # Calculate how much to shift it from it's current position, but only in x direction, since we are multiplying offset by direction: RIGHT, i.e. by [1,0,0] submobject.shift(direction * offset * (factor - 1)) - + return self def move_to( From eab1be3864f240a40fd6cfa120046d76e2bab4e2 Mon Sep 17 00:00:00 2001 From: GoThrones Date: Tue, 24 Mar 2026 11:50:18 +0530 Subject: [PATCH 3/7] fix: add type annotations to space_out_submobjects --- manim/mobject/mobject.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manim/mobject/mobject.py b/manim/mobject/mobject.py index ca6026b5fa..0658f9a236 100644 --- a/manim/mobject/mobject.py +++ b/manim/mobject/mobject.py @@ -1871,7 +1871,7 @@ def set_z(self, z: float, direction: Vector3DLike = ORIGIN) -> Self: """Set z value of the center of the :class:`~.Mobject` (``int`` or ``float``)""" return self.set_coord(z, 2, direction) - def space_out_submobjects(self, factor: float = 2.5, direction = RIGHT, **kwargs): + def space_out_submobjects(self, factor: float = 2.5, direction: np.ndarray = RIGHT, **kwargs) -> Self: mobject_centre = self.get_center() # store the coordinate of centre of the Mobject actual_submobjects = [submobject for submobject in self.get_family() if len(submobject.submobjects)==0] # list of all the submobjects which do not have submobjectes of their own @@ -1879,7 +1879,7 @@ def space_out_submobjects(self, factor: float = 2.5, direction = RIGHT, **kwargs # store the coordinates of all the submobjects before they are spaced out. submobject_center = [submobject.get_center() for submobject in actual_submobjects] - for i,submobject in enumerate(actual_submobjects): + for i,submobject in enumerate(actual_submobjects): # How far is this submobject from the group center offset = submobject_center[i] - mobject_centre From 9fe28df824654621f4b22baad956ff03cd70ff9c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 24 Mar 2026 06:25:56 +0000 Subject: [PATCH 4/7] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- manim/mobject/mobject.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/manim/mobject/mobject.py b/manim/mobject/mobject.py index e9bee96d1b..de68e5725e 100644 --- a/manim/mobject/mobject.py +++ b/manim/mobject/mobject.py @@ -1890,8 +1890,12 @@ def set_z(self, z: float, direction: Vector3DLike = ORIGIN) -> Self: """Set z value of the center of the :class:`~.Mobject` (``int`` or ``float``)""" return self.set_coord(z, 2, direction) - def space_out_submobjects(self, factor: float = 2.5, direction: np.ndarray = RIGHT, **kwargs) -> Self: - mobject_centre = self.get_center() # store the coordinate of centre of the Mobject + def space_out_submobjects( + self, factor: float = 2.5, direction: np.ndarray = RIGHT, **kwargs + ) -> Self: + mobject_centre = ( + self.get_center() + ) # store the coordinate of centre of the Mobject actual_submobjects = [ submobject @@ -1900,9 +1904,11 @@ def space_out_submobjects(self, factor: float = 2.5, direction: np.ndarray = RIG ] # list of all the submobjects which do not have submobjectes of their own # store the coordinates of all the submobjects before they are spaced out. - submobject_center = [submobject.get_center() for submobject in actual_submobjects] - - for i,submobject in enumerate(actual_submobjects): + submobject_center = [ + submobject.get_center() for submobject in actual_submobjects + ] + + for i, submobject in enumerate(actual_submobjects): # How far is this submobject from the group center offset = submobject_center[i] - mobject_centre From 4e5a3e7cdc6218bceb21009ec420c33be67eb469 Mon Sep 17 00:00:00 2001 From: GoThrones Date: Tue, 24 Mar 2026 11:59:56 +0530 Subject: [PATCH 5/7] fix: add type annotations to space_out_submobjects --- manim/mobject/mobject.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manim/mobject/mobject.py b/manim/mobject/mobject.py index e9bee96d1b..18efa64491 100644 --- a/manim/mobject/mobject.py +++ b/manim/mobject/mobject.py @@ -1890,7 +1890,7 @@ def set_z(self, z: float, direction: Vector3DLike = ORIGIN) -> Self: """Set z value of the center of the :class:`~.Mobject` (``int`` or ``float``)""" return self.set_coord(z, 2, direction) - def space_out_submobjects(self, factor: float = 2.5, direction: np.ndarray = RIGHT, **kwargs) -> Self: + def space_out_submobjects(self, factor: float = 2.5, direction: np.ndarray = RIGHT, **kwargs: Any) -> Self: mobject_centre = self.get_center() # store the coordinate of centre of the Mobject actual_submobjects = [ From 779be790e522977719ca23921476c71cdea57304 Mon Sep 17 00:00:00 2001 From: GoThrones Date: Wed, 25 Mar 2026 10:45:54 +0530 Subject: [PATCH 6/7] rename: space_out_submobjects to space_out in Mobject --- manim/mobject/mobject.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manim/mobject/mobject.py b/manim/mobject/mobject.py index fba85dff14..7c6fbd67b9 100644 --- a/manim/mobject/mobject.py +++ b/manim/mobject/mobject.py @@ -1890,7 +1890,7 @@ def set_z(self, z: float, direction: Vector3DLike = ORIGIN) -> Self: """Set z value of the center of the :class:`~.Mobject` (``int`` or ``float``)""" return self.set_coord(z, 2, direction) - def space_out_submobjects(self, factor: float = 2.5, direction: np.ndarray = RIGHT, **kwargs: Any) -> Self: + def space_out(self, factor: float = 2.5, direction: np.ndarray = RIGHT, **kwargs: Any) -> Self: mobject_centre = self.get_center() # store the coordinate of centre of the Mobject actual_submobjects = [ From 478f94a12660d39da00a1226dbd2421337bb1052 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 25 Mar 2026 07:23:55 +0000 Subject: [PATCH 7/7] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- manim/mobject/mobject.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/manim/mobject/mobject.py b/manim/mobject/mobject.py index 7c6fbd67b9..90c4bb69c4 100644 --- a/manim/mobject/mobject.py +++ b/manim/mobject/mobject.py @@ -1890,8 +1890,12 @@ def set_z(self, z: float, direction: Vector3DLike = ORIGIN) -> Self: """Set z value of the center of the :class:`~.Mobject` (``int`` or ``float``)""" return self.set_coord(z, 2, direction) - def space_out(self, factor: float = 2.5, direction: np.ndarray = RIGHT, **kwargs: Any) -> Self: - mobject_centre = self.get_center() # store the coordinate of centre of the Mobject + def space_out( + self, factor: float = 2.5, direction: np.ndarray = RIGHT, **kwargs: Any + ) -> Self: + mobject_centre = ( + self.get_center() + ) # store the coordinate of centre of the Mobject actual_submobjects = [ submobject