0

There are three statements like below:

print("first time", time.time())
self.wait(5)
print("second time", time.time())

I suppose the difference between "second time" and "first time" will be 5 seconds, however, they are the same, why?

I think the self.wait(5) should be async call, if so, how to get timestame in runtime?

James Hao
  • 765
  • 2
  • 11
  • 40

2 Answers2

1

If what you want is to print in the terminal the exact second of each moment of the animation you can do something like this (the time is saved in the variable self.time):

class TimeTest(Scene):
    def print_time(self):
        print("Time:",self.time)

    def construct(self):
        dot=Dot()
        # 0 seconds
        self.print_time()
        self.play(Write(dot,run_time=2))
        # 2 seconds
        self.print_time()
        self.wait()
        # 3 seconds
        self.print_time()
        self.play(dot.shift,UP,run_time=1)
        # 4 seconds
        self.print_time()
        self.play(FadeToColor(dot,RED,run_time=3))
        # 7 seconds
        self.print_time()
        self.wait()
        # 8 seconds
        self.print_time()
TheoremOfBeethoven
  • 1,864
  • 6
  • 15
0

It looks like in the recent version of Manim-CE time is no longer a member variable of Scene (although this might still be the way to go for ManimGL).

What worked for me was using self.renderer.time

Aleksei Petrenko
  • 6,698
  • 10
  • 53
  • 87