Skip to content

fix: AnimationGroup with negative z_index #4277

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion manim/scene/scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,18 @@
# as soon as there's one that needs updating of
# some kind per frame, return the list from that
# point forward.
animation_mobjects = [anim.mobject for anim in animations]

# Imported inside the method to avoid cyclic import
from ..animation.composition import AnimationGroup

Check notice

Code scanning / CodeQL

Cyclic import Note

Import of module
manim.animation.composition
begins an import cycle.

animation_mobjects = []
for anim in animations:
if isinstance(anim, AnimationGroup):
for sub in anim.animations:
animation_mobjects.append(sub.mobject)
else:
animation_mobjects.append(anim.mobject)

mobjects = self.get_mobject_family_members()
for i, mob in enumerate(mobjects):
update_possibilities = [
Expand Down
Binary file not shown.
Binary file not shown.
15 changes: 15 additions & 0 deletions tests/test_graphical_units/test_geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,21 @@ def test_ZIndex(scene):
scene.play(ApplyMethod(triangle.shift, 2 * UP))


@frames_comparison(last_frame=False)
def test_negative_z_index_AnimationGroup(scene):
# https://github.com/ManimCommunity/manim/issues/3334
s = Square().set_z_index(-1)
scene.play(AnimationGroup(GrowFromCenter(s)))


@frames_comparison(last_frame=False)
def test_negative_z_index_LaggedStart(scene):
# https://github.com/ManimCommunity/manim/issues/3914
background = Rectangle(z_index=-1)
line = Line(2 * LEFT, 2 * RIGHT, color=RED_D, z_index=-1)
scene.play(LaggedStart(FadeIn(background), FadeIn(line), lag_ratio=0.5))


@frames_comparison
def test_Angle(scene):
l1 = Line(ORIGIN, RIGHT)
Expand Down