Beispiel #1
0
    def increment_count(self):
        number = self.number = Integer(0)
        number.move_to(UP, LEFT)
        number.scale(3)
        self.look_at(number, run_time=0)

        confetti_spirils = self.confetti_spirils = list(
            map(NormalAnimationAsContinualAnimation,
                get_confetti_animations(50)))
        self.add(*confetti_spirils)
        self.play(
            ChangeDecimalToValue(
                number,
                10**6,
                position_update_func=lambda m: m.move_to(UP, LEFT),
                rate_func=bezier([0, 0, 0, 1, 1, 1]),
                run_time=5,
            ),
            OldLaggedStart(
                ApplyMethod,
                self.get_pi_creatures(),
                lambda m: (m.change, "hooray", number),
                rate_func=squish_rate_func(smooth, 0, 0.5),
                run_time=4,
            ),
        )
        self.wait()
Beispiel #2
0
    def increment_count(self):
        number = self.number = Integer(0)
        number.move_to(UP, LEFT)
        number.scale(3)
        self.look_at(number, run_time=0)

        confetti_spirils = self.confetti_spirils = list(map(
            turn_animation_into_updater,
            get_confetti_animations(50)
        ))
        self.add(*confetti_spirils)
        self.play(
            ChangeDecimalToValue(
                number, 10**6,
                position_update_func=lambda m: m.move_to(
                    UP, LEFT
                ),
                rate_func=bezier([0, 0, 0, 1, 1, 1]),
                run_time=5,
            ),
            LaggedStartMap(
                ApplyMethod, self.get_pi_creatures(),
                lambda m: (m.change, "hooray", number),
                rate_func=squish_rate_func(smooth, 0, 0.5),
                run_time=4,
            ),
        )
        self.wait()
Beispiel #3
0
    def construct(self):
        equation = TexMobject("2^{19} = " + "{:,}".format(2**19))
        equation.scale_to_fit_width(FRAME_X_RADIUS)
        equation.to_edge(DOWN, buff = LARGE_BUFF)

        q_and_a = TextMobject("Q\\&A \\\\ Round 2")
        q_and_a.set_color_by_gradient(BLUE, YELLOW)
        q_and_a.scale_to_fit_width(FRAME_X_RADIUS)
        q_and_a.to_edge(UP, buff = LARGE_BUFF)

        eater = ImageMobject("eater", height = 3)
        eater.to_corner(UP+RIGHT, buff = 0)

        confetti_anims = get_confetti_animations(100)
        for anim in confetti_anims:
            anim.update(0.5)
        confetti = VGroup(*[a.mobject for a in confetti_anims])

        self.add(equation, q_and_a, eater)
Beispiel #4
0
    def construct(self):
        equation = TexMobject("2^{19} = " + "{:,}".format(2**19))
        equation.set_width(FRAME_X_RADIUS)
        equation.to_edge(DOWN, buff = LARGE_BUFF)

        q_and_a = TextMobject("Q\\&A \\\\ Round 2")
        q_and_a.set_color_by_gradient(BLUE, YELLOW)
        q_and_a.set_width(FRAME_X_RADIUS)
        q_and_a.to_edge(UP, buff = LARGE_BUFF)

        eater = ImageMobject("eater", height = 3)
        eater.to_corner(UP+RIGHT, buff = 0)

        confetti_anims = get_confetti_animations(100)
        for anim in confetti_anims:
            anim.update(0.5)
        confetti = VGroup(*[a.mobject for a in confetti_anims])

        self.add(equation, q_and_a, eater)
Beispiel #5
0
    def construct(self):
        powers_of_2 = VGroup(*[
            TexMobject("2^{%d}"%n, "=", "{:,}".format(2**n))
            for n in range(20)
        ])
        powers_of_2.to_edge(UP)
        max_height = 6
        center = MED_LARGE_BUFF*DOWN

        mob = Dot(color = BLUE)
        mob.move_to(center)
        vects = it.cycle(5*[UP] + 5*[RIGHT])
        curr_po2 = powers_of_2[0]

        for i, vect, po2 in zip(it.count(), vects, powers_of_2[1:]):
            if i == 10:
                rect = SurroundingRectangle(mob, color = GREEN)
                group = VGroup(mob, rect)
                two_to_ten = group.copy()
                group.generate_target()
                group.target.scale_to_fit_height(0.2)
                group.target[1].set_fill(BLUE, 1)

                self.play(ShowCreation(rect))
                self.play(MoveToTarget(group))
                self.remove(group)
                mob = rect
                self.add(mob)
            m1, m2 = mob.copy(), mob.copy()
            group = VGroup(m1, m2)
            group.arrange_submobjects(
                vect, buff = SMALL_BUFF
            )
            if group.get_height() > max_height:
                group.scale_to_fit_height(max_height)
            group.move_to(center)
            pa = np.pi/3
            self.play(
                Transform(curr_po2, po2),
                ReplacementTransform(mob, m1, path_arc = pa),
                ReplacementTransform(mob.copy(), m2, path_arc = pa),
            )
            mob = VGroup(*it.chain(m1, m2))

        #Show two_to_ten for comparrison
        self.play(
            mob.space_out_submobjects, 1.1,
            mob.to_edge, RIGHT
        )
        two_to_ten.to_edge(LEFT)
        lines = VGroup(*[
            Line(
                two_to_ten.get_corner(vect+RIGHT),
                mob[0].get_corner(vect+LEFT),
            )
            for vect in UP, DOWN
        ])
        two_to_ten.save_state()
        two_to_ten.replace(mob[0])
        self.play(
            two_to_ten.restore,
            *map(ShowCreation, lines)
        )

        curr_po2_outline = curr_po2[-1].copy()
        curr_po2_outline.set_fill(opacity = 0)
        curr_po2_outline.set_stroke(width = 2)
        curr_po2_outline.set_color_by_gradient(
            YELLOW, RED, PINK, PURPLE, BLUE, GREEN
        )

        self.play(
            LaggedStart(
                FadeIn, curr_po2_outline,
                rate_func = lambda t : wiggle(t, 8),
                run_time = 2,
                lag_ratio = 0.75,
            ),
            *get_confetti_animations(50)
        )
Beispiel #6
0
    def construct(self):
        powers_of_2 = VGroup(*[
            TexMobject("2^{%d}"%n, "=", "{:,}".format(2**n))
            for n in range(20)
        ])
        powers_of_2.to_edge(UP)
        max_height = 6
        center = MED_LARGE_BUFF*DOWN

        mob = Dot(color = BLUE)
        mob.move_to(center)
        vects = it.cycle(5*[UP] + 5*[RIGHT])
        curr_po2 = powers_of_2[0]

        for i, vect, po2 in zip(it.count(), vects, powers_of_2[1:]):
            if i == 10:
                rect = SurroundingRectangle(mob, color = GREEN)
                group = VGroup(mob, rect)
                two_to_ten = group.copy()
                group.generate_target()
                group.target.set_height(0.2)
                group.target[1].set_fill(BLUE, 1)

                self.play(ShowCreation(rect))
                self.play(MoveToTarget(group))
                self.remove(group)
                mob = rect
                self.add(mob)
            m1, m2 = mob.copy(), mob.copy()
            group = VGroup(m1, m2)
            group.arrange(
                vect, buff = SMALL_BUFF
            )
            if group.get_height() > max_height:
                group.set_height(max_height)
            group.move_to(center)
            pa = np.pi/3
            self.play(
                Transform(curr_po2, po2),
                ReplacementTransform(mob, m1, path_arc = pa),
                ReplacementTransform(mob.copy(), m2, path_arc = pa),
            )
            mob = VGroup(*it.chain(m1, m2))

        #Show two_to_ten for comparrison
        self.play(
            mob.space_out_submobjects, 1.1,
            mob.to_edge, RIGHT
        )
        two_to_ten.to_edge(LEFT)
        lines = VGroup(*[
            Line(
                two_to_ten.get_corner(vect+RIGHT),
                mob[0].get_corner(vect+LEFT),
            )
            for vect in (UP, DOWN)
        ])
        two_to_ten.save_state()
        two_to_ten.replace(mob[0])
        self.play(
            two_to_ten.restore,
            *list(map(ShowCreation, lines))
        )

        curr_po2_outline = curr_po2[-1].copy()
        curr_po2_outline.set_fill(opacity = 0)
        curr_po2_outline.set_stroke(width = 2)
        curr_po2_outline.set_color_by_gradient(
            YELLOW, RED, PINK, PURPLE, BLUE, GREEN
        )

        self.play(
            LaggedStartMap(
                FadeIn, curr_po2_outline,
                rate_func = lambda t : wiggle(t, 8),
                run_time = 2,
                lag_ratio = 0.75,
            ),
            *get_confetti_animations(50)
        )