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


Python VMobject.shift方法代码示例

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


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

示例1: construct

# 需要导入模块: from mobject.vectorized_mobject import VMobject [as 别名]
# 或者: from mobject.vectorized_mobject.VMobject import shift [as 别名]
    def construct(self):
        v_sum = VMobject(
            Vector([1, 1], color = YELLOW),
            Vector([3, 1], color = BLUE).shift(RIGHT+UP),
            Vector([4, 2], color = GREEN),
        )
        scalar_multiplication = VMobject(
            TexMobject("2 \\cdot "),
            Vector([1, 1]),
            TexMobject("="),
            Vector([2, 2], color = WHITE)
        )
        scalar_multiplication.arrange_submobjects(RIGHT)
        both = VMobject(v_sum, scalar_multiplication)
        both.arrange_submobjects(RIGHT, buff = 1)
        both.shift(2*DOWN)
        self.add(both)

        UpcomingSeriesOfVidoes.construct(self)
        last_video = self.mobjects[-1]
        self.play(ApplyMethod(last_video.highlight, YELLOW))
        self.dither()
        everything = VMobject(*self.mobjects)
        everything.remove(last_video)
        big_last_video = last_video.copy()
        big_last_video.center()
        big_last_video.scale_to_fit_height(2.5*SPACE_HEIGHT)
        big_last_video.set_fill(opacity = 0)
        self.play(
            ApplyMethod(everything.shift, 2*SPACE_WIDTH*LEFT),
            Transform(last_video, big_last_video),
            run_time = 2
        )
开发者ID:namkam5,项目名称:manim,代码行数:35,代码来源:chapter1.py

示例2: construct

# 需要导入模块: from mobject.vectorized_mobject import VMobject [as 别名]
# 或者: from mobject.vectorized_mobject.VMobject import shift [as 别名]
    def construct(self):
        v = TexMobject(self.v_str)
        v.highlight(YELLOW)
        eq = TexMobject("=")
        coords = Matrix(["x", "y", "z"])
        eq2 = eq.copy()
        if self.post_transform:
            L, l_paren, r_paren = map(TexMobject, "L()")
            parens = VMobject(l_paren, r_paren)
            parens.scale(2)
            parens.stretch_to_fit_height(
                coords.get_height()
            )
            VMobject(L, l_paren, coords, r_paren).arrange_submobjects(buff = 0.1)
            coords.submobjects = [L, l_paren] + coords.submobjects + [r_paren]

        lin_comb = VMobject(*map(TexMobject, [
            "x", self.i_str, "+",
            "y", self.j_str, "+",
            "z", self.k_str,
        ]))
        lin_comb.arrange_submobjects(
            RIGHT, buff = 0.1, 
            aligned_edge = ORIGIN if self.post_transform else DOWN
        )
        lin_comb_parts = np.array(lin_comb.split())
        new_x, new_y, new_z = lin_comb_parts[[0, 3, 6]]
        i, j, k = lin_comb_parts[[1, 4, 7]]
        plusses = lin_comb_parts[[2, 5]]
        i.highlight(X_COLOR)
        j.highlight(Y_COLOR)
        k.highlight(Z_COLOR)

        everything = VMobject(v, eq, coords, eq2, lin_comb)
        everything.arrange_submobjects(buff = 0.2)
        everything.scale_to_fit_width(2*SPACE_WIDTH - 1)
        everything.to_edge(DOWN)
        if not self.post_transform:
            lin_comb.shift(0.35*UP)

        self.play(*map(Write, [v, eq, coords]))
        self.dither()
        self.play(
            Transform(
                coords.get_entries().copy(),
                VMobject(new_x, new_y, new_z),
                path_arc = -np.pi,
                submobject_mode = "lagged_start"
            ),
            Write(VMobject(*[eq2, i, j, k] + list(plusses))),
            run_time = 3
        )
        self.dither()
开发者ID:PythonJedi,项目名称:manim,代码行数:55,代码来源:footnote.py

示例3: construct

# 需要导入模块: from mobject.vectorized_mobject import VMobject [as 别名]
# 或者: from mobject.vectorized_mobject.VMobject import shift [as 别名]
    def construct(self):
        self.setup()
        matrix = Matrix(np.array(self.transposed_matrix).transpose())
        matrix.highlight_columns(X_COLOR, Y_COLOR)
        matrix.next_to(ORIGIN, LEFT).to_edge(UP)
        matrix_background = BackgroundRectangle(matrix)
        self.play(ShowCreation(matrix_background), Write(matrix))
        if self.show_square:
            self.add_unit_square(animate = True)
        self.add_foreground_mobject(matrix_background, matrix)
        self.dither()
        self.apply_transposed_matrix([self.transposed_matrix[0], [0, 1]])
        self.apply_transposed_matrix([[1, 0], self.transposed_matrix[1]])
        self.dither()
        if self.show_square:


            bottom_brace = Brace(self.i_hat, DOWN)
            right_brace = Brace(self.square, RIGHT)
            width = TexMobject(str(self.transposed_matrix[0][0]))
            height = TexMobject(str(self.transposed_matrix[1][1]))
            width.next_to(bottom_brace, DOWN)
            height.next_to(right_brace, RIGHT)
            for mob in bottom_brace, width, right_brace, height:
                mob.add_background_rectangle()
                self.play(Write(mob, run_time = 0.5))
            self.dither()

            width_target, height_target = width.copy(), height.copy()
            det = np.linalg.det(self.transposed_matrix)
            times, eq_det = map(TexMobject, ["\\times", "=%d"%det])
            words = TextMobject("New area $=$")
            equation = VMobject(
                words, width_target, times, height_target, eq_det
            )
            equation.arrange_submobjects(RIGHT, buff = 0.2)
            equation.next_to(self.square, UP, aligned_edge = LEFT)
            equation.shift(0.5*RIGHT)
            background_rect = BackgroundRectangle(equation)

            self.play(
                ShowCreation(background_rect),                
                Transform(width.copy(), width_target),
                Transform(height.copy(), height_target),
                *map(Write, [words, times, eq_det])
            )
            self.dither()
开发者ID:xhrwang,项目名称:manim,代码行数:49,代码来源:chapter5.py

示例4: scale_basis_vectors

# 需要导入模块: from mobject.vectorized_mobject import VMobject [as 别名]
# 或者: from mobject.vectorized_mobject.VMobject import shift [as 别名]
    def scale_basis_vectors(self, new_array):
        i_hat, j_hat = self.get_basis_vectors()
        self.add_vector(i_hat)
        i_hat_label = self.label_vector(
            i_hat, "\\hat{\\imath}", 
            color = X_COLOR, 
            label_scale_factor = 1
        )
        self.add_vector(j_hat)
        j_hat_label = self.label_vector(
            j_hat, "\\hat{\\jmath}", 
            color = Y_COLOR, 
            label_scale_factor = 1
        )
        self.dither()

        x, y = new_array.get_mob_matrix().flatten()
        for coord, v, label, factor, shift_right in [
            (x, i_hat, i_hat_label, self.vector_coords[0], False), 
            (y, j_hat, j_hat_label, self.vector_coords[1], True)
            ]:
            faded_v = v.copy().fade(0.7)
            scaled_v = Vector(factor*v.get_end(), color = v.get_color())

            scaled_label = VMobject(coord.copy(), label.copy())
            scaled_label.arrange_submobjects(RIGHT, buff = 0.1)
            scaled_label.move_to(label, DOWN+RIGHT)
            scaled_label.shift((scaled_v.get_end()-v.get_end())/2)
            coord_copy = coord.copy()
            self.play(
                Transform(v.copy(), faded_v),
                Transform(v, scaled_v),
                Transform(VMobject(coord_copy, label), scaled_label),
            )
            self.dither()
            if shift_right:
                group = VMobject(v, coord_copy, label)
                self.play(ApplyMethod(
                    group.shift, self.vector_coords[0]*RIGHT
                ))
        self.dither()
开发者ID:PythonJedi,项目名称:manim,代码行数:43,代码来源:chapter2.py

示例5: construct

# 需要导入模块: from mobject.vectorized_mobject import VMobject [as 别名]
# 或者: from mobject.vectorized_mobject.VMobject import shift [as 别名]
    def construct(self):
        icons = [VideoIcon() for x in range(10)]
        colors = Color(BLUE_A).range_to(BLUE_D, len(icons))
        for icon, color in zip(icons, colors):
            icon.set_fill(color, opacity = 1)
        icons = VMobject(*icons)
        icons.arrange_submobjects(RIGHT)
        icons.to_edge(LEFT)
        icons.shift(UP)
        icons = icons.split()

        def rate_func_creator(offset):
            return lambda a : min(max(2*(a-offset), 0), 1)
        self.play(*[
            FadeIn(
                icon, 
                run_time = 5,
                rate_func = rate_func_creator(offset)
            )
            for icon, offset in zip(icons, np.linspace(0, 0.5, len(icons)))
        ])
        self.dither()
开发者ID:PythonJedi,项目名称:manim,代码行数:24,代码来源:chapter0.py

示例6: series_of_videos

# 需要导入模块: from mobject.vectorized_mobject import VMobject [as 别名]
# 或者: from mobject.vectorized_mobject.VMobject import shift [as 别名]
    def series_of_videos(self, chapters):
        icon = SVGMobject("video_icon")
        icon.center()
        icon.scale_to_fit_width(2*SPACE_WIDTH/12.)
        icon.set_stroke(color = WHITE, width = 0)
        icons = [icon.copy() for chapter in chapters.split()]
        colors = Color(BLUE_A).range_to(BLUE_D, len(icons))
        for icon, color in zip(icons, colors):
            icon.set_fill(color, opacity = 1)
        icons = VMobject(*icons)
        icons.arrange_submobjects(RIGHT)
        icons.to_edge(LEFT)
        icons.shift(UP)

        randy = Randolph()
        randy.to_corner()
        bubble = randy.get_bubble()
        new_icons = icons.copy().scale(0.2)
        bubble.position_mobject_inside(new_icons)

        self.play(Transform(
            chapters, icons,
            path_arc = np.pi/2,
        ))
        self.clear()
        self.add(icons)
        self.play(FadeIn(randy))
        self.play(Blink(randy))
        self.dither()
        self.play(
            ShowCreation(bubble),
            Transform(icons, new_icons)
        )
        self.remove(icons)
        bubble.make_green_screen()
        self.dither()
开发者ID:PythonJedi,项目名称:manim,代码行数:38,代码来源:chapter0.py


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