In particular, I would like to smoothly zoom out and then zoom in all the while an object rotates. I cannot seem to control runtimes separately and I couldn't figure out how to use LaggedStart or Succession to achieve this. I also couldn't make an updater work – the width does not change at all. I'm including the last try on the updater.
class Rectangles(MovingCameraScene):
def construct(self):
rect1 = Rectangle(height=4.2, width=9.3)
staticobj = Rectangle(height=8,width=2,fill_color=BLUE).shift(RIGHT*7)
self.add(rect1,staticobj)
self.camera.frame.set(width=20)
x = ValueTracker(-.99)
def zoom_level(inp):
inp.set(width=math.exp(10 / (x.get_value() ** 2 - 1) + 20))
self.camera.frame.add_updater(zoom_level)
self.play(Rotate(rect1, angle=PI / 2, about_point=ORIGIN),x.animate.set_value(0.99),run_time=5)
self.wait(1)
To whoever stumbles upon this: the solution I came up with in the end was to use UpdateFromAlphaFunc.
class Rectangles(MovingCameraScene):
def construct(self):
rect1 = Rectangle(height=4.2, width=9.3)
staticobj = Rectangle(height=8,width=2,fill_color=BLUE).shift(RIGHT*7)
self.add(rect1,staticobj)
self.camera.frame.set(width=20)
def zoom_level(inp,alpha):
inp.set(width=20+5-20*(alpha-0.5)**2)
self.play(Rotate(rect1, angle=PI / 2, about_point=ORIGIN),
UpdateFromAlphaFunc(self.camera.frame,zoom_level),run_time=5)
self.wait(1)