Skip to content

Instantly share code, notes, and snippets.

@uwezi
Created March 19, 2023 11:53
Show Gist options
  • Save uwezi/98e64503b2dff31859de6f891718cb1c to your computer and use it in GitHub Desktop.
Save uwezi/98e64503b2dff31859de6f891718cb1c to your computer and use it in GitHub Desktop.
[different rate functions] How to use different rate functions in the same animation #manim #updater #valuetracker #rate_functions
# @Benjamin Hackl and @kolibril13
# https://discord.com/channels/581738731934056449/1020428420498333696/1020431068236628001
from manim import *
class MeineSzene(Scene):
def construct(self):
line1 = Line(3*LEFT, 3*RIGHT).shift(UP).set_color(RED)
line2 = Line(3*LEFT, 3*RIGHT).set_color(GREEN)
d1 = Dot().move_to(line1.get_left())
d2 = Dot().move_to(line2.get_left())
label1 = Tex("smooth").next_to(line1, RIGHT)
label2 = Tex("linear").next_to(line2, RIGHT)
tr1=ValueTracker(-3)
tr2=ValueTracker(-3)
d1.add_updater(lambda z: z.set_x(tr1.get_value()))
d2.add_updater(lambda z: z.set_x(tr2.get_value()))
self.add(d1,d2)
self.add(line1,line2,d1,d2,label1,label2 )
self.play(tr1.animate(rate_func=smooth).set_value(3), tr2.animate(rate_func=linear).set_value(3))
self.wait()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment