Пример #1
0
 def countdown(self):
     for k in range(5, -1, -1):
         countdown_text = TexMobject(str(k))
         countdown_text.scale(1.5)
         countdown_text.set_color(YELLOW)
         countdown_text.to_corner(RIGHT+UP)
         self.add(countdown_text)
         self.wait()
         self.remove(countdown_text)
Пример #2
0
    def setup(self):
        pos_axis = NumberLine(x_min=-4.5, x_max=2.5, color=WHITE)
        pos_axis.rotate(np.pi / 2)
        pos_axis.add_tip()
        time_axis = NumberLine(x_min=0, x_max=9.5, color=WHITE)
        time_axis.add_tip()
        vec = pos_axis.number_to_point(0) - time_axis.number_to_point(0)
        time_axis.shift(vec)
        pos_text = TextMobject("位置")
        pos_text.next_to(pos_axis.number_to_point(2.5), LEFT)
        time_text = TextMobject("时间")
        time_text.next_to(time_axis.number_to_point(9.5), DOWN)
        axes_group = VGroup(pos_axis, time_axis, pos_text, time_text)
        axes_group.center()

        title_pq = TexMobject("P_4", "570", "Q_4")
        title_pq.scale(1.5)
        title_pq.to_corner(UP + RIGHT)
        for part, color in zip(title_pq, [ORANGE, BLACK, GREEN]):
            part.set_color(color)
        r_arrow = TexMobject("\\rightarrow")
        l_arrow = TexMobject("\\leftarrow")
        for arrow in (r_arrow, l_arrow):
            arrow.scale(1.5)
            arrow.move_to(title_pq[1])

        sequence_p, sequence_q = sequences = ["UDUUDUDD", "DDUDDUDD"]
        colors = [ORANGE, GREEN]
        walk_p, walk_q = walks = [
            RandomWalk1DArrow(sequence, up_color = color, down_color = color) \
            .move_start_to(pos_axis.number_to_point(0))
            for sequence, color in zip(sequences, colors)
        ]
        parts_p, parts_q = [walk.split_at(3) for walk in walks]
        self.axes_group = axes_group
        self.title_pq = title_pq
        self.walk_p = walk_p
        self.walk_q = walk_q
        self.parts_p = parts_p
        self.parts_q = parts_q
        self.r_arrow = r_arrow
        self.l_arrow = l_arrow