-2

I would like to know how can I create a dice animation displaying random values for my manim project.

I looked over the manim documentation and 3blue1brown github but I'm not really into coding and seems very confusing for me. Thanks :s

  • Please take [the tour](https://stackoverflow.com/tour). Reading articles in the [help section](https://stackoverflow.com/help) such as [how to ask a good question](https://stackoverflow.com/help/how-to-ask) is a worthwhile investment of your time so you stay [on-topic](https://stackoverflow.com/help/on-topic) for the site. – pjs Jun 20 '23 at 15:33

1 Answers1

0

Manim is all about programming your animations using Python. There is no short-cut I believe, however, Python is considered to be quite an easy language to learn.

class dice(Scene):
    def construct(self):
        faces = VGroup(
            VGroup(
              Square(side_length=2),
            ),
            VGroup(
              Square(side_length=2),
              Dot([0,0,0], radius=0.2),
            ),
            VGroup(
              Square(side_length=2),
              Dot([-0.67,-0.67,0], radius=0.2),
              Dot([+0.67,+0.67,0], radius=0.2),
            ),
            VGroup(
              Square(side_length=2),
              Dot([-0.67,-0.67,0], radius=0.2),
              Dot([0,0,0], radius=0.2),
              Dot([+0.67,+0.67,0], radius=0.2),
            ),
            VGroup(
              Square(side_length=2),
              Dot([-0.67,-0.67,0], radius=0.2),
              Dot([+0.67,+0.67,0], radius=0.2),
              Dot([-0.67,+0.67,0], radius=0.2),
              Dot([+0.67,-0.67,0], radius=0.2),
            ),
            VGroup(
              Square(side_length=2),
              Dot([-0.67,-0.67,0], radius=0.2),
              Dot([+0.67,+0.67,0], radius=0.2),
              Dot([0,0,0], radius=0.2),
              Dot([-0.67,+0.67,0], radius=0.2),
              Dot([+0.67,-0.67,0], radius=0.2),
            ),
            VGroup(
              Square(side_length=2),
              Dot([-0.67,-0.67,0], radius=0.2),
              Dot([+0.67,+0.67,0], radius=0.2),
              Dot([-0.67,+0.67,0], radius=0.2),
              Dot([+0.67,-0.67,0], radius=0.2),
              Dot([+0.67,0,0], radius=0.2),
              Dot([-0.67,0,0], radius=0.2),
            ),
        )    
        for i in range(10):
            self.wait()
            num = np.random.random_integers(low = 1, high = 6)
            self.play(SpinInFromNothing(faces[num]))
            self.wait()
            self.play(FadeOut(faces[num]))

enter image description here

uwezi
  • 551
  • 2
  • 3