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

FadeOut and .animate.set_opacity() are not working correctly on ImageMobject #4072

Open
chopan050 opened this issue Dec 26, 2024 · 0 comments · May be fixed by #4089
Open

FadeOut and .animate.set_opacity() are not working correctly on ImageMobject #4072

chopan050 opened this issue Dec 26, 2024 · 0 comments · May be fixed by #4089

Comments

@chopan050
Copy link
Contributor

chopan050 commented Dec 26, 2024

Description of bug / unexpected behavior

After adding an ImageMobject:

  • When applying .animate.set_opacity(0.1), the opacity goes up from 0.0 to 0.1 instead of going down from 1.0 to 0.1.
  • Applying .animate.set_opacity(0.5) works as expected.
  • When applying FadeOut, the opacity of the image goes to 1.0 instead of 0.0.
  • Applying FadeIn works as it should: it starts with an opacity of 0.0, and it goes up to 0.5: the last opacity we set before.

Expected behavior

  • When applying .animate.set_opacity(0.1), the opacity should have gone down from 1.0 to 0.1.
  • When applying FadeOut, the opacity of the image should have gone down to 0.0.

How to reproduce the issue

class ImageScene(Scene):
    def construct(self):
        array = np.zeros((400, 400, 4), dtype=np.uint8)
        array[:, :, 1] = 255 # Green
        array[:, :, 3] = 255 # Opaque
        image = ImageMobject(array)

        self.add(image)
        self.play(image.animate.set_opacity(0.1))
        self.play(image.animate.set_opacity(0.5))
        self.play(FadeOut(image))
        self.play(FadeIn(image))

Additional media files

Current version (with bug):

ImageScene.mp4

Without this bug, it should look like this instead (I rendered this video on an earlier version of Manim):

ImageScene.mp4

Additional comments

This bug is recent. I switched to the branch for my PR #3742, last updated in July, and the error was not present. I haven't yet found the cause of this. I looked at the fading.py, transform.py, animation.py and image_mobject.py, but I didn't find any relevant change: most of them were added typehints.

NOTE: I had to change a np.float_ to np.float64 in manim.utils.iterables and convert the config.frame_rate float to a Fraction in manim.scene.scene_file_writer in order to be able to render the scene in that older branch.

@henrikmidtiby henrikmidtiby linked a pull request Jan 2, 2025 that will close this issue
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant