-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Fixed animations introducing or removing objects #2396
Fixed animations introducing or removing objects #2396
Conversation
I like the semantics of this approach! In particular, the new method for preparing the scene seems useful. I'll have to think a bit more about this and how it interacts with the already present machinery for adding mobjects (the For now, thank you! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, I like these changes – thanks again for your efforts! There are some things I am somewhat unhappy with (like the fact that this makes it less easy to understand when in an Animation's life cycle mobjects are added to the scene), but I think the fact that this PR makes Animations more symmetric with the introducer
keyword arg on the one hand, and the setup_scene
method on the other hand, outweighs my concerns.
It would be good to have another dev look over this / approve it before it is merged.
manim/animation/composition.py
Outdated
@@ -112,6 +117,7 @@ def interpolate(self, alpha: float) -> None: | |||
class Succession(AnimationGroup): | |||
def __init__(self, *animations: Animation, lag_ratio: float = 1, **kwargs) -> None: | |||
super().__init__(*animations, lag_ratio=lag_ratio, **kwargs) | |||
self.scene = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see why this is necessary, but I don't quite like it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this was needed only because some tests didn't call setup_scene
before begin. I've updated them and it's no longer necessary.
@@ -497,7 +497,7 @@ def __getitem__(self: "Graph", v: Hashable) -> "Mobject": | |||
def __repr__(self: "Graph") -> str: | |||
return f"Graph on {len(self.vertices)} vertices and {len(self.edges)} edges" | |||
|
|||
def _add_vertex( | |||
def _create_vertex( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like these changes to Graph
vertex creation, regardless of the changed overridden animation. I do have to admit: I don't like the amount of bending of the Animation framework that needs to be done to make custom overrides of vertex creation work. Maybe it is not worth keeping the @override_animate
idea around.
2d33b57
to
aef14f3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM in general, just some questions and comments.
manim/animation/animation.py
Outdated
if self.is_remover(): | ||
scene.remove(self.mobject) | ||
|
||
def setup_scene(self, scene: "Scene") -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be prefaced with a single underscore to mark it as only for internal use?
@@ -434,6 +456,16 @@ def is_remover(self) -> bool: | |||
""" | |||
return self.remover | |||
|
|||
def is_introducer(self) -> bool: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that this method only returns the value of an attribute, is it really needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's made this way to mirror the is_remover
method.
manim/animation/animation.py
Outdated
self.suspend_mobject_updating: bool = suspend_mobject_updating | ||
self.lag_ratio: float = lag_ratio | ||
self._on_finish: Callable[["Scene"], None] = _on_finish |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's better to mark typehints with the actual class rather than a string.
manim/mobject/graph.py
Outdated
The mobject to be used as the vertex. Overrides all other | ||
vertex customization options. | ||
""" | ||
) -> Tuple[Hashable, np.ndarray, dict, "Mobject"]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typehint, see above
manim/mobject/graph.py
Outdated
vertex: Hashable, | ||
position: np.ndarray, | ||
vertex_config: dict, | ||
vertex_mobject: "Mobject", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typehints, see above
aef14f3
to
7a77ee6
Compare
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you!
Overview: What does this pull request change?
.ShowPassingFlash
now removes objects when the animation is finishedintroducer
keyword argument to :class:.Animation
analogous toremover
.Graph
vertex addition handlingMotivation and Explanation: Why and how do your changes improve the library?
Fixes #2349.
Links to added or changed documentation pages
Further Information and Comments
Code:
Before:
IntroducersInSuccession.mp4
After:
IntroducersInSuccession.mp4
Reviewer Checklist