示例#1
0
    def construct(self):
        grids = [
            Grid(
                2**order, 2**order,
                stroke_width = 1
            ).shift(0.3*DOWN)
            for order in 6, 7
        ]
        grid = grids[0]
        side_brace = Brace(grid, LEFT)
        top_brace = Brace(grid, UP)
        top_words = TextMobject("256")
        new_top_words = TextMobject("512")
        side_words = top_words.copy()
        new_side_words = new_top_words.copy()
        for words in top_words, new_top_words:
            words.next_to(top_brace, UP, buff = 0.1)
        for words in side_words, new_side_words:
            words.next_to(side_brace, LEFT)

        self.add(grid)
        self.play(
            GrowFromCenter(side_brace),
            GrowFromCenter(top_brace),
            ShimmerIn(top_words),
            ShimmerIn(side_words)
        )
        self.dither()
        self.play(
            DelayByOrder(Transform(*grids)),
            Transform(top_words, new_top_words),
            Transform(side_words, new_side_words)
        )
        self.dither()
示例#2
0
    def construct(self):
        low_res = ImageMobject("low_resolution_lion", invert = False)
        high_res = ImageMobject("Lion", invert = False)
        grid = get_grid().scale(0.8)
        for mob in low_res, high_res:
            mob.replace(grid, stretch = True)
        side_brace = Brace(low_res, LEFT)
        top_brace = Brace(low_res, UP)
        top_words = TextMobject("256 Px", size = "\\normal")
        side_words = top_words.copy().rotate(np.pi/2)
        top_words.next_to(top_brace, UP)
        side_words.next_to(side_brace, LEFT)

        self.add(high_res)
        self.dither()
        self.play(DelayByOrder(Transform(high_res, low_res)))
        self.dither()
        self.play(
            GrowFromCenter(top_brace),
            GrowFromCenter(side_brace),
            ShimmerIn(top_words),
            ShimmerIn(side_words)
        )
        self.dither()
        for mob in grid, high_res:
            mob.sort_points(np.linalg.norm)
        self.play(DelayByOrder(Transform(high_res, grid)))
        self.dither()
示例#3
0
    def construct(self):
        val = 0.3
        text = TextMobject([
            "PHC", "$_n", "(", "%3.1f"%val, ")$", 
            " has a ", "limit point ", "as $n \\to \\infty$"
        ])
        func_parts = text.copy().split()[:5]
        Mobject(*func_parts).center().to_edge(UP)
        num_str, val_str = func_parts[1], func_parts[3]
        curve = UnitInterval()
        curve.sort_points(lambda p : p[0])
        dot = Dot().shift(curve.number_to_point(val))
        arrow = Arrow(val_str, dot, buff = 0.1)
        curve.add_numbers(0, 1)

        self.play(ShowCreation(curve))
        self.play(
            ShimmerIn(val_str),
            ShowCreation(arrow),
            ShowCreation(dot)
        )
        self.wait()
        self.play(
            FadeOut(arrow),
            *[
                FadeIn(func_parts[i])
                for i in 0, 1, 2, 4
            ]
        )
        for num in range(2,9):
            new_curve = HilbertCurve(order = num)
            new_curve.scale(0.8)
            new_dot = Dot(new_curve.points[int(val*new_curve.get_num_points())])
            new_num_str = TexMobject(str(num)).replace(num_str)
            self.play(
                Transform(curve, new_curve),
                Transform(dot, new_dot),
                Transform(num_str, new_num_str)
            )
            self.wait()

        text.to_edge(UP)
        text_parts = text.split()
        for index in 1, -1:
            text_parts[index].highlight()
        starters = Mobject(*func_parts + [
            Point(mob.get_center(), stroke_width=1)
            for mob in text_parts[5:]
        ])
        self.play(Transform(starters, text))
        arrow = Arrow(text_parts[-2].get_bottom(), dot, buff = 0.1)
        self.play(ShowCreation(arrow))
        self.wait()
示例#4
0
    def construct(self):
        val = 0.3
        text = TextMobject([
            "PHC", "$_n", "(", "%3.1f"%val, ")$", 
            " has a ", "limit point ", "as $n \\to \\infty$"
        ])
        func_parts = text.copy().split()[:5]
        Mobject(*func_parts).center().to_edge(UP)
        num_str, val_str = func_parts[1], func_parts[3]
        curve = UnitInterval()
        curve.sort_points(lambda p : p[0])
        dot = Dot().shift(curve.number_to_point(val))
        arrow = Arrow(val_str, dot, buff = 0.1)
        curve.add_numbers(0, 1)

        self.play(ShowCreation(curve))
        self.play(
            ShimmerIn(val_str),
            ShowCreation(arrow),
            ShowCreation(dot)
        )
        self.dither()
        self.play(
            FadeOut(arrow),
            *[
                FadeIn(func_parts[i])
                for i in 0, 1, 2, 4
            ]
        )
        for num in range(2,9):
            new_curve = HilbertCurve(order = num)
            new_curve.scale(0.8)
            new_dot = Dot(new_curve.points[int(val*new_curve.get_num_points())])
            new_num_str = TexMobject(str(num)).replace(num_str)
            self.play(
                Transform(curve, new_curve),
                Transform(dot, new_dot),
                Transform(num_str, new_num_str)
            )
            self.dither()

        text.to_edge(UP)
        text_parts = text.split()
        for index in 1, -1:
            text_parts[index].highlight()
        starters = Mobject(*func_parts + [
            Point(mob.get_center(), point_thickness=1)
            for mob in text_parts[5:]
        ])
        self.play(Transform(starters, text))
        arrow = Arrow(text_parts[-2].get_bottom(), dot, buff = 0.1)
        self.play(ShowCreation(arrow))
        self.dither()
示例#5
0
 def __init__(self, word, **kwargs):
     self.path = Cycloid(end_theta = np.pi)        
     word_mob = TextMobject(list(word))
     end_word = word_mob.copy()
     end_word.shift(-end_word.get_bottom())
     end_word.shift(self.path.get_corner(DOWN+RIGHT))
     end_word.shift(3*RIGHT)
     self.end_letters = end_word.split()
     for letter in word_mob.split():
         letter.center()
         letter.angle = 0
     unit_interval = np.arange(0, 1, 1./len(word))
     self.start_times = 0.5*(1-(unit_interval))
     Animation.__init__(self, word_mob, **kwargs)
示例#6
0
    def construct(self):
        snells = TextMobject("Snell's")
        snells.shift(-snells.get_left())
        snells.to_edge(UP)
        for vect in [RIGHT, RIGHT, LEFT, DOWN, DOWN, DOWN]:
            snells.add(snells.copy().next_to(snells, vect))
        snells.ingest_submobjects()
        snells.show()
        condensed = TextMobject("condensed")

        self.add(snells)
        self.dither()
        self.play(DelayByOrder(Transform(snells, condensed, run_time=2)))
        self.dither()
示例#7
0
 def __init__(self, word, **kwargs):
     self.path = Cycloid(end_theta=np.pi)
     word_mob = TextMobject(list(word))
     end_word = word_mob.copy()
     end_word.shift(-end_word.get_bottom())
     end_word.shift(self.path.get_corner(DOWN + RIGHT))
     end_word.shift(3 * RIGHT)
     self.end_letters = end_word.split()
     for letter in word_mob.split():
         letter.center()
         letter.angle = 0
     unit_interval = np.arange(0, 1, 1. / len(word))
     self.start_times = 0.5 * (1 - (unit_interval))
     Animation.__init__(self, word_mob, **kwargs)
示例#8
0
    def construct(self):
        snells = TextMobject("Snell's")
        snells.shift(-snells.get_left())
        snells.to_edge(UP)
        for vect in [RIGHT, RIGHT, LEFT, DOWN, DOWN, DOWN]:
            snells.add(snells.copy().next_to(snells, vect))
        snells.ingest_submobjects()
        snells.show()
        condensed = TextMobject("condensed")

        self.add(snells)
        self.dither()
        self.play(DelayByOrder(
            Transform(snells, condensed, run_time = 2)
        ))
        self.dither()
示例#9
0
    def construct(self):
        start_words = TextMobject([
            "``", "Space Filling", "Curve ''",
        ]).to_edge(TOP, buff = 0.25)
        quote, space_filling, curve_quote = start_words.copy().split()
        curve_quote.shift(
            space_filling.get_left()-\
            curve_quote.get_left()
        )
        space_filling = Point(space_filling.get_center())                
        end_words = Mobject(*[
            quote, space_filling, curve_quote
        ]).center().to_edge(TOP, buff = 0.25)
        space_filling_fractal = TextMobject("""
            ``Space Filling Fractal''
        """).to_edge(UP)
        curve = HilbertCurve(order = 2).shift(DOWN)
        fine_curve = HilbertCurve(order = 8)
        fine_curve.replace(curve)
        dots = Mobject(*[
            Dot(
                curve.points[n*curve.get_num_points()/15],
                color = YELLOW_C
            )
            for n in range(1, 15)
            if n not in [4, 11]
        ])

        start_words.shift(2*(UP+LEFT))
        self.play(
            ApplyMethod(start_words.shift, 2*(DOWN+RIGHT))
        )
        self.wait()
        self.play(Transform(start_words, end_words))
        self.wait()
        self.play(ShowCreation(curve))
        self.wait()
        self.play(ShowCreation(
            dots, 
            run_time = 3,
        ))
        self.wait()
        self.clear()
        self.play(ShowCreation(fine_curve, run_time = 5))
        self.wait()
        self.play(ShimmerIn(space_filling_fractal))
        self.wait()
示例#10
0
    def construct(self):
        start_words = TextMobject([
            "``", "Space Filling", "Curve ''",
        ]).to_edge(TOP, buff = 0.25)
        quote, space_filling, curve_quote = start_words.copy().split()
        curve_quote.shift(
            space_filling.get_left()-\
            curve_quote.get_left()
        )
        space_filling = Point(space_filling.get_center())                
        end_words = Mobject(*[
            quote, space_filling, curve_quote
        ]).center().to_edge(TOP, buff = 0.25)
        space_filling_fractal = TextMobject("""
            ``Space Filling Fractal''
        """).to_edge(UP)
        curve = HilbertCurve(order = 2).shift(DOWN)
        fine_curve = HilbertCurve(order = 8)
        fine_curve.replace(curve)
        dots = Mobject(*[
            Dot(
                curve.points[n*curve.get_num_points()/15],
                color = YELLOW_C
            )
            for n in range(1, 15)
            if n not in [4, 11]
        ])

        start_words.shift(2*(UP+LEFT))
        self.play(
            ApplyMethod(start_words.shift, 2*(DOWN+RIGHT))
        )
        self.dither()
        self.play(Transform(start_words, end_words))
        self.dither()
        self.play(ShowCreation(curve))
        self.dither()
        self.play(ShowCreation(
            dots, 
            run_time = 3,
        ))
        self.dither()
        self.clear()
        self.play(ShowCreation(fine_curve, run_time = 5))
        self.dither()
        self.play(ShimmerIn(space_filling_fractal))
        self.dither()
示例#11
0
    def construct(self):
        word = TextMobject(["Bra", "chis", "to", "chrone"])
        original_word = word.copy()
        dots = []
        for part in word.split():
            if dots:
                part.next_to(dots[-1], buff=0.06)
            dot = TexMobject("\\cdot")
            dot.next_to(part, buff=0.06)
            dots.append(dot)
        dots = Mobject(*dots[:-1])
        dots.shift(0.1 * DOWN)
        Mobject(word, dots).center()
        overbrace1 = Brace(Mobject(*word.split()[:-1]), UP)
        overbrace2 = Brace(word.split()[-1], UP)
        shortest = TextMobject("Shortest")
        shortest.next_to(overbrace1, UP)
        shortest.highlight(YELLOW)
        time = TextMobject("Time")
        time.next_to(overbrace2, UP)
        time.highlight(YELLOW)
        chrono_example = TextMobject("""
            As in ``Chronological'' \\\\
            or ``Synchronize''
        """)
        chrono_example.scale(0.5)
        chrono_example.to_edge(RIGHT)
        chrono_example.shift(2 * UP)
        chrono_example.highlight(BLUE_D)
        chrono_arrow = Arrow(word.get_right(),
                             chrono_example.get_bottom(),
                             color=BLUE_D)
        brachy_example = TextMobject("As in . . . brachydactyly?")
        brachy_example.scale(0.5)
        brachy_example.to_edge(LEFT)
        brachy_example.shift(2 * DOWN)
        brachy_example.highlight(GREEN)
        brachy_arrow = Arrow(word.get_left(),
                             brachy_example.get_top(),
                             color=GREEN)

        pronunciation = TextMobject(
            ["/br", "e", "kist", "e", "kr$\\bar{o}$n/"])
        pronunciation.split()[1].rotate_in_place(np.pi)
        pronunciation.split()[3].rotate_in_place(np.pi)
        pronunciation.scale(0.7)
        pronunciation.shift(DOWN)

        latin = TextMobject(list("Latin"))
        greek = TextMobject(list("Greek"))
        for mob in latin, greek:
            mob.to_edge(LEFT)
        question_mark = TextMobject("?").next_to(greek, buff=0.1)
        stars = Stars().highlight(BLACK)
        stars.scale(0.5).shift(question_mark.get_center())

        self.play(Transform(original_word, word), ShowCreation(dots))
        self.play(ShimmerIn(pronunciation))
        self.dither()
        self.play(GrowFromCenter(overbrace1), GrowFromCenter(overbrace2))
        self.dither()
        self.play(ShimmerIn(latin))
        self.play(FadeIn(question_mark))
        self.play(Transform(latin, greek, path_func=counterclockwise_path()))
        self.dither()
        self.play(Transform(question_mark, stars))
        self.remove(stars)
        self.dither()
        self.play(ShimmerIn(shortest))
        self.play(ShimmerIn(time))
        for ex, ar in [(chrono_example, chrono_arrow),
                       (brachy_example, brachy_arrow)]:
            self.play(ShowCreation(ar), ShimmerIn(ex))
        self.dither()
示例#12
0
    def construct(self):
        word = TextMobject(["Bra", "chis", "to", "chrone"])
        original_word = word.copy()
        dots = []
        for part in word.split():
            if dots:
                part.next_to(dots[-1], buff = 0.06)
            dot = TexMobject("\\cdot")
            dot.next_to(part, buff = 0.06)
            dots.append(dot)
        dots = Mobject(*dots[:-1])
        dots.shift(0.1*DOWN)
        Mobject(word, dots).center()
        overbrace1 = Brace(Mobject(*word.split()[:-1]), UP)
        overbrace2 = Brace(word.split()[-1], UP)
        shortest = TextMobject("Shortest")
        shortest.next_to(overbrace1, UP)
        shortest.highlight(YELLOW)
        time = TextMobject("Time")
        time.next_to(overbrace2, UP)
        time.highlight(YELLOW)
        chrono_example = TextMobject("""
            As in ``Chronological'' \\\\
            or ``Synchronize''
        """)
        chrono_example.scale(0.5)
        chrono_example.to_edge(RIGHT)
        chrono_example.shift(2*UP)
        chrono_example.highlight(BLUE_D)
        chrono_arrow = Arrow(
            word.get_right(), 
            chrono_example.get_bottom(), 
            color = BLUE_D
        )
        brachy_example = TextMobject("As in . . . brachydactyly?")
        brachy_example.scale(0.5)
        brachy_example.to_edge(LEFT)
        brachy_example.shift(2*DOWN)
        brachy_example.highlight(GREEN)
        brachy_arrow = Arrow(
            word.get_left(),
            brachy_example.get_top(), 
            color = GREEN
        )

        pronunciation = TextMobject(["/br", "e", "kist","e","kr$\\bar{o}$n/"])
        pronunciation.split()[1].rotate_in_place(np.pi)
        pronunciation.split()[3].rotate_in_place(np.pi) 
        pronunciation.scale(0.7)
        pronunciation.shift(DOWN)

        latin = TextMobject(list("Latin"))
        greek = TextMobject(list("Greek"))
        for mob in latin, greek:
            mob.to_edge(LEFT)
        question_mark = TextMobject("?").next_to(greek, buff = 0.1)
        stars = Stars().highlight(BLACK)
        stars.scale(0.5).shift(question_mark.get_center())

        self.play(Transform(original_word, word), ShowCreation(dots))
        self.play(ShimmerIn(pronunciation))
        self.dither()
        self.play(
            GrowFromCenter(overbrace1),
            GrowFromCenter(overbrace2)
        )
        self.dither()
        self.play(ShimmerIn(latin))
        self.play(FadeIn(question_mark))
        self.play(Transform(
            latin, greek,
            path_func = counterclockwise_path()
        ))
        self.dither()
        self.play(Transform(question_mark, stars))
        self.remove(stars)
        self.dither()
        self.play(ShimmerIn(shortest))
        self.play(ShimmerIn(time))
        for ex, ar in [(chrono_example, chrono_arrow), (brachy_example, brachy_arrow)]:
            self.play(
                ShowCreation(ar),
                ShimmerIn(ex)
            )
        self.dither()