A community-maintained Python framework for creating mathematical animations.
Store the original alpha channel from the image when creating the ImageMObject and then use it in the set_opacity method (#4313)
Henrik Skov Midtiby9c43ad0d2130
diff --git a/manim/mobject/types/image_mobject.py b/manim/mobject/types/image_mobject.pyindex 56029f941..f73e6a647 100644--- a/manim/mobject/types/image_mobject.py+++ b/manim/mobject/types/image_mobject.py@@ -205,6 +205,7 @@ class ImageMobject(AbstractImageMobject):self.pixel_array[:, :, :3] = (np.iinfo(self.pixel_array_dtype).max - self.pixel_array[:, :, :3])+ self.orig_alpha_pixel_array = self.pixel_array[:, :, 3].copy()super().__init__(scale_to_resolution, **kwargs)def get_pixel_array(self):@@ -230,8 +231,7 @@ class ImageMobject(AbstractImageMobject):The alpha value of the object, 1 being opaque and 0 beingtransparent."""- self.pixel_array[:, :, 3] = int(255 * alpha)- self.fill_opacity = alpha+ self.pixel_array[:, :, 3] = self.orig_alpha_pixel_array * alphaself.stroke_opacity = alphareturn self