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


Python TexMobject.center方法代码示例

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


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

示例1: generate_points

# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import center [as 别名]
 def generate_points(self):
     self.cell_height = self.height / self.nrows
     self.cell_width = self.width / self.nrows
     self.bottom_left = (self.cell_width * self.nrows / 2.0)*LEFT + \
                        (self.cell_height * self.nrows / 2.0)*DOWN
     num_to_num_mob   = {} 
     self.coords_to_mobs   = {}
     self.coords = [
         (n, k) 
         for n in range(self.nrows) 
         for k in range(n+1)
     ]
     for n, k in self.coords:
         num = choose(n, k)              
         center = self.coords_to_center(n, k)
         num_mob = TexMobject(str(num))
         scale_factor = min(
             1,
             self.portion_to_fill * self.cell_height / num_mob.get_height(),
             self.portion_to_fill * self.cell_width / num_mob.get_width(),
         )
         num_mob.center().scale(scale_factor).shift(center)
         if n not in self.coords_to_mobs:
             self.coords_to_mobs[n] = {}
         self.coords_to_mobs[n][k] = num_mob
     self.add(*[
         self.coords_to_mobs[n][k] 
         for n, k in self.coords
     ])
     return self
开发者ID:GodotMisogi,项目名称:manim,代码行数:32,代码来源:combinatorics.py

示例2: construct

# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import center [as 别名]
    def construct(self):
        CycloidScene.construct(self)
        equations = TexMobject([
            "x(t) = Rt - R\\sin(t)",
            "y(t) = -R + R\\cos(t)"
        ])
        top, bottom = equations.split()
        bottom.next_to(top, DOWN)
        equations.center()
        equations.to_edge(UP, buff = 1.3)

        self.play(ShimmerIn(equations))
        self.grow_parts()
        self.draw_cycloid(rate_func = None, run_time = 5)
        self.dither()
开发者ID:GodotMisogi,项目名称:manim,代码行数:17,代码来源:cycloid.py

示例3: generate_n_choose_k_mobs

# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import center [as 别名]
 def generate_n_choose_k_mobs(self):
     self.coords_to_n_choose_k = {}
     for n, k in self.coords:
         nck_mob = TexMobject(r"{%d \choose %d}"%(n, k)) 
         scale_factor = min(
             1,
             self.portion_to_fill * self.cell_height / nck_mob.get_height(),
             self.portion_to_fill * self.cell_width / nck_mob.get_width(),
         )
         center = self.coords_to_mobs[n][k].get_center()
         nck_mob.center().scale(scale_factor).shift(center)
         if n not in self.coords_to_n_choose_k:
             self.coords_to_n_choose_k[n] = {}
         self.coords_to_n_choose_k[n][k] = nck_mob
     return self
开发者ID:GodotMisogi,项目名称:manim,代码行数:17,代码来源:combinatorics.py

示例4: count_mobjects

# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import center [as 别名]
    def count_mobjects(
        self, mobjects, mode = "highlight",
        color = "red", 
        display_numbers = True,
        num_offset = DEFAULT_COUNT_NUM_OFFSET,
        run_time   = DEFAULT_COUNT_RUN_TIME):
        """
        Note, leaves final number mobject as "number" attribute

        mode can be "highlight", "show_creation" or "show", otherwise
        a warning is given and nothing is animating during the count
        """
        if len(mobjects) > 50: #TODO
            raise Exception("I don't know if you should be counting \
                             too many mobjects...")
        if len(mobjects) == 0:
            raise Exception("Counting mobject list of length 0")
        if mode not in ["highlight", "show_creation", "show"]:
            raise Warning("Unknown mode")
        frame_time = run_time / len(mobjects)
        if mode == "highlight":
            self.add(*mobjects)
        for mob, num in zip(mobjects, it.count(1)):
            if display_numbers:
                num_mob = TexMobject(str(num))
                num_mob.center().shift(num_offset)
                self.add(num_mob)
            if mode == "highlight":
                original_color = mob.color
                mob.highlight(color)
                self.dither(frame_time)
                mob.highlight(original_color)
            if mode == "show_creation":
                self.play(ShowCreation(mob, run_time = frame_time))
            if mode == "show":
                self.add(mob)
                self.dither(frame_time)
            if display_numbers:
                self.remove(num_mob)
        if display_numbers:
            self.add(num_mob)
            self.number = num_mob
        return self
开发者ID:GodotMisogi,项目名称:manim,代码行数:45,代码来源:combinatorics.py

示例5: FlipThroughSymbols

# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import center [as 别名]
class FlipThroughSymbols(Animation):
    CONFIG = {
        "start_center" : ORIGIN,
        "end_center" : ORIGIN,
    }
    def __init__(self, tex_list, **kwargs):
        mobject = TexMobject(self.curr_tex).shift(start_center)
        Animation.__init__(self, mobject, **kwargs)

    def update_mobject(self, alpha):
        new_tex = self.tex_list[np.ceil(alpha*len(self.tex_list))-1]

        if new_tex != self.curr_tex:
            self.curr_tex = new_tex
            self.mobject = TexMobject(new_tex).shift(self.start_center)
        if not all(self.start_center == self.end_center):
            self.mobject.center().shift(
                (1-alpha)*self.start_center + alpha*self.end_center
            )
开发者ID:GodotMisogi,项目名称:manim,代码行数:21,代码来源:arithmetic.py

示例6: count_regions

# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import center [as 别名]
 def count_regions(self, regions, 
                   mode = "one_at_a_time",
                   num_offset = DEFAULT_COUNT_NUM_OFFSET,
                   run_time   = DEFAULT_COUNT_RUN_TIME,
                   **unused_kwargsn):
     if mode not in ["one_at_a_time", "show_all"]:
         raise Warning("Unknown mode")
     frame_time = run_time / (len(regions))
     for region, count in zip(regions, it.count(1)):
         num_mob = TexMobject(str(count))
         num_mob.center().shift(num_offset)
         self.add(num_mob)
         self.highlight_region(region)
         self.dither(frame_time)
         if mode == "one_at_a_time":
             self.reset_background()
         self.remove(num_mob)
     self.add(num_mob)
     self.number = num_mob
     return self
开发者ID:GodotMisogi,项目名称:manim,代码行数:22,代码来源:combinatorics.py

示例7: ask_continuous_question

# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import center [as 别名]
    def ask_continuous_question(self):
        continuous = self.get_continuous_background()
        line = Line(
            UP, DOWN,
            density = self.zoom_factor*DEFAULT_POINT_DENSITY_1D
        )
        theta = TexMobject("\\theta")
        theta.scale(0.5/self.zoom_factor)

        self.play(
            ShowCreation(continuous),
            Animation(self.equation)
        )
        self.remove(*self.layers)
        self.play(ShowCreation(self.cycloid))
        self.activate_zooming()
        little_square = self.get_zoomed_camera_mobject()

        self.add(line)
        indices = np.arange(
            0, self.cycloid.get_num_points()-1, 10
        )
        for index in indices:
            point = self.cycloid.points[index]
            next_point = self.cycloid.points[index+1]
            angle = angle_of_vector(point - next_point)
            for mob in little_square, line:
                mob.shift(point - mob.get_center())
            arc = Arc(angle-np.pi/2, start_angle = np.pi/2)
            arc.scale(0.1)
            arc.shift(point)
            self.add(arc)
            if angle > np.pi/2 + np.pi/6:
                vect_angle = interpolate(np.pi/2, angle, 0.5)
                vect = rotate_vector(RIGHT, vect_angle)
                theta.center()
                theta.shift(point)
                theta.shift(0.15*vect)
                self.add(theta)
            self.dither(self.frame_duration)
            self.remove(arc)
开发者ID:GodotMisogi,项目名称:manim,代码行数:43,代码来源:graveyard.py

示例8: get_marks

# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import center [as 别名]
 def get_marks(self, point1, point2):
     vert_line = Line(2*DOWN, 2*UP)
     tangent_line = vert_line.copy()
     theta = TexMobject("\\theta")
     theta.scale(0.5)
     angle = angle_of_vector(point1 - point2)
     tangent_line.rotate(
         angle - tangent_line.get_angle()
     )
     angle_from_vert = angle - np.pi/2
     for mob in vert_line, tangent_line:
         mob.shift(point1 - mob.get_center())
     arc = Arc(angle_from_vert, start_angle = np.pi/2)
     arc.scale(self.arc_radius)
     arc.shift(point1)
     vect_angle = angle_from_vert/2 + np.pi/2
     vect = rotate_vector(RIGHT, vect_angle)
     theta.center()
     theta.shift(point1)
     theta.shift(1.5*self.arc_radius*vect)
     return arc, theta, vert_line, tangent_line
开发者ID:GodotMisogi,项目名称:manim,代码行数:23,代码来源:multilayered.py


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