Skip to content

Using z-order to define layer for Mobjects #117

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
kolibril13 opened this issue May 31, 2020 · 4 comments · Fixed by #122
Closed

Using z-order to define layer for Mobjects #117

kolibril13 opened this issue May 31, 2020 · 4 comments · Fixed by #122
Labels
enhancement Additions and improvements in general refactor Refactor or redesign of existing code
Milestone

Comments

@kolibril13
Copy link
Member

kolibril13 commented May 31, 2020

Matplotlib has a very nice method to define in which layer objects are shown on the screen with a parameter zorder.
image
When working with manim, it's sometimes a little tricky to get the layers right, so what about an implementation, where you can write:

d=Dot()
self.add(d, zorder= 1)

Furthermore, there could be defaults like:

  • Dots at the first layer
  • Text & Equations at the second layer
  • Shapes on the third layer
  • Functions and graphs on the fourth layer.

When I posted this text to the discord server, @eulertour wrote:

I don't think it would require anything more than sorting scene.mobjects by z-index before rendering each frame
and since its already possible to assign arbitrary attributes to mobjects it may end up being a one-line change

@PgBiel PgBiel added enhancement Additions and improvements in general refactor Refactor or redesign of existing code labels May 31, 2020
@PgBiel PgBiel added this to the PyPI Release 1.0.0 milestone May 31, 2020
@leotrs
Copy link
Contributor

leotrs commented May 31, 2020

Sounds good to me.

Relatedly, I was under the impression that mobject.get_z_index_reference_point had something to do with this, but now I'm not sure what it's supposed to be doing.

@TonyCrane
Copy link
Contributor

TonyCrane commented Jun 1, 2020

See:
manim-kindergarten/manim@dde65b4
manim-kindergarten/manim@9467514

If you think this implementation is good, I can try to create a PR.

@eulertour
Copy link
Member

The name feels a little opaque to me. Maybe it's because I've worked with CSS some, but I find z_order or z_index to make more sense. Thoughts?

@PgBiel
Copy link
Member

PgBiel commented Jun 2, 2020

I'd preder z_index as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Additions and improvements in general refactor Refactor or redesign of existing code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants