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


Python TextMobject.highlight方法代码示例

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


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

示例1: construct

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

# 需要导入模块: from mobject.tex_mobject import TextMobject [as 别名]
# 或者: from mobject.tex_mobject.TextMobject import highlight [as 别名]
    def construct(self):
        point_a = 3*LEFT+3*UP
        point_b = 1.5*RIGHT+3*DOWN
        midpoint = ORIGIN

        lines, arcs, thetas = [], [], []
        counter = it.count(1)
        for point in point_a, point_b:
            line = Line(point, midpoint, color = RED_D)
            angle = np.pi/2-np.abs(np.arctan(line.get_slope()))
            arc = Arc(angle, radius = 0.5).rotate(np.pi/2)
            if point is point_b:
                arc.rotate(np.pi)
                line.reverse_points()
            theta = TexMobject("\\theta_%d"%counter.next())
            theta.scale(0.5)
            theta.shift(2*arc.get_center())
            arc.shift(midpoint)
            theta.shift(midpoint)

            lines.append(line)
            arcs.append(arc)
            thetas.append(theta)
        vert_line = Line(2*UP, 2*DOWN)
        vert_line.shift(midpoint)
        path = Mobject(*lines).ingest_submobjects()
        glass = Region(lambda x, y : y < 0, color = BLUE_E)
        self.add(glass)
        equation = TexMobject([
            "\\dfrac{\\sin(\\theta_1)}{v_{\\text{air}}}",
            "=",            
            "\\dfrac{\\sin(\\theta_2)}{v_{\\text{water}}}",
        ])
        equation.to_corner(UP+RIGHT)
        exp1, equals, exp2 = equation.split()
        snells_law = TextMobject("Snell's Law:")
        snells_law.highlight(YELLOW)
        snells_law.to_edge(UP)

        self.play(ShimmerIn(snells_law))
        self.dither()
        self.play(ShowCreation(path))
        self.play(self.photon_run_along_path(path))
        self.dither()
        self.play(ShowCreation(vert_line))
        self.play(*map(ShowCreation, arcs))
        self.play(*map(GrowFromCenter, thetas))
        self.dither()
        self.play(ShimmerIn(exp1))
        self.dither()
        self.play(*map(ShimmerIn, [equals, exp2]))
        self.dither()
开发者ID:PythonJedi,项目名称:manim,代码行数:54,代码来源:light.py

示例3: finite_analog

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

示例4: construct

# 需要导入模块: from mobject.tex_mobject import TextMobject [as 别名]
# 或者: from mobject.tex_mobject.TextMobject import highlight [as 别名]
    def construct(self):
        mathy, bubble = get_mathy_and_bubble()
        bubble.write("For a 256x256 pixel array...")
        words = TextMobject("Order 8 Pseudo-Hilbert Curve")
        words.highlight(GREEN)
        words.to_edge(UP, buff = 0.3)
        curve = HilbertCurve(order = 8)

        self.add(mathy, bubble)
        self.play(ShimmerIn(bubble.content))
        self.dither()
        self.clear()
        self.add(words)
        self.play(ShowCreation(
            curve, run_time = 7, rate_func = None
        ))
        self.dither()
开发者ID:GodotMisogi,项目名称:manim,代码行数:19,代码来源:section1.py

示例5: construct

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

示例6: label

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

示例7: equivalence

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

示例8: get_corner_numbers

# 需要导入模块: from mobject.tex_mobject import TextMobject [as 别名]
# 或者: from mobject.tex_mobject.TextMobject import highlight [as 别名]
    def get_corner_numbers(self, value, symbol):
        value_mob = TextMobject(value)
        width = self.get_width()/self.card_width_to_corner_num_width
        height = self.get_height()/self.card_height_to_corner_num_height
        value_mob.scale_to_fit_width(width)
        value_mob.stretch_to_fit_height(height)
        value_mob.next_to(
            self.get_corner(UP+LEFT), DOWN+RIGHT,
            buff = MED_LARGE_BUFF*width
        )
        value_mob.highlight(symbol.get_color())
        corner_symbol = symbol.copy()
        corner_symbol.scale_to_fit_width(width)
        corner_symbol.next_to(
            value_mob, DOWN, 
            buff = MED_SMALL_BUFF*width
        )
        corner_group = VGroup(value_mob, corner_symbol)
        opposite_corner_group = corner_group.copy()
        opposite_corner_group.rotate(
            np.pi, about_point = self.get_center()
        )

        return VGroup(corner_group, opposite_corner_group)
开发者ID:PythonJedi,项目名称:manim,代码行数:26,代码来源:probability.py

示例9: construct

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

示例10: get_author

# 需要导入模块: from mobject.tex_mobject import TextMobject [as 别名]
# 或者: from mobject.tex_mobject.TextMobject import highlight [as 别名]
 def get_author(self, quote):
     author = TextMobject("-" + self.author)
     author.next_to(quote, DOWN)
     author.highlight(YELLOW)
     return author
开发者ID:PythonJedi,项目名称:manim,代码行数:7,代码来源:common_scenes.py

示例11: show_equation

# 需要导入模块: from mobject.tex_mobject import TextMobject [as 别名]
# 或者: from mobject.tex_mobject.TextMobject import highlight [as 别名]
    def show_equation(self):
        equation = TexMobject([
            "\\left(\\dfrac{1}{\\phantom{v_air}}\\right)",
            "\\sin(\\theta_1)", 
            "=", 
            "\\left(\\dfrac{1}{\\phantom{v_water}}\\right)",
            "\\sin(\\theta_2)"
        ])
        equation.to_corner(UP+RIGHT)
        frac1, sin1, equals, frac2, sin2 = equation.split()
        v_air, v_water = [
            TexMobject("v_{\\text{%s}}"%s, size = "\\Large")
            for s in "air", "water"
        ]
        v_air.next_to(Point(frac1.get_center()), DOWN)
        v_water.next_to(Point(frac2.get_center()), DOWN)
        frac1.add(v_air)
        frac2.add(v_water)
        f1, f2 = [
            TexMobject("F_%d"%d, size = "\\Large") 
            for d in 1, 2
        ]
        f1.next_to(sin1, LEFT)
        f2.next_to(equals, RIGHT)
        sin2_start = sin2.copy().next_to(f2, RIGHT)
        bar1 = TexMobject("\\dfrac{\\qquad}{\\qquad}")
        bar2 = bar1.copy()
        bar1.next_to(sin1, DOWN)
        bar2.next_to(sin2, DOWN)        
        v_air_copy = v_air.copy().next_to(bar1, DOWN)
        v_water_copy = v_water.copy().next_to(bar2, DOWN)
        bars = Mobject(bar1, bar2)
        new_eq = equals.copy().center().shift(bars.get_center())
        snells = TextMobject("Snell's Law")
        snells.highlight(YELLOW)
        snells.shift(new_eq.get_center()[0]*RIGHT)
        snells.shift(UP)

        anims = []
        for mob in f1, sin1, equals, f2, sin2_start:
            anims.append(ShimmerIn(mob))
        self.play(*anims)
        self.dither()
        for f, frac in (f1, frac1), (f2, frac2):
            target = frac.copy().ingest_submobjects()
            also = []
            if f is f2:
                also.append(Transform(sin2_start, sin2))
                sin2 = sin2_start
            self.play(Transform(f, target), *also)
            self.remove(f)
            self.add(frac)
        self.dither()
        self.play(
            FadeOut(frac1),
            FadeOut(frac2),
            Transform(v_air, v_air_copy),
            Transform(v_water, v_water_copy),
            ShowCreation(bars),
            Transform(equals, new_eq)
        )
        self.dither()
        frac1 = Mobject(sin1, bar1, v_air)
        frac2 = Mobject(sin2, bar2, v_water)
        for frac, vect in (frac1, LEFT), (frac2, RIGHT):
            self.play(ApplyMethod(
                frac.next_to, equals, vect
            ))
        self.dither()
        self.play(ShimmerIn(snells))
        self.dither()
开发者ID:PythonJedi,项目名称:manim,代码行数:73,代码来源:light.py

示例12: construct

# 需要导入模块: from mobject.tex_mobject import TextMobject [as 别名]
# 或者: from mobject.tex_mobject.TextMobject import highlight [as 别名]
    def construct(self):
        morty = Mortimer()
        morty.next_to(ORIGIN, DOWN)

        n_patrons = len(self.specific_patrons)
        special_thanks = TextMobject("Special thanks")
        special_thanks.highlight(YELLOW)
        special_thanks.to_edge(UP)

        patreon_logo = PatreonLogo()
        patreon_logo.next_to(morty, UP, buff = MED_LARGE_BUFF)

        left_patrons = VGroup(*map(TextMobject, 
            self.specific_patrons[:n_patrons/2]
        ))
        right_patrons = VGroup(*map(TextMobject, 
            self.specific_patrons[n_patrons/2:]
        ))
        for patrons in left_patrons, right_patrons:
            patrons.arrange_submobjects(
                DOWN, aligned_edge = LEFT,
                buff = 1.5*MED_SMALL_BUFF
            )

        all_patrons = VGroup(left_patrons, right_patrons)
        all_patrons.scale(self.patron_scale_val)
        for patrons, vect in (left_patrons, LEFT), (right_patrons, RIGHT):
            patrons.to_edge(vect, buff = MED_SMALL_BUFF)
            if patrons.get_height() > 2*SPACE_HEIGHT - LARGE_BUFF:
                patrons.to_edge(UP, buff = MED_SMALL_BUFF)

        shift_distance = max(
            0, (all_patrons.get_height() - 2*SPACE_HEIGHT)
        )
        if shift_distance > 0:
            shift_distance += 1
        velocity = shift_distance/9.0
        def get_shift_anim():
            return ApplyMethod(
                all_patrons.shift, velocity*UP,
                rate_func = None
            )

        self.play(
            morty.change_mode, "gracious",
            DrawBorderThenFill(patreon_logo),
        )
        self.play(Write(special_thanks, run_time = 1))
        self.play(
            Write(left_patrons),
            morty.look_at, left_patrons
        )
        self.play(
            Write(right_patrons),
            morty.look_at, right_patrons
        )
        self.play(Blink(morty), get_shift_anim())
        for patrons in left_patrons, right_patrons:
            for index in 0, -1:
                self.play(
                    morty.look_at, patrons[index],
                    get_shift_anim()
                )
                self.play(get_shift_anim())
开发者ID:crclayton,项目名称:manim,代码行数:66,代码来源:common_scenes.py


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