manim icon indicating copy to clipboard operation
manim copied to clipboard

add zorder to mobject

Open zhuanvi opened this issue 1 year ago • 0 comments

Motivation

Suggestion: Using z-order to define layer for Mobjects.

Proposed changes

  • mobject.py
  • scene.py

Test

Code:

from manimlib import *


class Video(Scene):
    
    def construct(self):
        s = Square(zorder=1).set_fill(RED,opacity=1)
        c = Circle(zorder=2).set_fill(BLUE,opacity=1)
        t = Triangle(zorder=0).scale(2).set_fill(GREEN,opacity=1)
        r = Rectangle(width=4,height=2,zorder=0).set_fill(PINK,opacity=1)
        self.play(ShowCreation(c))
        self.play(ShowCreation(s))
        self.play(ShowCreation(t))
        self.play(ShowCreation(r))

Result:

https://github.com/3b1b/manim/assets/15604323/cc51b03b-db30-41ea-8050-9e00922151fa

zhuanvi avatar Aug 27 '23 07:08 zhuanvi