class ClockPassesTime(Animation): CONFIG = { "run_time": 5, "hours_passed": 12, "rate_func": linear, } def __init__(self, clock, **kwargs): digest_config(self, kwargs) assert(isinstance(clock, Clock)) rot_kwargs = { "axis": OUT, "about_point": clock.get_center() } hour_radians = -self.hours_passed * 2 * np.pi / 12 self.hour_rotation = Rotating( clock.hour_hand, radians=hour_radians, **rot_kwargs ) self.hour_rotation.begin() self.minute_rotation = Rotating( clock.minute_hand, radians=12 * hour_radians, **rot_kwargs ) self.minute_rotation.begin() Animation.__init__(self, clock, **kwargs) def interpolate_mobject(self, alpha): for rotation in self.hour_rotation, self.minute_rotation: rotation.interpolate_mobject(alpha)
class ClockPassesTime(Animation): CONFIG = { "run_time": 5, "hours_passed": 12, "rate_func": linear, } def __init__(self, clock, **kwargs): digest_config(self, kwargs) assert (isinstance(clock, Clock)) rot_kwargs = {"axis": OUT, "about_point": clock.get_center()} hour_radians = -self.hours_passed * 2 * np.pi / 12 self.hour_rotation = Rotating(clock.hour_hand, angle=hour_radians, **rot_kwargs) self.hour_rotation.begin() self.minute_rotation = Rotating(clock.minute_hand, angle=12 * hour_radians, **rot_kwargs) self.minute_rotation.begin() Animation.__init__(self, clock, **kwargs) def interpolate_mobject(self, alpha): for rotation in self.hour_rotation, self.minute_rotation: rotation.interpolate_mobject(alpha)
def __init__(self, clock, **kwargs): digest_config(self, kwargs) assert (isinstance(clock, Clock)) rot_kwargs = {"axis": OUT, "about_point": clock.get_center()} hour_radians = -self.hours_passed * 2 * np.pi / 12 self.hour_rotation = Rotating(clock.hour_hand, radians=hour_radians, **rot_kwargs) self.minute_rotation = Rotating(clock.minute_hand, radians=12 * hour_radians, **rot_kwargs) Animation.__init__(self, clock, **kwargs)
def construct(self): circle = Circle(color=PURPLE_A) square = Square(fill_color=GOLD_B, fill_opacity=1, color=GOLD_A) square.move_to(UP + LEFT) circle.surround(square) rectangle = Rectangle(height=2, width=3) ellipse = Ellipse(width=3, height=1, color=RED) ellipse.shift(2 * DOWN + 2 * RIGHT) pointer = CurvedArrow(2 * RIGHT, 5 * RIGHT, color=MAROON_C) arrow = Arrow(LEFT, UP) arrow.next_to(circle, DOWN + LEFT) rectangle.next_to(arrow, DOWN + LEFT) circle2 = Circle() circle2.surround(rectangle, buffer_factor=1) ring = Annulus(inner_radius=.5, outer_radius=1, color=BLUE) ring.next_to(ellipse, RIGHT) self.add(pointer) self.add(circle2) self.play(FadeIn(square)) self.play(Rotating(square), FadeIn(circle)) self.play(GrowArrow(arrow)) self.play(GrowFromCenter(rectangle), GrowFromCenter(ellipse), GrowFromCenter(ring)) self.wait()
def __init__(self, clock, **kwargs): if not hasattr(self, "args"): self.args = serialize_args([clock]) if not hasattr(self, "config"): self.config = serialize_config({ **kwargs, }) digest_config(self, kwargs) assert (isinstance(clock, Clock)) rot_kwargs = {"axis": OUT, "about_point": clock.get_center()} hour_radians = -self.hours_passed * 2 * np.pi / 12 self.hour_rotation = Rotating(clock.hour_hand, radians=hour_radians, **rot_kwargs) self.hour_rotation.begin() self.minute_rotation = Rotating(clock.minute_hand, radians=12 * hour_radians, **rot_kwargs) self.minute_rotation.begin() Animation.__init__(self, clock, **kwargs)
def __init__(self, clock, **kwargs): digest_config(self, kwargs) assert(isinstance(clock, Clock)) rot_kwargs = { "axis": OUT, "about_point": clock.get_center() } hour_radians = -self.hours_passed * 2 * np.pi / 12 self.hour_rotation = Rotating( clock.hour_hand, radians=hour_radians, **rot_kwargs ) self.hour_rotation.begin() self.minute_rotation = Rotating( clock.minute_hand, radians=12 * hour_radians, **rot_kwargs ) self.minute_rotation.begin() Animation.__init__(self, clock, **kwargs)
def construct(self): my_first_text = TextMobject("Writing with manim is fun") second_line = TextMobject("and easy to do!") second_line.next_to(my_first_text, DOWN) third_line = TextMobject("for me and you!") third_line.next_to(my_first_text, DOWN) self.play(FadeIn(my_first_text), FadeIn(second_line)) self.wait(2) self.play(Transform(second_line, third_line)) self.wait(2) self.play(ApplyMethod(my_first_text.shift, 3 * UP)) self.play(Rotating(second_line), radians=PI, run_time=2) self.wait()