Make save and restore states work as a stack #2813
jesi-rgb
started this conversation in
Suggestions and Proposals
Replies: 3 comments
-
I like this idea! |
Beta Was this translation helpful? Give feedback.
0 replies
-
That's great. Should I wait for a 1.0 version of Manim to implement it? What do you think? |
Beta Was this translation helpful? Give feedback.
0 replies
-
You could make a PR if you like, now. You won't need to wait for the refactor to complete. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello everyone! Thanks so much beforehand for your precious time. I already read the docs and saw that new features won't be tackled because of the major refactor, but I do believe it is beneficial to post it nevertheless so I don't forget about it. I myself can try to tackle this problem in the future.
Description of proposed feature
Right now, as of version 0.15.1, save and restore states work with a single state. Code can be seen here. The way it currently works is just saving a copy of the current state of the
Mobject
. In case I called theMobject.save_state()
twice, the first one would be overwritten.I found a bit of trouble working with this setup using
self.camera.frame.save_state()
because I had two different, kind of nested states: the default camera view, one zoomed in and one even more zoomed in. If I want to go from general to zoomed, then zoom a bit more, I will lose the general camera overview. There are ways around it, but pretty hacky.I propose that this functionality works as a stack, as in classic OpenGL
push()
andpop()
matrices. If I save a state, it will be saved in a LIFO array. I can save many times and then pop as needed.How can the new feature be used?
The way I imagine the interface to look is exactly the same as it works now. For any given mobject, we can do something like:
Additional comments
I don't know if there are official ways to support this or if this can interfere negatively in how the interface works. As I've seen many times in other issues and PRs, keeping the usage as simple and as easy as possible is one of the main goals of the library.
I think that by the time a given user has the necessity to do what it is described here, it can be (arguably) safe to assume that they know about the
push()
andpop()
mechanic.In case they didn't, it would definitely be beneficial to know. But that is totally open for discussion.
Thanks again. Let me know if I missed something!
Beta Was this translation helpful? Give feedback.
All reactions