예제 #1
0
 def __init__(self, light, **kwargs):
     if (not isinstance(light, AmbientLight)
             and not isinstance(light, Spotlight)):
         raise Exception(
             "Only AmbientLights and Spotlights can be switched off")
     light.submobjects = light.submobjects[::-1]
     LaggedStart.__init__(self, FadeOut, light, **kwargs)
     light.submobjects = light.submobjects[::-1]
예제 #2
0
    def construct(self):
        number_line = NumberLine(x_min=-2, x_max=2)
        text_1 = TextMobject("Theorem of") \
            .next_to(number_line, DOWN)
        text_2 = TextMobject("Beethoven") \
            .next_to(number_line, DOWN)
        dashed_line = DashedLine(
            number_line.get_left(),
            number_line.get_right(),
            color=YELLOW,
        ).set_stroke(width=11)

        self.add(number_line, text_1)

        self.play(
            LaggedStart(*[
                ShowCreationThenDestruction(dashed_segment)
                for dashed_segment in dashed_line
            ],
                        run_time=5),
            AnimationGroup(Animation(Mobject(), run_time=2.1),
                           ReplacementTransform(text_1, text_2),
                           lag_ratio=1))

        self.wait()
예제 #3
0
 def __init__(self, focal_point, **kwargs):
     digest_config(self, kwargs)
     circles = VGroup()
     for x in range(self.n_circles):
         circle = Circle(
             radius=self.big_radius,
             stroke_color=BLACK,
             stroke_width=0,
         )
         circle.move_to(focal_point)
         circle.save_state()
         circle.set_width(self.small_radius * 2)
         circle.set_stroke(self.color, self.start_stroke_width)
         circles.add(circle)
     LaggedStart.__init__(self, ApplyMethod, circles, lambda c:
                          (c.restore, ), **kwargs)
예제 #4
0
 def get_student_changes(self, *modes, **kwargs):
     pairs = list(zip(self.get_students(), modes))
     pairs = [(s, m) for s, m in pairs if m is not None]
     start = VGroup(*[s for s, m in pairs])
     target = VGroup(*[s.copy().change_mode(m) for s, m in pairs])
     if "look_at_arg" in kwargs:
         for pi in target:
             pi.look_at(kwargs["look_at_arg"])
     anims = [Transform(s, t) for s, t in zip(start, target)]
     return LaggedStart(
         *anims,
         lag_ratio=kwargs.get("lag_ratio", 0.5),
         run_time=1,
     )
예제 #5
0
    def construct(self):
        morty = Mortimer()
        morty.next_to(ORIGIN, DOWN)

        patreon_logo = PatreonLogo()
        patreon_logo.to_edge(UP)

        patrons = list(map(TextMobject, self.specific_patrons))
        num_groups = float(len(patrons)) / self.max_patron_group_size
        proportion_range = np.linspace(0, 1, num_groups + 1)
        indices = (len(patrons) * proportion_range).astype('int')
        patron_groups = [
            VGroup(*patrons[i:j]) for i, j in zip(indices, indices[1:])
        ]

        for i, group in enumerate(patron_groups):
            left_group = VGroup(*group[:len(group) / 2])
            right_group = VGroup(*group[len(group) / 2:])
            for subgroup, vect in (left_group, LEFT), (right_group, RIGHT):
                subgroup.arrange_submobjects(DOWN, aligned_edge=LEFT)
                subgroup.scale(self.patron_scale_val)
                subgroup.to_edge(vect)

        last_group = None
        for i, group in enumerate(patron_groups):
            anims = []
            if last_group is not None:
                self.play(FadeOut(last_group), morty.look, UP + LEFT)
            else:
                anims += [
                    DrawBorderThenFill(patreon_logo),
                ]
            self.play(LaggedStart(
                FadeIn,
                group,
                run_time=2,
            ), morty.change, "gracious", group.get_corner(UP + LEFT), *anims)
            self.play(morty.look_at, group.get_corner(DOWN + LEFT))
            self.play(morty.look_at, group.get_corner(UP + RIGHT))
            self.play(morty.look_at, group.get_corner(DOWN + RIGHT))
            self.play(Blink(morty))
            last_group = group
예제 #6
0
    def construct(self):
        number_line = NumberLine(x_min=-2, x_max=2)
        text = TextMobject("Text") \
            .next_to(number_line, DOWN)
        dashed_line = DashedLine(
            number_line.get_left(),
            number_line.get_right(),
            color=YELLOW,
        ).set_stroke(width=11)

        self.add(number_line)
        self.wait(0.3)

        self.play(
            LaggedStart(*[
                ShowCreationThenDestruction(dashed_segment)
                for dashed_segment in dashed_line
            ],
                        run_time=5),
            AnimationGroup(Animation(Mobject(), run_time=2.1),
                           Write(text),
                           lag_ratio=1))
        self.wait()
예제 #7
0
 def __init__(self, light, **kwargs):
     if (not isinstance(light, AmbientLight)
             and not isinstance(light, Spotlight)):
         raise Exception(
             "Only AmbientLights and Spotlights can be switched on")
     LaggedStart.__init__(self, FadeIn, light, **kwargs)