-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Fixed alpha operations on (PNG) images with transparency #2923
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
Conversation
Previously, calling set_opacity(alpha) would have replaced the original alpha channel, thus making previously invisible parts visible.
ad4cf0c to
d10c20d
Compare
|
Hi @NicoWeio, and the other time ? class Example1(Scene):
def construct(self):
im1 = ImageMobject("translate.png").scale(5)
self.add(im1)
self.wait(0.7)
im1.set_opacity(0.7)
self.play(im1.animate.set_color(YELLOW))
self.play(FadeOut(im1))Example1@2022-08-15@18-26-18.mp4 |
|
Thanks for taking a look at it! In fact, I'm not sure how to reference our PNG file in the example, otherwise I'd gladly include it. |
|
You can use either this NumPy array then: |
|
Thanks for the pointers. While creating this PR, I noticed another bug, which I just opened #2924 for. |
|
This PR/issue depends on:
|
|
Closing this as stale. |
Overview: What does this pull request change?
Methods like
set_opacity,fadeandset_colornow preserve transparent areas in the image instead of overriding them.Note: This depends on #2924.
Motivation and Explanation: Why and how do your changes improve the library?
The previous behavior was probably not intended in the first place, thus a bug.
If I add a PNG icon with transparency, for example, I don't expect the formerly transparent background to become (mostly) black when calling
set_opacity(0.9).Further Information and Comments
My Discord message
Reviewer Checklist