ManimCommunity / manim

A community-maintained Python framework for creating mathematical animations.
https://www.manim.community
MIT License
24.17k stars 1.7k forks source link

New feature .animate does not work when including multiple animations to run at once #1129

Closed fmsol94 closed 3 years ago

fmsol94 commented 3 years ago

Description of bug / unexpected behavior

In the past when we wanted to play multiple actions over a MObject we could include all of them in the following way: This example is working with old version and a Tex Object:

class ChangePosColScale(Scene):
    def construct(self):
        text = Tex("Text")
        text.scale(2)
        text.move_to(LEFT*2)
        self.play(Write(text))
        self.wait()

         self.play(
                 text.move_to, RIGHT*2,
                 text.scale, 2,
                 text.set_color, RED,
                 run_time=2,
             )

        self.wait()

Since this pull request 881, this code is no longer supported and the way it should be done is:

class ChangePosColScale(Scene):
    def construct(self):
        text = Tex("Text")
        text.scale(2)
        text.move_to(LEFT*2)
        self.play(Write(text))
        self.wait()

         self.play(
                 text.animate.move_to(RIGHT*2),
                 text.animate.scale(2),
                 text.animate.set_color(RED),
                 run_time=2,
             )

        self.wait()

And this code will only generate the last animation (changing color to RED) included in self.play.

Expected behavior

The expected behavior of the last code snippet is to generate an animation where the text is moved to the right, scaled to 2 and the color changes to RED.

The unexpected behavior is that it only plays the last animation included, the text only changes the color without scaling nor movement.

How to reproduce the issue

Code for reproducing the problem ```py class ChangePosColScale(Scene): def construct(self): text = Tex("Text") text.scale(2) text.move_to(LEFT*2) self.play(Write(text)) self.wait() self.play( text.animate.move_to(RIGHT*2), text.animate.scale(2), text.animate.set_color(RED), run_time=2, ) self.wait() ```

Additional media files

Images/GIFs https://gifyu.com/image/fvhp

Logs

Terminal output ``` [03/20/21 19:44:50] DEBUG Hashing ... hashing.py:239 DEBUG Hashing done in 0.017715 s. hashing.py:252 DEBUG Hash generated : hashing.py:256 3163782288_3460403320_2088264539 INFO Animation 0 : Using cached data (hash : caching.py:39 3163782288_3460403320_2088264539) DEBUG List of the first few animation hashes of the caching.py:48 scene: ['3163782288_3460403320_2088264539'] DEBUG creating dummy animation animation.py:66 DEBUG Hashing ... hashing.py:239 DEBUG Hashing done in 0.013540 s. hashing.py:252 DEBUG Hash generated : hashing.py:256 1495979052_4180579860_1719147566 INFO Animation 1 : Using cached data (hash : caching.py:39 1495979052_4180579860_1719147566) DEBUG List of the first few animation hashes of the caching.py:48 scene: ['3163782288_3460403320_2088264539', '1495979052_4180579860_1719147566'] DEBUG Hashing ... hashing.py:239 DEBUG Hashing done in 0.027755 s. hashing.py:252 DEBUG Hash generated : hashing.py:256 1495979052_1998610956_2088264539 DEBUG List of the first few animation hashes of the caching.py:48 scene: ['3163782288_3460403320_2088264539', '1495979052_4180579860_1719147566', '1495979052_1998610956_2088264539'] [03/20/21 19:44:51] INFO Animation 2 : Partial movie file scene_file_writer.py:395 written in {'/manim/Examples/media/vide os/Examples/480p15/partial_movie_files/ MediaFile/1495979052_1998610956_2088264 539.mp4'} DEBUG creating dummy animation animation.py:66 DEBUG Hashing ... hashing.py:239 DEBUG Hashing done in 0.023662 s. hashing.py:252 DEBUG Hash generated : hashing.py:256 1495979052_4180579860_2805714875 DEBUG List of the first few animation hashes of the caching.py:48 scene: ['3163782288_3460403320_2088264539', '1495979052_4180579860_1719147566', '1495979052_1998610956_2088264539', '1495979052_4180579860_2805714875'] INFO Animation 3 : Partial movie file scene_file_writer.py:395 written in {'/manim/Examples/media/vide os/Examples/480p15/partial_movie_files/ MediaFile/1495979052_4180579860_2805714 875.mp4'} DEBUG Partial movie files to combine (4 scene_file_writer.py:447 files): ['/manim/Examples/media/videos/ Examples/480p15/partial_movie_files/Med iaFile/3163782288_3460403320_2088264539 .mp4', '/manim/Examples/media/videos/Ex amples/480p15/partial_movie_files/Media File/1495979052_4180579860_1719147566.m p4', '/manim/Examples/media/videos/Exam ples/480p15/partial_movie_files/MediaFi le/1495979052_1998610956_2088264539.mp4 ', '/manim/Examples/media/videos/Exampl es/480p15/partial_movie_files/MediaFile /1495979052_4180579860_2805714875.mp4'] INFO scene_file_writer.py:579 File ready at /manim/Examples/media/vid eos/Examples/480p15/MediaFile_ManimCE_v 0.4.0.gif INFO Rendered MediaFile scene.py:183 Played 4 animations ```

System specifications

System Details - OS: NAME="Debian GNU/Linux" VERSION_ID="10" VERSION="10 (buster)" VERSION_CODENAME=buster ID=debian HOME_URL="https://www.debian.org/" SUPPORT_URL="https://www.debian.org/support" BUG_REPORT_URL="https://bugs.debian.org/" - RAM: 32GB - Python version: 3.8.8 - Installed modules (provide output from `pip list`): ``` anyio 2.2.0 argon2-cffi 20.1.0 async-generator 1.10 attrs 20.3.0 Babel 2.9.0 backcall 0.2.0 bleach 3.3.0 certifi 2020.12.5 cffi 1.14.5 chardet 4.0.0 colorama 0.4.4 colour 0.1.5 commonmark 0.9.1 decorator 4.4.2 defusedxml 0.7.1 entrypoints 0.3 glcontext 2.3.3 grpcio 1.33.2 grpcio-tools 1.33.2 idna 2.10 ipykernel 5.5.0 ipython 7.21.0 ipython-genutils 0.2.0 jedi 0.17.2 Jinja2 2.11.3 json5 0.9.5 jsonschema 3.2.0 jupyter-client 6.1.12 jupyter-core 4.7.1 jupyter-packaging 0.7.12 jupyter-server 1.4.1 jupyterlab 3.0.10 jupyterlab-pygments 0.1.2 jupyterlab-server 2.3.0 manim 0.4.0 ManimPango 0.2.4 mapbox-earcut 0.12.10 MarkupSafe 1.1.1 mistune 0.8.4 moderngl 5.6.4 moderngl-window 2.3.0 multipledispatch 0.6.0 nbclassic 0.2.6 nbclient 0.5.3 nbconvert 6.0.7 nbformat 5.1.2 nest-asyncio 1.5.1 networkx 2.5 notebook 6.2.0 numpy 1.20.1 packaging 20.9 pandocfilters 1.4.3 parso 0.7.1 pexpect 4.8.0 pickleshare 0.7.5 Pillow 8.1.2 pip 21.0.1 prometheus-client 0.9.0 prompt-toolkit 3.0.17 protobuf 3.15.6 ptyprocess 0.7.0 pycairo 1.20.0 pycparser 2.20 pydub 0.25.1 pyglet 1.5.15 Pygments 2.8.1 pyparsing 2.4.7 pyrr 0.10.3 pyrsistent 0.17.3 python-dateutil 2.8.1 pytz 2021.1 pyzmq 22.0.3 requests 2.25.1 rich 6.2.0 scipy 1.6.1 Send2Trash 1.5.0 setuptools 54.1.1 six 1.15.0 sniffio 1.2.0 terminado 0.9.3 testpath 0.4.4 tornado 6.1 tqdm 4.59.0 traitlets 5.0.5 typing-extensions 3.7.4.3 urllib3 1.26.4 watchdog 2.0.2 wcwidth 0.2.5 webencodings 0.5.1 wheel 0.36.2 ```
LaTeX details + LaTeX distribution (e.g. TeX Live 2020): pdfTeX, Version 3.14159265-2.6-1.40.21 (TeX Live 2020) (preloaded format=latex) + Installed LaTeX packages: i amsfonts: TeX fonts from the American Mathematical Society i amsmath: AMS mathematical facilities for LaTeX i atbegshi: Execute stuff at \shipout time i atveryend: Hooks at the very end of a document i babel: Multilingual support for Plain TeX or LaTeX i babel-english: Babel support for English i bibtex: Process bibliographies for LaTeX, etc i bibtex.x86_64-linux: x86_64-linux files of bibtex i cm: Computer Modern fonts i cm-super: CM-Super family of fonts i collection-basic: Essential programs and files i colorprofiles: Collection of free ICC profiles i dehyph: German hyphenation patterns for traditional orthography i doublestroke: Typeset mathematical double stroke symbols i dvipdfmx: An extended version of dvipdfm i dvipdfmx.x86_64-linux: x86_64-linux files of dvipdfmx i dvips: A DVI to PostScript driver i dvips.x86_64-linux: x86_64-linux files of dvips i dvisvgm: Convert DVI, EPS, and PDF files to Scalable Vector Graphics format (SVG) i dvisvgm.x86_64-linux: x86_64-linux files of dvisvgm i ec: Computer modern fonts in T1 and TS1 encodings i enctex: A TeX extension that translates input on its way into TeX i etex: An extended version of TeX, from the NTS project i etex-pkg: E-TeX support package i everysel: Provides hooks into \selectfont i everyshi: Take action at every \shipout i firstaid: First aid for external LaTeX files and packages that need updating i fundus-calligra: Support for the calligra font in LaTeX documents i glyphlist: Adobe Glyph List and TeX extensions i graphics: The LaTeX standard graphics bundle i graphics-cfg: Sample configuration files for LaTeX color and graphics i graphics-def: Colour and graphics option files i hyph-utf8: Hyphenation patterns expressed in UTF-8 i hyphen-base: core hyphenation support files i hyphenex: US English hyphenation exceptions file i ifplatform: Conditionals to test which platform is being used i iftex: Am I running under pdfTeX, XeTeX or LuaTeX? i jknapltx: Miscellaneous packages by Joerg Knappen i knuth-lib: Core TeX and Metafont sources from Knuth i knuth-local: Knuth's local information i kpathsea: Path searching library for TeX-related files i kpathsea.x86_64-linux: x86_64-linux files of kpathsea i l3backend: LaTeX3 backend drivers i l3kernel: LaTeX3 programming conventions i l3packages: High-level LaTeX3 concepts i latex: A TeX macro package that defines LaTeX i latex-bin: LaTeX executables and man pages i latex-bin.x86_64-linux: x86_64-linux files of latex-bin i latex-fonts: A collection of fonts used in LaTeX distributions i latexconfig: configuration files for LaTeX-related formats i lm: Latin modern fonts in outline formats i lua-alt-getopt: Process application arguments the same way as getopt_long i luahbtex: LuaTeX with HarfBuzz library for glyph shaping i luahbtex.x86_64-linux: x86_64-linux files of luahbtex i lualibs: Additional Lua functions for LuaTeX macro programmers i luaotfload: OpenType 'loader' for Plain TeX and LaTeX i luaotfload.x86_64-linux: x86_64-linux files of luaotfload i luatex: The LuaTeX engine i luatex.x86_64-linux: x86_64-linux files of luatex i makeindex: Makeindex development sources i makeindex.x86_64-linux: x86_64-linux files of makeindex i metafont: A system for specifying fonts i metafont.x86_64-linux: x86_64-linux files of metafont i mflogo: LaTeX support for Metafont logo fonts i mfware: Supporting tools for use with Metafont i mfware.x86_64-linux: x86_64-linux files of mfware i microtype: Subliminal refinements towards typographical perfection i modes: A collection of Metafont mode_def's i ms: Various LaTeX packages by Martin Schroder i pdftex: A TeX extension for direct creation of PDF i pdftex.x86_64-linux: x86_64-linux files of pdftex i physics: Macros supporting the Mathematics of Physics i plain: The Plain TeX format i preview: Extract bits of a LaTeX source for output i ragged2e: Alternative versions of "ragged"-type commands i relsize: Set the font size relative to the current font size i rsfs: Ralph Smith's Formal Script font i scheme-infraonly: infrastructure-only scheme (no TeX at all) i scheme-minimal: minimal scheme (plain only) i setspace: Set space between lines i standalone: Compile TeX pictures stand-alone or as part of a document i tex: A sophisticated typesetting engine i tex-ini-files: Model TeX format creation files i tex.x86_64-linux: x86_64-linux files of tex i texlive-common: TeX Live documentation (common elements) i texlive-docindex: top-level TeX Live doc.html, etc. i texlive-en: TeX Live manual (English) i texlive-msg-translations: translations of the TeX Live installer and TeX Live Manager i texlive-scripts: TeX Live infrastructure programs i texlive-scripts.x86_64-linux: x86_64-linux files of texlive-scripts i texlive.infra: basic TeX Live infrastructure i texlive.infra.x86_64-linux: x86_64-linux files of texlive.infra i tipa: Fonts and macros for IPA phonetics characters i tlshell: GUI frontend (tcl/tk-based) for tlmgr i tlshell.x86_64-linux: x86_64-linux files of tlshell i unicode-data: Unicode data and loaders for TeX i wasy: The wasy fonts (Waldi symbol fonts) i wasysym: LaTeX support for the wasy fonts i xcolor: Driver-independent color extensions for LaTeX and pdfLaTeX i xdvi: A DVI previewer for the X Window System i xdvi.x86_64-linux: x86_64-linux files of xdvi i xkeyval: Extension of the keyval package
FFMPEG Output of `ffmpeg -version`: ``` ffmpeg version 4.1.6-1~deb10u1 Copyright (c) 2000-2020 the FFmpeg developers built with gcc 8 (Debian 8.3.0-6) configuration: --prefix=/usr --extra-version='1~deb10u1' --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared libavutil 56. 22.100 / 56. 22.100 libavcodec 58. 35.100 / 58. 35.100 libavformat 58. 20.100 / 58. 20.100 libavdevice 58. 5.100 / 58. 5.100 libavfilter 7. 40.101 / 7. 40.101 libavresample 4. 0. 0 / 4. 0. 0 libswscale 5. 3.100 / 5. 3.100 libswresample 3. 3.100 / 3. 3.100 libpostproc 55. 3.100 / 55. 3.100 ```

Additional comments

I'm using the docker image provided in the docker repo of manim community. Thanks to the team for all this amazing work.

kilacoda-old commented 3 years ago

Use text.animate.move_to(RIGHT*2).scale(2).set_color(RED). run_time and other parameters will be added when #1118 is merged.

fmsol94 commented 3 years ago

Thanks, that worked!