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


Python TexMobject.scale方法代码示例

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


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

示例1: construct

# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import scale [as 别名]
    def construct(self):
        v_tex = "\\vec{\\textbf{v}}"
        eq = TexMobject("A", v_tex, "=", "\\lambda", v_tex)
        eq.highlight_by_tex(v_tex, YELLOW)
        eq.highlight_by_tex("\\lambda", MAROON_B)
        eq.scale(3)
        eq.add_background_rectangle()
        eq.shift(2*DOWN)        

        title = TextMobject(
            "Eigen", "vectors \\\\",
            "Eigen", "values"
        , arg_separator = "")
        title.scale(2.5)
        title.to_edge(UP)
        # title.highlight_by_tex("Eigen", MAROON_B)
        title[0].highlight(YELLOW)
        title[2].highlight(MAROON_B)
        title.add_background_rectangle()


        self.add_vector([-1, 1], color = YELLOW, animate = False)
        self.apply_transposed_matrix([[3, 0], [1, 2]])        
        self.plane.fade()
        self.remove(self.j_hat)
        self.add(eq, title)
开发者ID:aquafemi,项目名称:manim,代码行数:28,代码来源:thumbnails.py

示例2: show_proportionality_to_dx_squared

# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import scale [as 别名]
    def show_proportionality_to_dx_squared(self):
        ddf = self.ddf.copy()
        ddf.generate_target()
        ddf.target.next_to(self.ddf, UP, LARGE_BUFF)
        rhs = TexMobject(
            "\\approx", "(\\text{Some constant})", "(dx)^2"
        )
        rhs.scale(0.8)
        rhs.next_to(ddf.target, RIGHT)

        example_dx = TexMobject(
            "dx = 0.01 \\Rightarrow (dx)^2 = 0.0001"
        )
        example_dx.scale(0.8)
        example_dx.to_corner(UP+RIGHT)

        self.play(MoveToTarget(ddf))
        self.play(Write(rhs))
        self.dither()
        self.play(Write(example_dx))
        self.dither(2)
        self.play(FadeOut(example_dx))

        self.ddf = ddf
        self.dx_squared = rhs.get_part_by_tex("dx")
开发者ID:PythonJedi,项目名称:manim,代码行数:27,代码来源:footnote.py

示例3: get_vector_label

# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import scale [as 别名]
    def get_vector_label(self, vector, label, 
                         direction = "left", 
                         rotate = False,
                         color = None, 
                         label_scale_factor = VECTOR_LABEL_SCALE_FACTOR):
        if not isinstance(label, TexMobject):
            if len(label) == 1:
                label = "\\vec{\\textbf{%s}}"%label
            label = TexMobject(label)
            if color is None:
                color = vector.get_color()
            label.highlight(color)
        label.scale(label_scale_factor)
        label.add_background_rectangle()

        angle = vector.get_angle()
        if not rotate:
            label.rotate(-angle)
        if direction is "left":
            label.shift(-label.get_bottom() + 0.1*UP)
        else:
            label.shift(-label.get_top() + 0.1*DOWN)
        label.rotate(angle)
        label.shift((vector.get_end() - vector.get_start())/2)
        return label
开发者ID:scottopell,项目名称:manim,代码行数:27,代码来源:two_d_space.py

示例4: add_polygons

# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import scale [as 别名]
    def add_polygons(self):
        a = self.i_hat.get_end()[0]*RIGHT
        b = self.j_hat.get_end()[0]*RIGHT
        c = self.i_hat.get_end()[1]*UP
        d = self.j_hat.get_end()[1]*UP

        shapes_colors_and_tex = [
            (Polygon(ORIGIN, a, a+c), TEAL, "bd/2"),
            (Polygon(ORIGIN, d+b, d), TEAL, "\\dfrac{bd}{2}"),
            (Polygon(a+c, a+b+c, a+b+c+d), MAROON, "\\dfrac{ac}{2}"),
            (Polygon(b+d, a+b+c+d, b+c+d), MAROON, "ac/2"),
            (Polygon(a, a+b, a+b+c, a+c), PINK, "bc"),
            (Polygon(d, d+b, d+b+c, d+c), PINK, "bc"),
        ]
        everyone = VMobject()
        for shape, color, tex in shapes_colors_and_tex:
            shape.set_stroke(width = 0)
            shape.set_fill(color = color, opacity = 0.7)
            tex_mob = TexMobject(tex)
            tex_mob.scale(0.7)
            tex_mob.move_to(shape.get_center_of_mass())
            everyone.add(shape, tex_mob)
        self.play(FadeIn(
            everyone, 
            submobject_mode = "lagged_start",
            run_time = 1
        ))
开发者ID:xhrwang,项目名称:manim,代码行数:29,代码来源:chapter5.py

示例5: construct

# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import scale [as 别名]
    def construct(self):
        derivative = TexMobject(
            "\\frac{d(a^t)}{dt} =", "a^t \\ln(a)"
        )
        derivative[0][3].highlight(YELLOW)
        derivative[1][1].highlight(YELLOW)
        derivative[0][2].highlight(BLUE)
        derivative[1][0].highlight(BLUE)
        derivative[1][5].highlight(BLUE)
        derivative.scale(3)
        # derivative.to_edge(UP)
        derivative.shift(DOWN)

        brace = Brace(Line(LEFT, RIGHT), UP)
        brace.scale_to_fit_width(derivative[1].get_width())
        brace.next_to(derivative[1], UP)
        question = TextMobject("Why?")
        question.scale(2.5)
        question.next_to(brace, UP)

        # randy = Randolph()
        # randy.scale(1.3)
        # randy.next_to(ORIGIN, LEFT).to_edge(DOWN)
        # randy.change_mode("pondering")

        # question = TextMobject("What is $e\\,$?")
        # e = question[-2]
        # e.scale(1.2, about_point = e.get_bottom())
        # e.highlight(BLUE)
        # question.scale(1.7)
        # question.next_to(randy, RIGHT, aligned_edge = UP)
        # question.shift(DOWN)
        # randy.look_at(question)

        self.add(derivative, brace, question)
开发者ID:crclayton,项目名称:manim,代码行数:37,代码来源:chapter4.py

示例6: construct

# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import scale [as 别名]
    def construct(self):
        pascals_triangle = PascalsTriangle()
        pascals_triangle.scale(0.5)
        final_triangle = PascalsTriangle()
        final_triangle.fill_with_n_choose_k()
        pascals_triangle.to_corner(UP+LEFT)
        final_triangle.scale(0.7)
        final_triangle.to_edge(UP)
        equation = TexMobject([
            "{n \\choose k}",
            " = \\dfrac{n!}{(n-k)!k!}"
        ])
        equation.scale(0.5)
        equation.to_corner(UP+RIGHT)
        n_choose_k, formula = equation.split()
        words = TextMobject("Seemingly unrelated")
        words.shift(2*DOWN)
        to_remove = VMobject(*words.split()[:-7])

        self.add(pascals_triangle, n_choose_k, formula)
        self.play(Write(words))
        self.dither()
        self.play(
            Transform(pascals_triangle, final_triangle),
            Transform(n_choose_k, final_triangle),
            FadeOut(formula),
            ApplyMethod(to_remove.shift, 5*DOWN)
        )
        self.dither()
开发者ID:GodotMisogi,项目名称:manim,代码行数:31,代码来源:intro.py

示例7: get_subdivision_braces_and_labels

# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import scale [as 别名]
    def get_subdivision_braces_and_labels(
        self, parts, labels, direction,
        buff = SMALL_BUFF,
        min_num_quads = 1
        ):
        label_mobs = VGroup()
        braces = VGroup()
        for label, part in zip(labels, parts):
            brace = Brace(
                part, direction, 
                min_num_quads = min_num_quads, 
                buff = buff
            )
            if isinstance(label, Mobject):
                label_mob = label
            else:
                label_mob = TexMobject(label)
                label_mob.scale(self.default_label_scale_val)
            label_mob.next_to(brace, direction, buff)

            braces.add(brace)
            label_mobs.add(label_mob)
        parts.braces = braces
        parts.labels = label_mobs
        parts.label_kwargs = {
            "labels" : label_mobs.copy(),
            "direction" : direction, 
            "buff" : buff,
        }
        return VGroup(parts.braces, parts.labels)
开发者ID:PythonJedi,项目名称:manim,代码行数:32,代码来源:probability.py

示例8: show_geometry

# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import scale [as 别名]
    def show_geometry(self, slider, vector):
        point_a = self.point_a.get_center()
        horiz_line = Line(point_a, point_a + 6*RIGHT)
        ceil_point = point_a
        ceil_point[0] = slider.get_center()[0]
        vert_brace = Brace(
            Mobject(Point(ceil_point), Point(slider.get_center())),
            RIGHT,
            buff = 0.5
        )
        vect_brace = Brace(slider)
        vect_brace.stretch_to_fit_width(vector.get_length())
        vect_brace.rotate(np.arctan(vector.get_slope()))
        vect_brace.center().shift(vector.get_center())
        nudge = 0.2*(DOWN+LEFT)
        vect_brace.shift(nudge)
        y_mob = TexMobject("y")
        y_mob.next_to(vert_brace)
        sqrt_y = TexMobject("k\\sqrt{y}")
        sqrt_y.scale(0.5)
        sqrt_y.shift(vect_brace.get_center())
        sqrt_y.shift(3*nudge)

        self.play(ShowCreation(horiz_line))
        self.play(
            GrowFromCenter(vert_brace),
            ShimmerIn(y_mob)
        )
        self.play(
            GrowFromCenter(vect_brace),
            ShimmerIn(sqrt_y)
        )
        self.dither(3)
        self.solve_energy()
开发者ID:GodotMisogi,项目名称:manim,代码行数:36,代码来源:curves.py

示例9: construct

# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import scale [as 别名]
 def construct(self):
     for char, color in zip(["\\imath", "\\jmath", "k"], [X_COLOR, Y_COLOR, Z_COLOR]):
         sym = TexMobject("{\\hat{%s}}"%char)
         sym.scale(3)
         sym.highlight(color)
         self.play(Write(sym))
         self.dither()
         self.clear()
开发者ID:PythonJedi,项目名称:manim,代码行数:10,代码来源:footnote.py

示例10: construct

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

示例11: add_brackets

# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import scale [as 别名]
 def add_brackets(self):
     bracket_pair = TexMobject("\\big[ \\big]")
     bracket_pair.scale(2)
     bracket_pair.stretch_to_fit_height(self.get_height() + 0.5)
     l_bracket, r_bracket = bracket_pair.split()
     l_bracket.next_to(self, LEFT)
     r_bracket.next_to(self, RIGHT)
     self.add(l_bracket, r_bracket)
     self.brackets = VMobject(l_bracket, r_bracket)
     return self
开发者ID:namkam5,项目名称:manim,代码行数:12,代码来源:matrix.py

示例12: construct

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

示例13: isolate_bend_points

# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import scale [as 别名]
    def isolate_bend_points(self):
        arc_radius = 0.1
        self.activate_zooming()
        little_square = self.get_zoomed_camera_mobject()

        for index in range(3):
            bend_point = self.bend_points[index]
            line = Line(
                bend_point+DOWN, 
                bend_point+UP,
                color = WHITE,
                density = self.zoom_factor*DEFAULT_POINT_DENSITY_1D
            )
            angle_arcs = []
            for i, rotation in [(index, np.pi/2), (index+1, -np.pi/2)]:
                arc = Arc(angle = self.path_angles[i])
                arc.scale(arc_radius)
                arc.rotate(rotation)
                arc.shift(bend_point)
                angle_arcs.append(arc)
            thetas = []
            for i in [index+1, index+2]:
                theta = TexMobject("\\theta_%d"%i)
                theta.scale(0.5/self.zoom_factor)
                vert = UP if i == index+1 else DOWN
                horiz = rotate_vector(vert, np.pi/2)
                theta.next_to(
                    Point(bend_point), 
                    horiz, 
                    buff = 0.01
                )
                theta.shift(1.5*arc_radius*vert)
                thetas.append(theta)
            figure_marks = [line] + angle_arcs + thetas                

            self.play(ApplyMethod(
                little_square.shift,
                bend_point - little_square.get_center(),
                run_time = 2
            ))
            self.play(*map(ShowCreation, figure_marks))
            self.dither()
            equation_frame = little_square.copy()
            equation_frame.scale(0.5)
            equation_frame.shift(
                little_square.get_corner(UP+RIGHT) - \
                equation_frame.get_corner(UP+RIGHT)
            )
            equation_frame.scale_in_place(0.9)
            self.show_snells(index+1, equation_frame)
            self.remove(*figure_marks)
        self.disactivate_zooming()
开发者ID:GodotMisogi,项目名称:manim,代码行数:54,代码来源:graveyard.py

示例14: get_number_mob

# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import scale [as 别名]
 def get_number_mob(self, num):
     result = VGroup()
     place = 0
     max_place = self.max_place
     while place < max_place:
         digit = TexMobject(str(self.get_place_num(num, place)))
         if place >= len(self.digit_place_colors):
             self.digit_place_colors += self.digit_place_colors
         digit.highlight(self.digit_place_colors[place])
         digit.scale(self.num_scale_factor)
         digit.next_to(result, LEFT, buff = SMALL_BUFF, aligned_edge = DOWN)
         result.add(digit)
         place += 1
     return result
开发者ID:PythonJedi,项目名称:manim,代码行数:16,代码来源:counting.py

示例15: get_number_mobjects

# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import scale [as 别名]
 def get_number_mobjects(self, *numbers):
     # TODO, handle decimals
     if len(numbers) == 0:
         numbers = self.default_numbers_to_display()
     result = []
     for number in numbers:
         mob = TexMobject(str(int(number)))
         vert_scale = 2 * self.tick_size / mob.get_height()
         hori_scale = self.tick_frequency * self.unit_length_to_spatial_width / mob.get_width()
         mob.scale(min(vert_scale, hori_scale))
         mob.shift(self.number_to_point(number))
         mob.shift(self.get_vertical_number_offset())
         result.append(mob)
     return result
开发者ID:Rubixdarcy,项目名称:manim,代码行数:16,代码来源:number_line.py


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