mirror of
https://github.com/ManimCommunity/manim.git
synced 2026-06-22 10:01:47 +00:00
Add support for negative z-index in AnimationGroup (#4389)
* Add support for negative z-index in AnimationGroup * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Refactor animation unpacking logic for clarity * Fix unpacking logic to handle Mobject instances correctly * Fix mypy check * Fix tests * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix: simplify AnimationGroup unpacking for moving mobjects --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Benjamin Hackl <devel@benjamin-hackl.at>
This commit is contained in:
parent
cd370610c5
commit
87cd63549c
5 changed files with 39 additions and 1 deletions
|
|
@ -903,7 +903,24 @@ class Scene:
|
|||
# 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
|
||||
|
||||
def _collect_animation_mobjects(
|
||||
nested_animations: Iterable[Animation],
|
||||
) -> list[Mobject | OpenGLMobject]:
|
||||
animation_mobjects: list[Mobject | OpenGLMobject] = []
|
||||
for anim in nested_animations:
|
||||
if isinstance(anim, AnimationGroup):
|
||||
animation_mobjects.extend(
|
||||
_collect_animation_mobjects(anim.animations),
|
||||
)
|
||||
else:
|
||||
animation_mobjects.extend(anim.mobject.get_family())
|
||||
return animation_mobjects
|
||||
|
||||
animation_mobjects = _collect_animation_mobjects(animations)
|
||||
|
||||
mobjects = self.get_mobject_family_members()
|
||||
for i, mob in enumerate(mobjects):
|
||||
update_possibilities = [
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -174,6 +174,27 @@ 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
|
||||
line_1 = Line(LEFT, RIGHT, color=BLUE)
|
||||
line_2 = Line(UP + LEFT, UP + RIGHT, color=RED).set_z_index(-1)
|
||||
scene.play(LaggedStart(FadeIn(line_1), FadeIn(line_2), lag_ratio=0.5))
|
||||
|
||||
|
||||
@frames_comparison(last_frame=False)
|
||||
def test_nested_animation_groups_with_negative_z_index(scene):
|
||||
line = Line(LEFT, RIGHT, color=BLUE).set_z_index(-1)
|
||||
scene.play(AnimationGroup(AnimationGroup(AnimationGroup(FadeIn(line)))))
|
||||
|
||||
|
||||
@frames_comparison
|
||||
def test_Angle(scene):
|
||||
l1 = Line(ORIGIN, RIGHT)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue