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

Drop Shadow for Mobjects #3616

Open
Ahmed-H-N opened this issue Feb 7, 2024 · 2 comments
Open

Drop Shadow for Mobjects #3616

Ahmed-H-N opened this issue Feb 7, 2024 · 2 comments
Labels
new feature Enhancement specifically adding a new feature (feature request should be used for issues instead)

Comments

@Ahmed-H-N
Copy link

Description of proposed feature

Adding drop shadow to mobjects.
The addition of a drop shadow feature for mobjects in Manim would greatly enhance the visual appeal and depth of animations created using the library.

@Ahmed-H-N Ahmed-H-N added the new feature Enhancement specifically adding a new feature (feature request should be used for issues instead) label Feb 7, 2024
@uwezi
Copy link
Contributor

uwezi commented Feb 7, 2024

This has been discussed on Discord: https://discord.com/channels/581738731934056449/1173280309601636483/1173280309601636483

The solution presented there is by cloning your objects which are supposed to cast a shadow. Implementing a true blurred shadow is not easy given how objects and scenes are rendered in Manim.

def add_shadow(mobject, color=BLACK, opacity=0.2, shift=(0.2, -0.2, 0)):
    shadow = (mobject.copy()
              .set_fill(color, opacity=opacity)
              .set_stroke(width=0)
              .shift(shift)
              .set_z_index(-1)
              )
    mobject.add(shadow)
    return mobject

config.background_color = WHITE

class Test(Scene): 
    def construct(self):
        card = Rectangle(height=3, width=4.5, fill_opacity=1, fill_color=WHITE, stroke_color=BLACK)
        circle = Circle(radius=1, fill_opacity=1, fill_color=WHITE, stroke_color=RED).to_corner(UL)
        star = Star(n=5, fill_opacity=1, fill_color=WHITE, stroke_color=BLUE).next_to(circle, RIGHT)
        add_shadow(card)
        add_shadow(circle)
        add_shadow(star)
        self.add(card, circle, star)

image

@uwezi
Copy link
Contributor

uwezi commented Feb 7, 2024

There is also another message on Discord by a user who claims that he has developed a drop-shadow in Manim back in 2022, but he seems to have never shared his code:
https://discord.com/channels/581738731934056449/581738732646957057/958273360612192256

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature Enhancement specifically adding a new feature (feature request should be used for issues instead)
Projects
Status: 🆕 New
Development

No branches or pull requests

2 participants