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


Python TextMobject.shift方法代码示例

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


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

示例1: construct

# 需要导入模块: from mobject.tex_mobject import TextMobject [as 别名]
# 或者: from mobject.tex_mobject.TextMobject import shift [as 别名]
    def construct(self):
        logo = ImageMobject("LogoGeneration", invert = False)
        name_mob = TextMobject("3Blue1Brown").center()
        name_mob.highlight("grey")
        name_mob.shift(2*DOWN)
        self.add(name_mob, logo)

        new_text = TextMobject(["with ", "Steven Strogatz"])
        new_text.next_to(name_mob, DOWN)
        self.play(*[
            ShimmerIn(part)
            for part in new_text.split()
        ])
        self.dither()
        with_word, steve = new_text.split()
        steve_copy = steve.copy().center().to_edge(UP)
        # logo.sort_points(lambda p : -np.linalg.norm(p))
        sort_by_color(logo)
        self.play(
            Transform(steve, steve_copy),
            DelayByOrder(Transform(logo, Point())),
            FadeOut(with_word),
            FadeOut(name_mob),
            run_time = 3
        )
开发者ID:GodotMisogi,项目名称:manim,代码行数:27,代码来源:wordplay.py

示例2: snells_law_at_every_point

# 需要导入模块: from mobject.tex_mobject import TextMobject [as 别名]
# 或者: from mobject.tex_mobject.TextMobject import shift [as 别名]
 def snells_law_at_every_point(self, cycloid, chopped_cycloid):
     square = Square(side_length = 0.2, color = WHITE)
     words = TextMobject(["Snell's law ", "everywhere"])
     snells, rest = words.split()
     colon = TextMobject(":")
     words.next_to(square)
     words.shift(0.3*UP)
     combo = Mobject(square, words)
     combo.get_center = lambda : square.get_center()
     new_snells = snells.copy().center().to_edge(UP, buff = 1.5)
     colon.next_to(new_snells)
     colon.shift(0.05*DOWN)
         
     self.play(MoveAlongPath(
         combo, cycloid,
         run_time = 5
     ))
     self.play(MoveAlongPath(
         combo, chopped_cycloid,
         run_time = 4
     ))
     dot = Dot(combo.get_center())
     self.play(Transform(square, dot))
     self.play(
         Transform(snells, new_snells),
         Transform(rest, colon)
     )
     self.dither()
     return colon
开发者ID:GodotMisogi,项目名称:manim,代码行数:31,代码来源:multilayered.py

示例3: construct

# 需要导入模块: from mobject.tex_mobject import TextMobject [as 别名]
# 或者: from mobject.tex_mobject.TextMobject import shift [as 别名]
    def construct(self):
        dated_events = [
            {
                "date" : 1696, 
                "text": "Johann Bernoulli poses Brachistochrone problem",
                "picture" : "Johann_Bernoulli2"
            },
            {
                "date" : 1662, 
                "text" : "Fermat states his principle of least time",
                "picture" : "Pierre_de_Fermat"
            }
        ]
        speical_dates = [2016] + [
            obj["date"] for obj in dated_events
        ]
        centuries = range(1600, 2100, 100)
        timeline = NumberLine(
            numerical_radius = 300,
            number_at_center = 1800,
            unit_length_to_spatial_width = SPACE_WIDTH/100,
            tick_frequency = 10,
            numbers_with_elongated_ticks = centuries
        )
        timeline.add_numbers(*centuries)
        centers = [
            Point(timeline.number_to_point(year))
            for year in speical_dates
        ]
        timeline.add(*centers)
        timeline.shift(-centers[0].get_center())

        self.add(timeline)
        self.dither()
        run_times = iter([3, 1])
        for point, event in zip(centers[1:], dated_events):
            self.play(ApplyMethod(
                timeline.shift, -point.get_center(), 
                run_time = run_times.next()
            ))
            picture = ImageMobject(event["picture"], invert = False)
            picture.scale_to_fit_width(2)
            picture.to_corner(UP+RIGHT)
            event_mob = TextMobject(event["text"])
            event_mob.shift(2*LEFT+2*UP)
            date_mob = TexMobject(str(event["date"]))
            date_mob.scale(0.5)
            date_mob.shift(0.6*UP)
            line = Line(event_mob.get_bottom(), 0.2*UP)
            self.play(
                ShimmerIn(event_mob),
                ShowCreation(line),
                ShimmerIn(date_mob)
            )
            self.play(FadeIn(picture))
            self.dither(3)
            self.play(*map(FadeOut, [event_mob, date_mob, line, picture]))
开发者ID:GodotMisogi,项目名称:manim,代码行数:59,代码来源:misc.py

示例4: draw_circles

# 需要导入模块: from mobject.tex_mobject import TextMobject [as 别名]
# 或者: from mobject.tex_mobject.TextMobject import shift [as 别名]
    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.dither()
        self.remove(A_text, A_arrow, B_text, B_arrow)
        self.play(ShowCreation(input_circle))
        self.dither()
        self.play(ShowCreation(input_points))
        self.dither()
        input_points_copy = input_points.copy()
        self.play(
            Transform(input_points_copy, output_points),
            run_time = 2
        )
        self.dither()
        self.play(ShowCreation(output_circle))
        self.dither()
        self.dither()
        self.remove(*[
            input_circle, input_points, 
            output_circle, input_points_copy
        ])
开发者ID:Rubixdarcy,项目名称:manim,代码行数:58,代码来源:section2.py

示例5: construct

# 需要导入模块: from mobject.tex_mobject import TextMobject [as 别名]
# 或者: from mobject.tex_mobject.TextMobject import shift [as 别名]
    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.dither()
        self.remove(function_arrow, function)
        self.play(ShowCreation(line))
        self.dither()
        self.play(
            ShimmerIn(arg),
            ShowCreation(arrow1),
            ShowCreation(dot1)
        )
        self.dither()
        self.remove(arrow1)
        self.play(
            FadeIn(grid),            
            Transform(line, curve),
            Transform(dot1, dot2),
            run_time = 2
        )
        self.dither()
        self.play(
            ShimmerIn(result),
            ShowCreation(arrow2)
        )
        self.dither()
开发者ID:Rubixdarcy,项目名称:manim,代码行数:58,代码来源:section2.py

示例6: construct

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

示例7: solve_energy

# 需要导入模块: from mobject.tex_mobject import TextMobject [as 别名]
# 或者: from mobject.tex_mobject.TextMobject import shift [as 别名]
    def solve_energy(self):
        loss_in_potential = TextMobject("Loss in potential: ")
        loss_in_potential.shift(2*UP)
        potential = TexMobject("m g y".split())
        potential.next_to(loss_in_potential)
        kinetic = TexMobject([
            "\\dfrac{1}{2}","m","v","^2","="
        ])
        kinetic.next_to(potential, LEFT)
        nudge = 0.1*UP
        kinetic.shift(nudge)
        loss_in_potential.shift(nudge)
        ms = Mobject(kinetic.split()[1], potential.split()[0])
        two = TexMobject("2")
        two.shift(ms.split()[1].get_center())
        half = kinetic.split()[0]
        sqrt = TexMobject("\\sqrt{\\phantom{2mg}}")
        sqrt.shift(potential.get_center())
        nudge = 0.2*LEFT
        sqrt.shift(nudge)
        squared = kinetic.split()[3]
        equals = kinetic.split()[-1]
        new_eq = equals.copy().next_to(kinetic.split()[2])

        self.play(
            Transform(
                Point(loss_in_potential.get_left()),
                loss_in_potential
            ),
            *map(GrowFromCenter, potential.split())
        )
        self.dither(2)
        self.play(
            FadeOut(loss_in_potential),
            GrowFromCenter(kinetic)
        )
        self.dither(2)
        self.play(ApplyMethod(ms.shift, 5*UP))
        self.dither()
        self.play(Transform(
            half, two, 
            path_func = counterclockwise_path()
        ))
        self.dither()
        self.play(
            Transform(
                squared, sqrt, 
                path_func = clockwise_path()
            ),
            Transform(equals, new_eq)
        )
        self.dither(2)
开发者ID:GodotMisogi,项目名称:manim,代码行数:54,代码来源:curves.py

示例8: construct

# 需要导入模块: from mobject.tex_mobject import TextMobject [as 别名]
# 或者: from mobject.tex_mobject.TextMobject import shift [as 别名]
    def construct(self):
        digest_config(self, {})
        ## Usually shouldn't need this...
        self.frame_duration = self.DEFAULT_CONFIG["frame_duration"]
        ##
        digest_config(self, {})
        circle = Circle(
            density = self.circle_density, 
            color   = self.circle_blue
        )
        circle.repeat(self.circle_repeats)
        circle.scale(self.radius)
        sphere = Sphere(
            density = self.sphere_density, 
            color   = self.sphere_blue
        )
        sphere.scale(self.radius)
        sphere.rotate(-np.pi / 7, [1, 0, 0])
        sphere.rotate(-np.pi / 7)
        iris = Mobject()
        iris.interpolate(
            circle, sphere,
            self.interpolation_factor
        )
        for mob, color in [(iris, self.sphere_brown), (circle, self.circle_brown)]:
            mob.highlight(color, lambda (x, y, z) : x < 0 and y > 0)
            mob.highlight(
                "black", 
                lambda point: np.linalg.norm(point) < \
                              self.inner_radius_ratio*self.radius
            )
        name = TextMobject("3Blue1Brown").center()
        name.highlight("grey")
        name.shift(2*DOWN)

        self.play(Transform(
            circle, iris, 
            run_time = self.run_time
        ))
        self.frames = drag_pixels(self.frames)
        self.save_image(IMAGE_DIR)
        self.show_frame()
        self.add(name)
        self.dither()
        print "Dragging pixels..."
开发者ID:astoeckley,项目名称:manim,代码行数:47,代码来源:generate_logo.py

示例9: label_spaces

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

示例10: vary_circle_sizes

# 需要导入模块: from mobject.tex_mobject import TextMobject [as 别名]
# 或者: from mobject.tex_mobject.TextMobject import shift [as 别名]
 def vary_circle_sizes(self):
     input_value = 0.45
     radius = 0.04
     vary_circles = VaryCircles(
         self, input_value, radius, 
         run_time = 5,
     )
     self.play(vary_circles)
     self.dither()
     text = TextMobject("Function is ``Continuous at A''")
     text.shift(2*UP).to_edge(LEFT)
     arrow = Arrow(text, self.input_dot)
     self.play(
         ShimmerIn(text),
         ShowCreation(arrow)
     )
     self.dither()
     self.remove(vary_circles.mobject, text, arrow)
开发者ID:Rubixdarcy,项目名称:manim,代码行数:20,代码来源:section2.py

示例11: construct

# 需要导入模块: from mobject.tex_mobject import TextMobject [as 别名]
# 或者: from mobject.tex_mobject.TextMobject import shift [as 别名]
    def construct(self):
        glass = Region(lambda x, y : y < 0, color = BLUE_E)
        self.generate_start_and_end_points()
        straight = Line(self.start_point, self.end_point)
        slow = TextMobject("Slow")
        slow.rotate(np.arctan(straight.get_slope()))
        slow.shift(straight.points[int(0.7*straight.get_num_points())])
        slow.shift(0.5*DOWN)
        too_long = TextMobject("Too long")
        too_long.shift(UP)
        air = TextMobject("Air").shift(2*UP)
        water = TextMobject("Water").shift(2*DOWN)

        self.add(glass)
        self.play(GrowFromCenter(air))
        self.play(GrowFromCenter(water))
        self.dither()
        self.remove(air, water)
        ShowMultiplePathsScene.construct(self)
        self.play(
            Transform(self.path, straight)
        )
        self.dither()
        self.play(GrowFromCenter(slow))
        self.dither()
        self.remove(slow)
        self.leftmost.ingest_submobjects()
        self.play(Transform(self.path, self.leftmost, run_time = 3))
        self.dither()
        self.play(ShimmerIn(too_long))
        self.dither()
开发者ID:PythonJedi,项目名称:manim,代码行数:33,代码来源:light.py

示例12: equivalence

# 需要导入模块: from mobject.tex_mobject import TextMobject [as 别名]
# 或者: from mobject.tex_mobject.TextMobject import shift [as 别名]
    def equivalence(self, left_mob, arrow, right_mob):
        self.clear()
        self.add(left_mob, arrow, right_mob)
        words = TextMobject("is equivalent to")
        words.shift(0.25*LEFT)
        words.highlight(BLUE)
        new_left = left_mob.copy().shift(RIGHT)
        new_right = right_mob.copy()
        new_right.shift(
            (words.get_right()[0]-\
             right_mob.get_left()[0]+\
             0.5
            )*RIGHT
        )
        for mob in arrow, words:
            mob.sort_points(np.linalg.norm)     

        self.play(
            ApplyMethod(left_mob.shift, RIGHT),
            Transform(arrow, words),
            ApplyMethod(right_mob.to_edge, RIGHT)
        )
        self.dither()
开发者ID:Rubixdarcy,项目名称:manim,代码行数:25,代码来源:section3.py

示例13: construct

# 需要导入模块: from mobject.tex_mobject import TextMobject [as 别名]
# 或者: from mobject.tex_mobject.TextMobject import shift [as 别名]
    def construct(self):
        self.add_cycloid_end_points()
        start = self.point_a.get_center()
        end   = self.point_b.get_center()
        angle = 2*np.pi/3
        path = Arc(angle, radius = 3)
        path.gradient_highlight(RED_D, WHITE)
        radius = Line(ORIGIN, path.points[0])
        randy = Randolph()
        randy.scale(RANDY_SCALE_VAL)
        randy.shift(-randy.get_bottom())
        randy_copy = randy.copy()
        words = TextMobject("Circular paths are good, \\\\ but still not the best")
        words.shift(UP)

        self.play(
            ShowCreation(path),
            ApplyMethod(
                radius.rotate, 
                angle,
                path_func = path_along_arc(angle)
            )
        )
        self.play(FadeOut(radius))
        self.play(
            ApplyMethod(
                path.position_endpoints_on, start, end,
                path_func = path_along_arc(-angle)
            ),
            run_time = 3
        )
        self.adjust_mobject_to_index(randy_copy, 1, path.points)
        self.play(FadeIn(randy_copy))
        self.remove(randy_copy)
        self.slide(randy, path)
        self.play(ShimmerIn(words))
        self.dither()
开发者ID:GodotMisogi,项目名称:manim,代码行数:39,代码来源:curves.py

示例14: discontinuous_point

# 需要导入模块: from mobject.tex_mobject import TextMobject [as 别名]
# 或者: from mobject.tex_mobject.TextMobject import shift [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

示例15: show_change_side_by_side

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


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