MCPcopy
hub / github.com/ManimCommunity/manim / set_z_index

Method set_z_index

manim/mobject/mobject.py:3244–3285  ·  view source on GitHub ↗

Sets the :class:`~.Mobject`'s :attr:`z_index` to the value specified in `z_index_value`. Parameters ---------- z_index_value The new value of :attr:`z_index` set. family If ``True``, the :attr:`z_index` value of all submobjects is also set.

(
        self,
        z_index_value: float,
        family: bool = True,
    )

Source from the content-addressed store, hash-verified

3242
3243 # About z-index
3244 def set_z_index(
3245 self,
3246 z_index_value: float,
3247 family: bool = True,
3248 ) -> Self:
3249 """Sets the :class:`~.Mobject`'s :attr:`z_index` to the value specified in `z_index_value`.
3250
3251 Parameters
3252 ----------
3253 z_index_value
3254 The new value of :attr:`z_index` set.
3255 family
3256 If ``True``, the :attr:`z_index` value of all submobjects is also set.
3257
3258 Returns
3259 -------
3260 :class:`Mobject`
3261 The Mobject itself, after :attr:`z_index` is set. For chaining purposes. (Returns `self`.)
3262
3263 Examples
3264 --------
3265 .. manim:: SetZIndex
3266 :save_last_frame:
3267
3268 class SetZIndex(Scene):
3269 def construct(self):
3270 text = Text('z_index = 3', color = PURE_RED).shift(UP).set_z_index(3)
3271 square = Square(2, fill_opacity=1).set_z_index(2)
3272 tex = Tex(r'zIndex = 1', color = PURE_BLUE).shift(DOWN).set_z_index(1)
3273 circle = Circle(radius = 1.7, color = GREEN, fill_opacity = 1) # z_index = 0
3274
3275 # Displaying order is now defined by z_index values
3276 self.add(text)
3277 self.add(square)
3278 self.add(tex)
3279 self.add(circle)
3280 """
3281 if family:
3282 for submob in self.submobjects:
3283 submob.set_z_index(z_index_value, family=family)
3284 self.z_index = z_index_value
3285 return self
3286
3287 def set_z_index_by_z_Point3D(self) -> Self:
3288 """Sets the :class:`~.Mobject`'s z Point3D to the value of :attr:`z_index`.

Calls

no outgoing calls