Giter Club home page Giter Club logo

Comments (2)

uwezi avatar uwezi commented on June 1, 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

from manim.

uwezi avatar uwezi commented on June 1, 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

from manim.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.