ManimCommunity / manim

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

cannot use png files in ShowCreation #387

Closed kyoobey closed 4 years ago

kyoobey commented 4 years ago

version (installed through pipenv) manimce==2020.8.9

code:

class snoo_test_scene(Scene):
    def construct(self):
        snoo = ImageMobject('snoo.png')
        self.play(ShowCreation(snoo))

issue: NotImplementedError

here's the complete traceback

```bash (manimce_fresh) blah@notebook:~/desktops/d4/manimce_fresh/snoo_testing$ manim snoo_testing.py scene3 -pl [09:02:51] INFO Read configuration files: ['/home/blah/desktops/d4/manimce_fresh/.venv/lib/python3.7/site-packages/manim/default.cfg'] config.py:93 [09:02:52] DEBUG STREAM b'IHDR' 16 13 PngImagePlugin.py:153 DEBUG STREAM b'sBIT' 41 4 PngImagePlugin.py:153 DEBUG b'sBIT' 41 4 (unknown) PngImagePlugin.py:660 DEBUG STREAM b'IDAT' 57 8192 PngImagePlugin.py:153 Traceback (most recent call last): File "/home/blah/desktops/d4/snoo_testing/.venv/lib/python3.7/site-packages/manim/__main__.py", line 184, in main scene = SceneClass() File "/home/blah/desktops/d4/snoo_testing/.venv/lib/python3.7/site-packages/manim/scene/scene.py", line 71, in __init__ self.construct() File "snoo_testing.py", line 80, in construct self.play(ShowCreation(snoo)) File "/home/blah/desktops/d4/snoo_testing/.venv/lib/python3.7/site-packages/manim/scene/scene.py", line 859, in wrapper func(self, *args, **kwargs) File "/home/blah/desktops/d4/snoo_testing/.venv/lib/python3.7/site-packages/manim/scene/scene.py", line 951, in play self.begin_animations(animations) File "/home/blah/desktops/d4/snoo_testing/.venv/lib/python3.7/site-packages/manim/scene/scene.py", line 880, in begin_animations animation.begin() File "/home/blah/desktops/d4/snoo_testing/.venv/lib/python3.7/site-packages/manim/animation/animation.py", line 54, in begin self.interpolate(0) File "/home/blah/desktops/d4/snoo_testing/.venv/lib/python3.7/site-packages/manim/animation/animation.py", line 107, in interpolate self.interpolate_mobject(self.rate_func(alpha)) File "/home/blah/desktops/d4/snoo_testing/.venv/lib/python3.7/site-packages/manim/animation/animation.py", line 120, in interpolate_mobject self.interpolate_submobject(*mobs, sub_alpha) File "/home/blah/desktops/d4/snoo_testing/.venv/lib/python3.7/site-packages/manim/animation/creation.py", line 21, in interpolate_submobject submob.pointwise_become_partial(start_submob, *self.get_bounds(alpha)) File "/home/blah/desktops/d4/snoo_testing/.venv/lib/python3.7/site-packages/manim/mobject/mobject.py", line 1063, in pointwise_become_partial raise NotImplementedError("Please override in a child class.") NotImplementedError: Please override in a child class. ```

snoo.png

![snoo](https://user-images.githubusercontent.com/61683653/91681072-e50b3880-eb6a-11ea-9552-808fd25610b8.png)

leotrs commented 4 years ago

Thanks for reporting. This looks pretty bad :sweat_smile:

Could you please try the instead:

class snoo_test_scene(Scene):
    def construct(self):
        snoo = ImageMobject('snoo.png')
        self.add(snoo)
        self.wait(1)

and let us know what happens?

kyoobey commented 4 years ago

I already checked, it works

leotrs commented 4 years ago

Ok cool, so the problem is not the file or the Image Mobject, but that the animation ShowCreation doesn't seem to work on pngs.

I think this makes sense. I think ShowCreation only works on vector graphics. Can you please try

class snoo_test_scene(Scene):
    def construct(self):
        snoo = ImageMobject('snoo.png')
        self.play(FadeIn(snoo))
kyoobey commented 4 years ago

FadeIn works

can you point me to some material where these animation functions are documented ?

when I was googling I found this issue in the main manim repo: https://github.com/3b1b/manim/issues/739 it seemed like ShowCreation would support (transparent) png files. Apparently this is not the case with manim-community I think. Does that mean manim and manim-community functions are not fully interchangeable, even in future ?

leotrs commented 4 years ago

We are in the process of building more extensive documentation here https://manimce.readthedocs.io/en/latest/. This site just went up today. Unfortunately, the animations are not thoroughly documented yet.

3b1b/manim and manim CE are not necessarily compatible. We are trying to keep it as backwards compatible as possible, but in the future, they will surely start to diverge a bit.

That issue you posted on 3b1b was closed in September 2019. Manim CE was forked a few months ago. So my guess is that 3b1b will behave the same in regards to applying ShowCreation to PNGs. But I would have to try to make sure.

Aathish04 commented 4 years ago

I can confirm that ShowCreation will not work on ImageMobjects both in ManimCE and on 3b1b's Manim. This is due to the fact that ShowCreation will only work on VMobjects, as they have a points attribute, which is required for `ShowCreation. I do recall seeing some work by @xy-23 on using some alternate method to make it work, but I can't seem to find it.

leotrs commented 4 years ago

Thanks @tshrpl for reporting and @Aathish04 for confirming. Closing this in favor of #389