当前位置: 首页>>代码示例>>Python>>正文


Python TextMobject.scale方法代码示例

本文整理汇总了Python中mobject.tex_mobject.TextMobject.scale方法的典型用法代码示例。如果您正苦于以下问题:Python TextMobject.scale方法的具体用法?Python TextMobject.scale怎么用?Python TextMobject.scale使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mobject.tex_mobject.TextMobject的用法示例。


在下文中一共展示了TextMobject.scale方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: construct

# 需要导入模块: from mobject.tex_mobject import TextMobject [as 别名]
# 或者: from mobject.tex_mobject.TextMobject import scale [as 别名]
    def construct(self):
        scale_factor = 0.9
        grid = Grid(4, 4, point_thickness = 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.dither()
        for n in range(3, 7):
            if n == 5:
                self.play(ShimmerIn(words))
            new_grid = Grid(2**n, 2**n, point_thickness = 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.dither()
开发者ID:Rubixdarcy,项目名称:manim,代码行数:32,代码来源:section3.py

示例2: construct

# 需要导入模块: from mobject.tex_mobject import TextMobject [as 别名]
# 或者: from mobject.tex_mobject.TextMobject import scale [as 别名]
    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.dither()
        self.play(Transform(intro, prove_that))
        for item in items[1:-1]:
            self.play(ShimmerIn(item))
            self.dither()
开发者ID:Rubixdarcy,项目名称:manim,代码行数:36,代码来源:section2.py

示例3: construct

# 需要导入模块: from mobject.tex_mobject import TextMobject [as 别名]
# 或者: from mobject.tex_mobject.TextMobject import scale [as 别名]
    def construct(self):
        name = TextMobject("Steven Strogatz")
        name.to_edge(UP)
        contributions = TextMobject("Frequent Contributions")
        contributions.scale(0.5).to_edge(RIGHT).shift(2*UP)
        books_word = TextMobject("Books")
        books_word.scale(0.5).to_edge(LEFT).shift(2*UP)
        radio_lab, sci_fri, cornell, book2, book3, book4 = [
            ImageMobject(filename, invert = False, filter_color = WHITE)
            for filename in [
                "radio_lab",
                "science_friday",
                "cornell",
                "strogatz_book2",
                "strogatz_book3",
                "strogatz_book4",
            ]
        ]
        book1 = ImageMobject("strogatz_book1", invert = False)
        nyt = ImageMobject("new_york_times")
        logos = [radio_lab, nyt, sci_fri]
        books = [book1, book2, book3, book4]

        sample_size = Square(side_length = 2)
        last = contributions        
        for image in logos:
            image.replace(sample_size)
            image.next_to(last, DOWN)
            last = image
        sci_fri.scale_in_place(0.9)
        shift_val = 0
        sample_size.scale(0.75)
        for book in books:
            book.replace(sample_size)
            book.next_to(books_word, DOWN)
            book.shift(shift_val*(RIGHT+DOWN))
            shift_val += 0.5
        sample_size.scale(2)
        cornell.replace(sample_size)
        cornell.next_to(name, DOWN)

        self.add(name)
        self.play(FadeIn(cornell))
        self.play(ShimmerIn(books_word))
        for book in books:
            book.shift(5*LEFT)
            self.play(ApplyMethod(book.shift, 5*RIGHT))
        self.play(ShimmerIn(contributions))
        for logo in logos:
            self.play(FadeIn(logo))
        self.dither()
开发者ID:GodotMisogi,项目名称:manim,代码行数:53,代码来源:wordplay.py

示例4: finite_analog

# 需要导入模块: from mobject.tex_mobject import TextMobject [as 别名]
# 或者: from mobject.tex_mobject.TextMobject import scale [as 别名]
    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.dither()
        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.dither()
        self.equivalence(
            left_mob,
            left_arrow, 
            Mobject(middle, brace, finite_analog)
        )
开发者ID:Rubixdarcy,项目名称:manim,代码行数:50,代码来源:section3.py

示例5: label

# 需要导入模块: from mobject.tex_mobject import TextMobject [as 别名]
# 或者: from mobject.tex_mobject.TextMobject import scale [as 别名]
 def label(self, text, time = 5):
     mob = TextMobject(text)
     mob.scale(1.5)
     mob.to_edge(UP)
     rectangle = region_from_polygon_vertices(*[
         mob.get_corner(vect) + 0.3*vect
         for vect in [
             UP+RIGHT,
             UP+LEFT,
             DOWN+LEFT,
             DOWN+RIGHT
         ]
     ])
     mob.highlight(self.text_color)
     rectangle = MobjectFromRegion(rectangle, "#111111")
     rectangle.point_thickness = 3
     self.add(rectangle, mob)
     self.dither(time)
     self.remove(mob, rectangle)
开发者ID:Rubixdarcy,项目名称:manim,代码行数:21,代码来源:fluid_flow.py

示例6: construct

# 需要导入模块: from mobject.tex_mobject import TextMobject [as 别名]
# 或者: from mobject.tex_mobject.TextMobject import scale [as 别名]
    def construct(self):
        words1 = TextMobject("""
            But of course, there's no reason we should limit 
            ourselves to filling in squares.
        """)
        words2 = TextMobject("""
            Here's a simple triangle-filling curve I defined
            in a style reflective of a Hilbert curve.
        """)
        words1.to_edge(UP)
        words2.scale(0.8).to_edge(UP, buff = 0.2)

        self.setup(TriangleFillingCurve)
        self.play(ShimmerIn(words1))
        for x in range(3):
            self.increase_order()
        self.remove(words1)
        self.add(words2)
        for x in range(5):
            self.increase_order()
开发者ID:GodotMisogi,项目名称:manim,代码行数:22,代码来源:fractal_porn.py

示例7: construct

# 需要导入模块: from mobject.tex_mobject import TextMobject [as 别名]
# 或者: from mobject.tex_mobject.TextMobject import scale [as 别名]
    def construct(self):
        horiz_radius = 5
        vert_radius = 3

        vert_axis = NumberLine(numerical_radius = vert_radius)
        vert_axis.rotate(np.pi/2)
        vert_axis.shift(horiz_radius*LEFT)
        horiz_axis = NumberLine(
            numerical_radius = 5,
            numbers_with_elongated_ticks = []
        )
        axes = Mobject(horiz_axis, vert_axis)
        graph = FunctionGraph(
            lambda x : 0.4*(x-2)*(x+2)+3,
            x_min = -2,
            x_max = 2,
            density = 3*DEFAULT_POINT_DENSITY_1D
        )
        graph.stretch_to_fit_width(2*horiz_radius)
        graph.highlight(YELLOW)
        min_point = Dot(graph.get_bottom())
        nature_finds = TextMobject("Nature finds this point")
        nature_finds.scale(0.5)
        nature_finds.highlight(GREEN)
        nature_finds.shift(2*RIGHT+3*UP)
        arrow = Arrow(
            nature_finds.get_bottom(), min_point, 
            color = GREEN
        )

        side_words_start = TextMobject("Parameter describing")
        top_words, last_side_words = [
            map(TextMobject, pair)
            for pair in [
                ("Light's travel time", "Potential energy"),
                ("path", "mechanical state")
            ]
        ]
        for word in top_words + last_side_words + [side_words_start]:
            word.scale(0.7)
        side_words_start.next_to(horiz_axis, DOWN)
        side_words_start.to_edge(RIGHT)
        for words in top_words:
            words.next_to(vert_axis, UP)
            words.to_edge(LEFT)
        for words in last_side_words:
            words.next_to(side_words_start, DOWN)
        for words in top_words[1], last_side_words[1]:
            words.highlight(RED)

        self.add(
            axes, top_words[0], side_words_start, 
            last_side_words[0]
        )
        self.play(ShowCreation(graph))
        self.play(
            ShimmerIn(nature_finds),
            ShowCreation(arrow),
            ShowCreation(min_point)
        )
        self.dither()
        self.play(
            FadeOut(top_words[0]), 
            FadeOut(last_side_words[0]),
            GrowFromCenter(top_words[1]), 
            GrowFromCenter(last_side_words[1])
        )
        self.dither(3)
开发者ID:GodotMisogi,项目名称:manim,代码行数:70,代码来源:curves.py

示例8: construct

# 需要导入模块: from mobject.tex_mobject import TextMobject [as 别名]
# 或者: from mobject.tex_mobject.TextMobject import scale [as 别名]
    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.dither()
        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.dither(2)
        for guy in guys[2:]:
            self.play(DelayByOrder(Transform(
                weakling, upper_point
            )))
            self.play(
                FadeIn(guy),
                ShimmerIn(guy.name_mob)
            )
            self.dither(3)
            self.remove(guy.name_mob)
            weakling = guy
        self.play(FadeOut(weakling), FadeOut(greater_than))
        self.play(ShowCreation(lightbulb))
        self.dither()
        self.play(FadeOut(comparitive_johann), FadeOut(lightbulb))
        self.play(ApplyMethod(
            Mobject(johann, bubble).scale, 10,
            run_time = 3
        ))
开发者ID:GodotMisogi,项目名称:manim,代码行数:79,代码来源:drawing_images.py

示例9: construct

# 需要导入模块: from mobject.tex_mobject import TextMobject [as 别名]
# 或者: from mobject.tex_mobject.TextMobject import scale [as 别名]
    def construct(self):
        clock = Circle(radius = 2, color = WHITE)
        clock.add(Dot(ORIGIN))
        ticks = Mobject(*[
            Line(1.8*vect, 2*vect, color = GREY)
            for vect in compass_directions(12)
        ])
        clock.add(ticks)
        hour_hand = Line(ORIGIN, UP)
        minute_hand = Line(ORIGIN, 1.5*UP)
        clock.add(hour_hand, minute_hand)
        clock.to_corner(UP+RIGHT)
        hour_hand.get_center = lambda : clock.get_center()
        minute_hand.get_center = lambda : clock.get_center()
 
        solution = ImageMobject(
            "Newton_brachistochrone_solution2",
            use_cache = False
        )
        solution.stroke_width = 3
        solution.highlight(GREY)
        solution.scale_to_fit_width(5)
        solution.to_corner(UP+RIGHT)
        newton = ImageMobject("Old_Newton", invert = False)
        newton.scale(0.8)
        phil_trans = TextMobject("Philosophical Transactions")
        rect = Rectangle(height = 6, width = 4.5, color = WHITE)
        rect.to_corner(UP+RIGHT)
        rect.shift(DOWN)
        phil_trans.scale_to_fit_width(0.8*rect.get_width())
        phil_trans.next_to(Point(rect.get_top()), DOWN)
        new_solution = solution.copy()
        new_solution.scale_to_fit_width(phil_trans.get_width())
        new_solution.next_to(phil_trans, DOWN, buff = 1)
        not_newton = TextMobject("-Totally not by Newton")
        not_newton.scale_to_fit_width(2.5)
        not_newton.next_to(new_solution, DOWN, aligned_edge = RIGHT)
        phil_trans.add(rect)

        newton_complaint = TextMobject([
            "``I do not love to be",
            " \\emph{dunned} ",
            "and teased by foreigners''"
        ], size = "\\small")
        newton_complaint.to_edge(UP, buff = 0.2)
        dunned = newton_complaint.split()[1]
        dunned.highlight()
        dunned_def = TextMobject("(old timey term for making \\\\ demands on someone)")
        dunned_def.scale(0.7)
        dunned_def.next_to(phil_trans, LEFT)
        dunned_def.shift(2*UP)
        dunned_arrow = Arrow(dunned_def, dunned)

        johann = ImageMobject("Johann_Bernoulli2", invert = False)
        johann.scale(0.4)
        johann.to_edge(LEFT)
        johann.shift(DOWN)
        johann_quote = TextMobject("``I recognize the lion by his claw''")
        johann_quote.next_to(johann, UP, aligned_edge = LEFT)

        self.play(ApplyMethod(newton.to_edge, LEFT))
        self.play(ShowCreation(clock))
        kwargs = {
            "axis" : OUT,
            "rate_func" : smooth
        }
        self.play(
            Rotating(hour_hand, radians = -2*np.pi, **kwargs),
            Rotating(minute_hand, radians = -12*2*np.pi, **kwargs),
            run_time = 5
        )
        self.dither()
        self.clear()
        self.add(newton)
        clock.ingest_submobjects()
        self.play(Transform(clock, solution))
        self.remove(clock)
        self.add(solution)
        self.dither()
        self.play(
            FadeIn(phil_trans),
            Transform(solution, new_solution)
        )
        self.dither()
        self.play(ShimmerIn(not_newton))
        phil_trans.add(solution, not_newton)
        self.dither()
        self.play(*map(ShimmerIn, newton_complaint.split()))
        self.dither()
        self.play(
            ShimmerIn(dunned_def),
            ShowCreation(dunned_arrow)
        )
        self.dither()
        self.remove(dunned_def, dunned_arrow)
        self.play(FadeOut(newton_complaint))
        self.remove(newton_complaint)
        self.play(
            FadeOut(newton),
            GrowFromCenter(johann)
#.........这里部分代码省略.........
开发者ID:GodotMisogi,项目名称:manim,代码行数:103,代码来源:misc.py

示例10: discontinuous_point

# 需要导入模块: from mobject.tex_mobject import TextMobject [as 别名]
# 或者: from mobject.tex_mobject.TextMobject import scale [as 别名]
    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)
开发者ID:Rubixdarcy,项目名称:manim,代码行数:73,代码来源:section2.py


注:本文中的mobject.tex_mobject.TextMobject.scale方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。