コード例 #1
0
ファイル: section2.py プロジェクト: zhujianing/manim
    def construct(self):
        definition = TexMobject([
            "\\text{HC}(", "x", ")",
            "=\\lim_{n \\to \\infty}\\text{PHC}_n(", "x", ")"
        ])
        definition.to_edge(UP)
        definition.split()[1].highlight(BLUE)
        definition.split()[-2].highlight(BLUE)
        intro = TextMobject("Three things need to be proven")
        prove_that = TextMobject("Prove that HC is $\\dots$")
        prove_that.scale(0.7)
        prove_that.to_edge(LEFT)
        items = TextMobject([
            "\\begin{enumerate}",
            "\\item Well-defined: ",
            "Points on Pseudo-Hilbert-curves really do converge",
            "\\item A Curve: ",
            "HC is continuous",
            "\\item Space-filling: ",
            "Each point in the unit square is an output of HC",
            "\\end{enumerate}",
        ]).split()
        items[1].highlight(GREEN)
        items[3].highlight(YELLOW_C)
        items[5].highlight(MAROON)
        Mobject(*items).to_edge(RIGHT)

        self.add(definition)
        self.play(ShimmerIn(intro))
        self.wait()
        self.play(Transform(intro, prove_that))
        for item in items[1:-1]:
            self.play(ShimmerIn(item))
            self.wait()
コード例 #2
0
ファイル: section1.py プロジェクト: zhouxiaoxiaoxujian/manim
    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
ファイル: section1.py プロジェクト: zhouxiaoxiaoxujian/manim
    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()
コード例 #4
0
ファイル: section2.py プロジェクト: yueleicool/manim
    def construct(self):
        words = TextMobject([
            "One does not simply define the limit \\\\ \
            of a sequence of", "curves", "\\dots"
        ])
        top_words = TextMobject(["curves", "are functions"]).to_edge(UP)
        curves1 = words.split()[1]
        curves2 = top_words.split()[0]
        words.ingest_submobjects()
        number = TexMobject("0.27")
        pair = TexMobject("(0.53, 0.02)")
        pair.next_to(number, buff=2)
        arrow = Arrow(number, pair)
        Mobject(number, arrow, pair).center().shift(UP)
        number_line = UnitInterval()
        number_line.stretch_to_fit_width(5)
        number_line.to_edge(LEFT).shift(DOWN)
        grid = Grid(4, 4).scale(0.4)
        grid.next_to(number_line, buff=2)
        low_arrow = Arrow(number_line, grid)

        self.play(ShimmerIn(words))
        self.dither()
        self.play(FadeOut(words), ApplyMethod(curves1.replace, curves2),
                  ShimmerIn(top_words.split()[1]))
        self.dither()
        self.play(FadeIn(number))
        self.play(ShowCreation(arrow))
        self.play(FadeIn(pair))
        self.dither()
        self.play(ShowCreation(number_line))
        self.play(ShowCreation(low_arrow))
        self.play(ShowCreation(grid))
        self.dither()
コード例 #5
0
ファイル: section2.py プロジェクト: yueleicool/manim
    def discontinuous_point(self):
        point_description = TextMobject("Point where the function jumps")
        point_description.shift(3 * RIGHT)
        discontinuous_at_A = TextMobject("``Discontinuous at A''",
                                         size="\\Large")
        discontinuous_at_A.shift(2 * UP).to_edge(LEFT)
        text = TextMobject("""
            Circle around ouput \\\\ 
            points can never \\\\
            be smaller than \\\\
            the jump
        """)
        text.scale(0.75)
        text.shift(3.5 * RIGHT)

        input_value = 0.5
        input_radius = 0.04
        vary_circles = VaryCircles(
            self,
            input_value,
            input_radius,
            run_time=5,
        )
        for dot in self.input_dot, self.output_dot:
            dot.center()
        kwargs = {
            "rate_func": lambda t: interpolate(0.45, input_value, smooth(t))
        }
        self.play(Homotopy(self.input_homotopy, self.input_dot, **kwargs),
                  Homotopy(self.output_homotopy, self.output_dot, **kwargs))
        discontinuous_arrow = Arrow(discontinuous_at_A, self.input_dot)
        arrow = Arrow(point_description,
                      self.output_dot,
                      buff=0.05,
                      color=self.output_color)
        self.play(ShimmerIn(point_description), ShowCreation(arrow))
        self.dither()
        self.remove(point_description, arrow)

        tup = self.get_circles_and_points(input_value - input_radius,
                                          input_value + input_radius)
        input_circle, input_points, output_circle, output_points = tup
        input_points_copy = input_points.copy()
        self.play(ShowCreation(input_circle))
        self.play(ShowCreation(input_points))
        self.play(Transform(input_points_copy, output_points), run_time=2)
        self.play(ShowCreation(output_circle))
        self.dither()
        self.play(ShimmerIn(text))
        self.remove(input_circle, input_points, output_circle,
                    input_points_copy)
        self.play(vary_circles)
        self.dither()
        self.play(ShimmerIn(discontinuous_at_A),
                  ShowCreation(discontinuous_arrow))
        self.dither(3)
        self.remove(vary_circles.mobject, discontinuous_at_A,
                    discontinuous_arrow)
コード例 #6
0
ファイル: section2.py プロジェクト: zhujianing/manim
    def construct(self, order):
        if order == 2:
            result_tex = "(0.125, 0.75)"
        elif order == 3:
            result_tex = "(0.0758,  0.6875)"

        phc, arg, result = TexMobject([
            "\\text{PHC}_%d"%order, 
            "(0.3)", 
            "= %s"%result_tex
        ]).to_edge(UP).split()
        function = TextMobject("Function", size = "\\normal")
        function.shift(phc.get_center()+DOWN+2*LEFT)
        function_arrow = Arrow(function, phc)

        line = Line(5*LEFT, 5*RIGHT)
        curve = HilbertCurve(order = order)
        line.match_colors(curve)
        grid = Grid(2**order, 2**order)
        grid.fade()
        for mob in curve, grid:
            mob.scale(0.7)
        index = int(0.3*line.get_num_points())
        dot1 = Dot(line.points[index])
        arrow1 = Arrow(arg, dot1, buff = 0.1)
        dot2 = Dot(curve.points[index])
        arrow2 = Arrow(result.get_bottom(), dot2, buff = 0.1)

        self.add(phc)
        self.play(
            ShimmerIn(function),
            ShowCreation(function_arrow)
        )
        self.wait()
        self.remove(function_arrow, function)
        self.play(ShowCreation(line))
        self.wait()
        self.play(
            ShimmerIn(arg),
            ShowCreation(arrow1),
            ShowCreation(dot1)
        )
        self.wait()
        self.remove(arrow1)
        self.play(
            FadeIn(grid),            
            Transform(line, curve),
            Transform(dot1, dot2),
            run_time = 2
        )
        self.wait()
        self.play(
            ShimmerIn(result),
            ShowCreation(arrow2)
        )
        self.wait()
コード例 #7
0
ファイル: fractal_porn.py プロジェクト: zhujianing/manim
    def show_change_side_by_side(self):

        seed = TextMobject("Seed")
        seed.shift(3 * LEFT + 2 * DOWN)
        fractal = TextMobject("Fractal")
        fractal.shift(3 * RIGHT + 2 * DOWN)
        words = map(TextMobject, [
            "A sharper angle results in a richer curve",
            "A more obtuse angle gives a sparser curve",
            "And as the angle approaches 0\\dots",
            "We have a new space-filling curve."
        ])
        for text in words:
            text.to_edge(UP)
        sharper, duller, space_filling = [
            CurveClass(order=1).shift(3 * LEFT)
            for CurveClass in SharperKoch, DullerKoch, SpaceFillingKoch
        ]
        shaper_f, duller_f, space_filling_f = [
            CurveClass(order=self.max_order).shift(3 * RIGHT)
            for CurveClass in SharperKoch, DullerKoch, SpaceFillingKoch
        ]

        self.add(words[0])
        left_curve = SharperKoch(order=1)
        right_curve = SharperKoch(order=1)
        self.play(
            Transform(left_curve, sharper),
            ApplyMethod(right_curve.shift, 3 * RIGHT),
        )
        self.play(
            Transform(right_curve,
                      SharperKoch(order=2).shift(3 * RIGHT)), ShimmerIn(seed),
            ShimmerIn(fractal))
        for order in range(3, self.max_order):
            self.play(
                Transform(right_curve,
                          SharperKoch(order=order).shift(3 * RIGHT)))
        self.remove(words[0])
        self.add(words[1])
        kwargs = {
            "run_time": 4,
        }
        self.play(Transform(left_curve, duller, **kwargs),
                  Transform(right_curve, duller_f, **kwargs))
        self.wait()
        kwargs["run_time"] = 7
        kwargs["rate_func"] = None
        self.remove(words[1])
        self.add(words[2])
        self.play(Transform(left_curve, space_filling, **kwargs),
                  Transform(right_curve, space_filling_f, **kwargs))
        self.remove(words[2])
        self.add(words[3])
        self.wait()
コード例 #8
0
ファイル: section2.py プロジェクト: zhujianing/manim
    def construct(self):
        all_points = TextMobject("$f$ is continuous at every input point")
        continuous = TextMobject("$f$ is continuous")
        all_points.shift(UP)
        continuous.shift(DOWN)
        arrow = Arrow(all_points, continuous)

        self.play(ShimmerIn(all_points))
        self.play(ShowCreation(arrow))
        self.play(ShimmerIn(continuous))
        self.wait()
コード例 #9
0
ファイル: section1.py プロジェクト: zhouxiaoxiaoxujian/manim
    def construct(self):
        top_words = TextMobject("Different pixel-frequency association")
        bottom_words = TextMobject("Need to relearn sight-via-sound")
        top_words.shift(UP)
        bottom_words.shift(DOWN)
        arrow = Arrow(top_words, bottom_words)

        self.play(ShimmerIn(top_words))
        self.dither()
        self.play(ShowCreation(arrow))
        self.play(ShimmerIn(bottom_words))
        self.dither()
コード例 #10
0
ファイル: section1.py プロジェクト: zhouxiaoxiaoxujian/manim
    def construct(self):
        mathy, bubble = get_mathy_and_bubble()
        squiggle_mouth = mathy.mouth.copy()
        squiggle_mouth.apply_function(
            lambda (x, y, z) : (x, y+0.02*np.sin(50*x), z)
        )
        bubble.ingest_submobjects()        
        bubble.write("Why not use a Hilbert curve \\textinterrobang ")
        words1 = bubble.content
        bubble.write("So, it's not one curve but an infinite family of curves \\dots")
        words2 = bubble.content
        bubble.write("Well, no, it \\emph{is} just one thing, but I need \\\\ \
                      to tell you about a certain infinite family first.")
        words3 =  bubble.content
        description = TextMobject("Mathematician friend", size = "\\small")
        description.next_to(mathy, buff = 2)
        arrow = Arrow(description, mathy)

        self.add(mathy)
        self.play(
            ShowCreation(arrow),
            ShimmerIn(description)
        )
        self.dither()
        point = Point(bubble.get_tip())
        self.play(
            Transform(point, bubble),
        )
        self.remove(point)
        self.add(bubble)
        self.play(ShimmerIn(words1))
        self.dither()
        self.remove(description, arrow)
        self.play(
            Transform(mathy.mouth, squiggle_mouth),
            ApplyMethod(mathy.arm.wag, 0.2*RIGHT, LEFT),
        )
        self.remove(words1)
        self.add(words2)
        self.dither(2)
        self.remove(words2)
        self.add(words3)
        self.dither(2)
        self.play(
            ApplyPointwiseFunction(
                lambda p : 15*p/np.linalg.norm(p),
                bubble
            ),
            ApplyMethod(mathy.shift, 5*(DOWN+LEFT)),
            FadeOut(words3),
            run_time = 3
        )
コード例 #11
0
ファイル: section2.py プロジェクト: yueleicool/manim
 def label_spaces(self):
     input_space = TextMobject("Input Space")
     input_space.to_edge(UP)
     input_space.shift(LEFT * SPACE_WIDTH / 2)
     output_space = TextMobject("Output Space")
     output_space.to_edge(UP)
     output_space.shift(RIGHT * SPACE_WIDTH / 2)
     line = Line(UP * SPACE_HEIGHT, DOWN * SPACE_HEIGHT, color=WHITE)
     self.play(
         ShimmerIn(input_space),
         ShimmerIn(output_space),
         ShowCreation(line),
         ShowCreation(self.interval),
     )
     self.dither()
コード例 #12
0
ファイル: section3.py プロジェクト: zhujianing/manim
    def finite_analog(self, left_mob, arrow, right_mob):
        self.clear()
        self.add(left_mob, arrow, right_mob)
        ex = TextMobject("\\times")
        ex.highlight(RED)
        # ex.shift(arrow.get_center())
        middle = TexMobject("\\sum_{n=0}^N 2^n \\equiv -1 \\mod 2^{N+1}")
        finite_analog = TextMobject("Finite analog")
        finite_analog.scale(0.8)
        brace = Brace(middle, UP)
        finite_analog.next_to(brace, UP)
        new_left = left_mob.copy().to_edge(LEFT)
        new_right = right_mob.copy().to_edge(RIGHT)
        left_arrow, right_arrow = [
            Arrow(mob1.get_right()[0] * RIGHT,
                  mob2.get_left()[0] * RIGHT,
                  buff=0)
            for mob1, mob2 in [(new_left, middle), (middle, new_right)]
        ]
        for mob in ex, middle:
            mob.sort_points(np.linalg.norm)

        self.play(GrowFromCenter(ex))
        self.wait()
        self.play(Transform(left_mob, new_left),
                  Transform(arrow.copy(), left_arrow),
                  DelayByOrder(Transform(ex, middle)),
                  Transform(arrow, right_arrow),
                  Transform(right_mob, new_right))
        self.play(GrowFromCenter(brace), ShimmerIn(finite_analog))
        self.wait()
        self.equivalence(left_mob, left_arrow,
                         Mobject(middle, brace, finite_analog))
コード例 #13
0
ファイル: section3.py プロジェクト: zhujianing/manim
    def construct(self):
        scale_factor = 0.9
        grid = Grid(4, 4, stroke_width=1)
        curve = HilbertCurve(order=2)
        for mob in grid, curve:
            mob.scale(scale_factor)
        words = TextMobject("""
            Sequence of curves is stable 
            $\\leftrightarrow$ existence of limit curve
        """,
                            size="\\normal")
        words.scale(1.25)
        words.to_edge(UP)

        self.add(curve, grid)
        self.wait()
        for n in range(3, 7):
            if n == 5:
                self.play(ShimmerIn(words))
            new_grid = Grid(2**n, 2**n, stroke_width=1)
            new_curve = HilbertCurve(order=n)
            for mob in new_grid, new_curve:
                mob.scale(scale_factor)
            self.play(ShowCreation(new_grid), Animation(curve))
            self.remove(grid)
            grid = new_grid
            self.play(Transform(curve, new_curve))
            self.wait()
コード例 #14
0
ファイル: fractal_porn.py プロジェクト: zhujianing/manim
    def show_angles(self):
        words = TextMobject("""
            Let's see what happens as we change
            the angle in this seed
        """)
        words.to_edge(UP)
        koch, sharper_koch, duller_koch = curves = [
            CurveClass(order=1)
            for CurveClass in StraightKoch, SharperKoch, DullerKoch
        ]
        arcs = [
            Arc(2 * (np.pi / 2 - curve.angle),
                radius=r,
                start_angle=np.pi + curve.angle).shift(
                    curve.points[curve.get_num_points() / 2])
            for curve, r in zip(curves, [0.6, 0.7, 0.4])
        ]
        theta = TexMobject("\\theta")
        theta.shift(arcs[0].get_center() + 2.5 * DOWN)
        arrow = Arrow(theta, arcs[0])

        self.add(words, koch)
        self.play(ShowCreation(arcs[0]))
        self.play(ShowCreation(arrow), ShimmerIn(theta))
        self.wait(2)
        self.remove(theta, arrow)
        self.play(
            Transform(koch, duller_koch),
            Transform(arcs[0], arcs[2]),
        )
        self.play(
            Transform(koch, sharper_koch),
            Transform(arcs[0], arcs[1]),
        )
        self.clear()
コード例 #15
0
ファイル: section2.py プロジェクト: yueleicool/manim
    def construct(self):
        mathy, bubble = get_mathy_and_bubble()
        bubble.write("A Hilbert curve is the \\\\ limit of all these \\dots")

        self.add(mathy, bubble)
        self.play(ShimmerIn(bubble.content))
        self.dither()
コード例 #16
0
ファイル: section2.py プロジェクト: yueleicool/manim
    def construct(self):
        curve = PeanoCurve(order=5)
        curve.stretch_to_fit_width(2 * SPACE_WIDTH)
        curve.stretch_to_fit_height(2 * SPACE_HEIGHT)
        curve_start = curve.copy()
        curve_start.apply_over_attr_arrays(lambda arr: arr[:200])
        time_line = get_time_line()
        time_line.shift(-time_line.number_to_point(2000))

        self.add(time_line)
        self.play(
            ApplyMethod(time_line.shift,
                        -time_line.number_to_point(1900),
                        run_time=3))
        brace = Brace(
            Mobject(
                Point(time_line.number_to_point(1865)),
                Point(time_line.number_to_point(1888)),
            ), UP)
        words = TextMobject("""
            Cantor drives himself (and the \\\\
            mathematical community at large) \\\\
            crazy with research on infinity.
        """)
        words.next_to(brace, UP)
        self.play(GrowFromCenter(brace), ShimmerIn(words))
        self.dither()
        self.play(Transform(time_line, curve_start), FadeOut(brace),
                  FadeOut(words))
        self.play(ShowCreation(curve, run_time=5, rate_func=None))
        self.dither()
コード例 #17
0
ファイル: section1.py プロジェクト: zhouxiaoxiaoxujian/manim
    def show_infinite_objects(self):
        sigma, summand, equals, result = TexMobject([
            "\\sum_{n = 1}^{\\infty}",
            "\\dfrac{1}{n^2}",
            "=",
            "\\dfrac{\pi^2}{6}"
        ]).split()
        alt_summand = TexMobject("n").replace(summand)
        alt_result = TexMobject("-\\dfrac{1}{12}").replace(result)

        rationals, other_equals, naturals = TexMobject([
            "|\\mathds{Q}|",
            "=",
            "|\\mathds{N}|"
        ]).scale(2).split()
        infinity = TexMobject("\\infty").scale(2)
        local_mobjects = filter(
            lambda m : isinstance(m, Mobject),
            locals().values(),
        )
        for mob in local_mobjects:    
            mob.sort_points(np.linalg.norm)

        self.play(ShimmerIn(infinity))
        self.dither()
        self.play(
            ShimmerIn(summand),
            ShimmerIn(equals),
            ShimmerIn(result),
            DelayByOrder(Transform(infinity, sigma))
        )
        self.dither()
        self.play(
            Transform(summand, alt_summand),
            Transform(result, alt_result),
        )
        self.dither()
        self.remove(infinity)
        self.play(*[
            CounterclockwiseTransform(
                Mobject(summand, equals, result, sigma),
                Mobject(rationals, other_equals, naturals)
            )
        ])
        self.dither()
        self.clear()
        self.add(self.bubble)
コード例 #18
0
ファイル: drawing_images.py プロジェクト: zhujianing/manim
    def construct(self):
        names = [
            "Johann_Bernoulli2", "Jacob_Bernoulli",
            "Gottfried_Wilhelm_von_Leibniz", "Newton"
        ]
        guys = [ImageMobject(name, invert=False) for name in names]
        johann = guys[0]
        johann.scale(0.8)
        pensive_johann = johann.copy()
        pensive_johann.scale(0.25)
        pensive_johann.to_corner(DOWN + LEFT)
        comparitive_johann = johann.copy()
        template = Square(side_length=2)
        comparitive_johann.replace(template)
        comparitive_johann.shift(UP + LEFT)
        greater_than = TexMobject(">")
        greater_than.next_to(comparitive_johann)
        for guy, name in zip(guys, names)[1:]:
            guy.replace(template)
            guy.next_to(greater_than)
            name_mob = TextMobject(name.replace("_", " "))
            name_mob.scale(0.5)
            name_mob.next_to(guy, DOWN)
            guy.name_mob = name_mob
            guy.sort_points(lambda p: np.dot(p, DOWN + RIGHT))
        bubble = ThoughtBubble(initial_width=12)
        bubble.stretch_to_fit_height(6)
        bubble.ingest_submobjects()
        bubble.pin_to(pensive_johann)
        bubble.shift(DOWN)
        point = Point(johann.get_corner(UP + RIGHT))
        upper_point = Point(comparitive_johann.get_corner(UP + RIGHT))
        lightbulb = ImageMobject("Lightbulb", invert=False)
        lightbulb.scale(0.1)
        lightbulb.sort_points(np.linalg.norm)
        lightbulb.next_to(upper_point, RIGHT)

        self.add(johann)
        self.wait()
        self.play(Transform(johann, pensive_johann),
                  Transform(point, bubble),
                  run_time=2)
        self.remove(point)
        self.add(bubble)
        weakling = guys[1]
        self.play(FadeIn(comparitive_johann), ShowCreation(greater_than),
                  FadeIn(weakling))
        self.wait(2)
        for guy in guys[2:]:
            self.play(DelayByOrder(Transform(weakling, upper_point)))
            self.play(FadeIn(guy), ShimmerIn(guy.name_mob))
            self.wait(3)
            self.remove(guy.name_mob)
            weakling = guy
        self.play(FadeOut(weakling), FadeOut(greater_than))
        self.play(ShowCreation(lightbulb))
        self.wait()
        self.play(FadeOut(comparitive_johann), FadeOut(lightbulb))
        self.play(ApplyMethod(Mobject(johann, bubble).scale, 10, run_time=3))
コード例 #19
0
ファイル: section1.py プロジェクト: zhouxiaoxiaoxujian/manim
    def construct(self):
        grid = get_grid()
        grid.sort_points(np.linalg.norm)        
        freq_line = get_freq_line()
        freq_line.sort_points(lambda p : p[0])
        red, blue = Color(RED), Color(BLUE)
        freq_line.gradient_highlight(red, blue)

        colors = [
            Color(rgb = interpolate(
                np.array(red.rgb),
                np.array(blue.rgb),
                alpha
            ))
            for alpha in np.arange(4)/3.
        ]
        string = Line(3*LEFT, 3*RIGHT, color = colors[1])
        vibration = Vibrate(string)
        vibration_copy = vibration.copy()
        vibration_copy.mobject.stroke_width = 1
        sub_vibrations = [
            Vibrate(
                string.copy().shift((n-1)*UP).highlight(colors[n]),
                overtones = 1,
                spatial_period = 6./(n+1),
                temporal_period = 1./(n+1),
                amplitude = 0.5/(n+1)
            )
            for n in range(4)
        ]
        words = TexMobject("&\\vdots \\\\ \\text{thousands }& \\text{of frequencies} \\\\ &\\vdots")
        words.to_edge(UP, buff = 0.1)

        self.add(grid)
        self.dither()
        self.play(DelayByOrder(ApplyMethod(
            grid.gradient_highlight, red, blue
        )))
        self.play(Transform(grid, freq_line))
        self.dither()
        self.play(
            ShimmerIn(
                words,
                rate_func = squish_rate_func(smooth, 0, 0.2)
            ),
            *sub_vibrations,
            run_time = 5
        )
        self.play(
            *[
                TransformAnimations(
                    sub_vib, vibration
                )
                for sub_vib in sub_vibrations
            ]+[FadeOut(words)]
        )
        self.clear()
        self.add(freq_line)
        self.play(vibration)
コード例 #20
0
ファイル: section1.py プロジェクト: zhouxiaoxiaoxujian/manim
 def construct(self):
     text = TextMobject("""
         See links in the description for more on
         sight via sound.
     """)
     self.play(ShimmerIn(text))
     self.play(ShowCreation(Arrow(text, 3*DOWN)))
     self.dither(2)
コード例 #21
0
ファイル: section2.py プロジェクト: yueleicool/manim
 def label_jump(self):
     jump_points = Mobject(Point(self.spiril1.points[-1]),
                           Point(self.spiril2.points[0]))
     self.brace = Brace(jump_points, RIGHT)
     self.jump = TextMobject("Jump")
     self.jump.next_to(self.brace, RIGHT)
     self.play(GrowFromCenter(self.brace), ShimmerIn(self.jump))
     self.dither()
     self.remove(self.brace, self.jump)
コード例 #22
0
 def construct(self):
     curve = HilbertCurve(order=1)
     words = TextMobject("``Hilbert Curve''")
     words.to_edge(UP, buff=0.2)
     self.play(ShimmerIn(words),
               Transform(curve, HilbertCurve(order=2)),
               run_time=2)
     for n in range(3, 8):
         self.play(Transform(curve, HilbertCurve(order=n)), run_time=5. / n)
コード例 #23
0
ファイル: section2.py プロジェクト: zhujianing/manim
    def construct(self):
        val = 0.7
        text = TexMobject([
            "\\text{HC}(", "x", ")",
            "=\\lim_{n \\to \\infty}\\text{PHC}_n(", "x", ")"
        ])
        text.to_edge(UP)
        x1 = text.split()[1]
        x2 = text.split()[-2]
        x2.highlight(BLUE)
        explanation = TextMobject("Actual Hilbert curve function")
        exp_arrow = Arrow(explanation, text.split()[0])
        curve = UnitInterval()
        dot = Dot(curve.number_to_point(val))
        x_arrow = Arrow(x1.get_bottom(), dot, buff = 0)
        curve.sort_points(lambda p : p[0])
        curve.add_numbers(0, 1)

        self.add(*text.split()[:3])
        self.play(
            ShimmerIn(explanation),
            ShowCreation(exp_arrow)
        )
        self.wait()
        self.remove(explanation, exp_arrow)
        self.play(ShowCreation(curve))
        self.play(
            ApplyMethod(x1.highlight, BLUE),
            ShowCreation(x_arrow), 
            ShowCreation(dot)
        )
        self.wait()
        self.remove(x_arrow)
        limit = Mobject(*text.split()[3:]).ingest_submobjects()
        limit.stroke_width = 1
        self.play(ShimmerIn(limit))
        for num in range(1, 9):
            new_curve = HilbertCurve(order = num)
            new_curve.scale(0.8)
            new_dot = Dot(new_curve.points[int(val*new_curve.get_num_points())])
            self.play(
                Transform(curve, new_curve),
                Transform(dot, new_dot),
            )
コード例 #24
0
ファイル: section2.py プロジェクト: zhujianing/manim
    def draw_circles(self):
        input_value = 0.45
        input_radius = 0.04
        for dot in self.input_dot, self.output_dot:
            dot.center()
        kwargs = {
            "rate_func" : lambda t : interpolate(1, input_value, smooth(t))
        }
        self.play(
            Homotopy(self.input_homotopy, self.input_dot, **kwargs),
            Homotopy(self.output_homotopy, self.output_dot, **kwargs)
        )

        A, B = map(Mobject.get_center, [self.input_dot, self.output_dot])
        A_text = TextMobject("A")
        A_text.shift(A+2*(LEFT+UP))
        A_arrow = Arrow(
            A_text, self.input_dot,
            color = self.input_color
        )
        B_text = TextMobject("B")
        B_text.shift(B+2*RIGHT+DOWN)
        B_arrow = Arrow(
            B_text, self.output_dot,
            color = self.output_color
        )
        tup = self.get_circles_and_points(
            input_value-input_radius, 
            input_value+input_radius
        )
        input_circle, input_points, output_circle, output_points = tup

        for text, arrow in [(A_text, A_arrow), (B_text, B_arrow)]:
            self.play(
                ShimmerIn(text),
                ShowCreation(arrow)
            )
            self.wait()
        self.remove(A_text, A_arrow, B_text, B_arrow)
        self.play(ShowCreation(input_circle))
        self.wait()
        self.play(ShowCreation(input_points))
        self.wait()
        input_points_copy = input_points.copy()
        self.play(
            Transform(input_points_copy, output_points),
            run_time = 2
        )
        self.wait()
        self.play(ShowCreation(output_circle))
        self.wait()
        self.wait()
        self.remove(*[
            input_circle, input_points, 
            output_circle, input_points_copy
        ])
コード例 #25
0
ファイル: fractal_porn.py プロジェクト: zhujianing/manim
    def construct(self):
        words1 = TextMobject(
            "If you watched my video about Hilbert's space-filling curve\\dots"
        )
        words2 = TextMobject(
            "\\dots you might be curious to see what a few other space-filling curves look like."
        )
        words2.scale(0.8)
        for words in words1, words2:
            words.to_edge(UP, buff=0.2)

        self.setup(HilbertCurve)
        self.play(ShimmerIn(words1))
        for x in range(4):
            self.increase_order()
        self.remove(words1)
        self.increase_order(ShimmerIn(words2))
        for x in range(4):
            self.increase_order()
コード例 #26
0
ファイル: section2.py プロジェクト: zhujianing/manim
    def construct(self):
        time_line = get_time_line()
        time_line.shift(-time_line.number_to_point(1900))
        hilbert_curve = HilbertCurve(order = 3)
        peano_curve = PeanoCurve(order = 2)
        for curve in hilbert_curve, peano_curve:
            curve.scale(0.5)
        hilbert_curve.to_corner(DOWN+RIGHT)
        peano_curve.to_corner(UP+LEFT)
        squares = Mobject(*[
            Square(side_length=3, color=WHITE).replace(curve)
            for curve in hilbert_curve, peano_curve
        ])


        self.add(time_line)
        self.wait()
        for year, curve, vect, text in [
            (1890, peano_curve, UP, "Peano Curve"), 
            (1891, hilbert_curve, DOWN, "Hilbert Curve"),
            ]:
            point = time_line.number_to_point(year)
            point[1] = 0.2
            arrow = Arrow(point+2*vect, point, buff = 0.1)
            arrow.gradient_highlight(curve.start_color, curve.end_color)
            year_mob = TexMobject(str(year))
            year_mob.next_to(arrow, vect)
            words = TextMobject(text)
            words.next_to(year_mob, vect)

            self.play(
                ShowCreation(arrow), 
                ShimmerIn(year_mob),
                ShimmerIn(words)
            )
            self.play(ShowCreation(curve))
            self.wait()
        self.play(ShowCreation(squares))
        self.wait()
        self.play(ApplyMethod(
            Mobject(*self.mobjects).shift, 20*(DOWN+RIGHT)
        ))
コード例 #27
0
    def pose_question(self):
        infinity, rightarrow, N = TexMobject(["\\infty", "\\rightarrow",
                                              "N"]).scale(2).split()
        question_mark = TextMobject("?").scale(2)

        self.add(question_mark)
        self.dither()
        self.play(*[ShimmerIn(mob) for mob in infinity, rightarrow, N] + [
            ApplyMethod(question_mark.next_to, rightarrow, UP),
        ])
        self.dither()
コード例 #28
0
    def construct(self):
        grid = Grid(16, 16).fade()
        snake_curve = SnakeCurve(order=4)
        words = TextMobject("``Snake Curve''")
        words.next_to(grid, UP)

        self.add(grid)
        self.play(ShowCreation(snake_curve, run_time=7, rate_func=None))
        self.dither()
        self.play(ShimmerIn(words))
        self.dither()
コード例 #29
0
ファイル: section2.py プロジェクト: zhujianing/manim
    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()
コード例 #30
0
    def construct(self):
        freq_line = get_freq_line()

        self.add(freq_line)
        self.dither()
        for tex, vect in zip(["20 Hz", "20{,}000 Hz"], [LEFT, RIGHT]):
            tex_mob = TextMobject(tex)
            tex_mob.to_edge(vect)
            tex_mob.shift(UP)
            arrow = Arrow(tex_mob, freq_line.get_edge_center(vect))
            self.play(ShimmerIn(tex_mob), ShowCreation(arrow))
        self.dither()