Skip to content
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

LaggedStart animation bugs when z-index of animated mobject is non-positive #3914

Open
bwilk315 opened this issue Aug 25, 2024 · 4 comments
Open

Comments

@bwilk315
Copy link

Description of bug / unexpected behavior

I wanted to animate MathTex and Line class instances together using LaggedStart animation.
I set the line's z-index value (using optional parameter in constructor) to -1 so it will appear under the text (which has no z-index value set).
When I render this, text animation is fine, unlike line's. It appears that line animation does not work, until LaggedStart finishes it's duty - then line transforms to the state in which it should be after successful animation.

Expected behavior

LaggedStart animation playing text's and line's animation together with lag ratio of 1/2. Finally line appearing under the text.

How to reproduce the issue

Code for reproducing the problem
from manim import *
class MainScene(Scene):
    def construct(self):
        self.wait()
        text = MathTex("amogus", font_size=30)
        line = Line([-2, 0, 0], [2, 0, 0], color=RED_D, z_index=-1)
        self.play(LaggedStart( FadeIn(text), FadeIn(line), lag_ratio=1/2 ))
        self.wait()

Additional media files

Images/GIFs
MainScene.mp4

Logs

Terminal output
Manim Community v0.18.1

[08/25/24 10:23:33] DEBUG    Animation with empty mobject                                                                                                                    animation.py:175
                    DEBUG    Hashing ...                                                                                                                                       hashing.py:352
                    DEBUG    Hashing done in 0.004607 s.                                                                                                                       hashing.py:364
                    DEBUG    Hash generated :  1264212857_123554531_631829896                                                                                                  hashing.py:367
                    INFO     Animation 0 : Using cached data (hash : 1264212857_123554531_631829896)                                                                     cairo_renderer.py:88
                    DEBUG    List of the first few animation hashes of the scene: ['1264212857_123554531_631829896']                                                     cairo_renderer.py:97
                    DEBUG    Hashing ...                                                                                                                                       hashing.py:352
                    DEBUG    Hashing done in 0.024146 s.                                                                                                                       hashing.py:364
                    DEBUG    Hash generated :  1264212857_2813359024_4227516557                                                                                                hashing.py:367
                    INFO     Animation 1 : Using cached data (hash : 1264212857_2813359024_4227516557)                                                                   cairo_renderer.py:88
                    DEBUG    List of the first few animation hashes of the scene: ['1264212857_123554531_631829896', '1264212857_2813359024_4227516557']                 cairo_renderer.py:97
[08/25/24 10:23:34] DEBUG    Animation with empty mobject                                                                                                                    animation.py:175
                    DEBUG    Hashing ...                                                                                                                                       hashing.py:352
                    DEBUG    Hashing done in 0.024582 s.                                                                                                                       hashing.py:364
                    DEBUG    Hash generated :  2725161996_1733944848_154931140                                                                                                 hashing.py:367
                    INFO     Animation 2 : Using cached data (hash : 2725161996_1733944848_154931140)                                                                    cairo_renderer.py:88
                    DEBUG    List of the first few animation hashes of the scene: ['1264212857_123554531_631829896', '1264212857_2813359024_4227516557',                 cairo_renderer.py:97
                             '2725161996_1733944848_154931140']                                                                                                                              
                    INFO     Combining to Movie file.                                                                                                                scene_file_writer.py:617
                    DEBUG    Partial movie files to combine (3 files): ['/home/bartek/Projects/To Ten                                                                scene_file_writer.py:561
                             Bartek/filmy/kąt-środkowy-i-wpisany/media/videos/program_2/1080p15/partial_movie_files/MainScene/1264212857_123554531_631829896.mp4',                           
                             '/home/bartek/Projects/To Ten                                                                                                                                   
                             Bartek/filmy/kąt-środkowy-i-wpisany/media/videos/program_2/1080p15/partial_movie_files/MainScene/1264212857_2813359024_4227516557.mp4',                         
                             '/home/bartek/Projects/To Ten                                                                                                                                   
                             Bartek/filmy/kąt-środkowy-i-wpisany/media/videos/program_2/1080p15/partial_movie_files/MainScene/2725161996_1733944848_154931140.mp4']                          
                    INFO                                                                                                                                             scene_file_writer.py:737
                             File ready at '/home/bartek/Projects/To Ten Bartek/filmy/kąt-środkowy-i-wpisany/media/videos/program_2/1080p15/MainScene.mp4'                                   
                                                                                                                                                                                             
                    INFO     Rendered MainScene                                                                                                                                  scene.py:247
                             Played 3 animations                                                                                                                                             
[08/25/24 10:23:35] INFO     Previewed File at: '/home/bartek/Projects/To Ten Bartek/filmy/kąt-środkowy-i-wpisany/media/videos/program_2/1080p15/MainScene.mp4'

System specifications

System Details
  • OS (with version, e.g., Windows 10 v2004 or macOS 10.15 (Catalina)): Linux Mint 21.3 (Cinnamon)
  • RAM: 16GB
  • Python version (python/py/python3 --version): 3.10.12
  • Installed modules (provide output from pip list):
Package           Version
----------------- -----------
click             8.1.7
cloup             3.0.5
decorator         5.1.1
glcontext         2.5.0
isosurfaces       0.1.2
manim             0.18.1
ManimPango        0.5.0
mapbox_earcut     1.0.2
markdown-it-py    3.0.0
mdurl             0.1.2
moderngl          5.10.0
moderngl-window   2.4.6
multipledispatch  1.0.0
networkx          3.3
numpy             1.26.4
pillow            10.4.0
pip               22.0.2
pycairo           1.26.1
pydub             0.25.1
pyglet            2.0.17
Pygments          2.18.0
pyrr              0.10.3
rich              13.7.1
scipy             1.14.0
screeninfo        0.8.1
setuptools        59.6.0
skia-pathops      0.8.0.post1
srt               3.5.3
svgelements       1.9.6
tqdm              4.66.5
typing_extensions 4.12.2
watchdog          4.0.1
LaTeX details
  • LaTeX distribution (e.g. TeX Live 2020): TeX Live 2022/dev/Debian
  • Installed LaTeX packages:

https://pastebin.ai/tuqw9trapp

Additional comments

I think checking out what does setting various z-indices for both mobjects actually result in, maybe we can learn something from the output behavior.

@uwezi
Copy link
Contributor

uwezi commented Aug 25, 2024

not a fix, but a work-around:

class MainScene(Scene):
    def construct(self):
        self.wait()
        text = MathTex("amogus", font_size=30)
        line = Line([-2, 0, 0], [2, 0, 0], color=RED_D, z_index=-1).set_opacity(0)
        self.add(line)
        self.play(LaggedStart( FadeIn(text), line.animate.set_opacity(1), lag_ratio=1/2 ))
        self.wait()

@bwilk315
Copy link
Author

@uwezi Actually FadeIn animation was an example. Your solution works for that specific animation, but there are still plenty of them that are affected by this bug. I mean there is even simpler way of avoiding this bug - just use positive z-indices and everything works fine. But I will keep this issue opened, because z-index is supposedly an integer which can be non-positive.

@uwezi
Copy link
Contributor

uwezi commented Aug 25, 2024

If you already have isolated the z-index as the culprit, then perhaps the title of your posting here is a bit misleading...

@bwilk315 bwilk315 changed the title LaggedStart animation bugs when using it on Line instance LaggedStart animation bugs when z-index of animated mobject is non-positive Aug 25, 2024
@bwilk315
Copy link
Author

Yeah you're right

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🆕 New
Development

No branches or pull requests

2 participants