A community-maintained Python framework for creating mathematical animations.
fix: set_z_index now sets all submobjects' z_index value (#1791)
LED Me Explain261f68b2a129
diff --git a/manim/mobject/mobject.py b/manim/mobject/mobject.pyindex 7bcdcf183..82e19772a 100644--- a/manim/mobject/mobject.py+++ b/manim/mobject/mobject.py@@ -2675,19 +2675,46 @@ class Mobject:)# About z-index- def set_z_index(self, z_index_value: Union[int, float]):+ def set_z_index(+ self,+ z_index_value: float,+ family: bool = True,+ ) -> "VMobject":"""Sets the :class:`~.Mobject`'s :attr:`z_index` to the value specified in `z_index_value`.Parameters----------z_index_valueThe new value of :attr:`z_index` set.+ family+ If ``True``, the :attr:`z_index` value of all submobjects is also set.Returns-------:class:`Mobject`- The Mobject itself, after :attr:`z_index` is set. (Returns `self`.)+ The Mobject itself, after :attr:`z_index` is set. For chaining purposes. (Returns `self`.)++ Examples+ --------+ .. manim:: SetZIndex+ :save_last_frame:++ class SetZIndex(Scene):+ def construct(self):+ text = Text('z_index = 3', color = PURE_RED).shift(UP).set_z_index(3)+ square = Square(2, fill_opacity=1).set_z_index(2)+ tex = Tex(r'zIndex = 1', color = PURE_BLUE).shift(DOWN).set_z_index(1)+ circle = Circle(radius = 1.7, color = GREEN, fill_opacity = 1) # z_index = 0++ # Displaying order is now defined by z_index values+ self.add(text)+ self.add(square)+ self.add(tex)+ self.add(circle)"""+ if family:+ for submob in self.submobjects:+ submob.set_z_index(z_index_value, family=family)self.z_index = z_index_valuereturn self