• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python vectorized_mobject.VGroup类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: __init__

 def __init__(self, **kwargs):
     digest_config(self, kwargs)
     videos = [VideoIcon() for x in range(self.num_videos)]
     VGroup.__init__(self, *videos, **kwargs)
     self.arrange_submobjects()
     self.scale_to_fit_width(2*SPACE_WIDTH-MED_LARGE_BUFF)
     self.gradient_highlight(*self.gradient_colors)
开发者ID:crclayton,项目名称:manim,代码行数:7,代码来源:objects.py


示例2: __init__

 def __init__(self, mobject, **kwargs):
     VGroup.__init__(self, 
         Line(UP+LEFT, DOWN+RIGHT),
         Line(UP+RIGHT, DOWN+LEFT),
     )
     self.replace(mobject, stretch = True)
     self.set_stroke(self.stroke_color, self.stroke_width)
开发者ID:PythonJedi,项目名称:manim,代码行数:7,代码来源:geometry.py


示例3: PartyHat

class PartyHat(SVGMobject):
    CONFIG = {
        "file_name" : "party_hat",
        "height" : 1.5,
        "pi_creature" : None,
        "stroke_width" : 0,
        "fill_opacity" : 1,
        "propogate_style_to_family" : True,
        "frills_colors" : [MAROON_B, PURPLE],
        "cone_color" : GREEN,
        "dots_colors" : [YELLOW],
    }
    NUM_FRILLS = 7
    NUM_DOTS = 6
    def __init__(self, **kwargs):
        SVGMobject.__init__(self, **kwargs)
        self.scale_to_fit_height(self.height)
        if self.pi_creature is not None:
            self.next_to(self.pi_creature.eyes, UP, buff = 0)

        self.frills = VGroup(*self[:self.NUM_FRILLS])
        self.cone = self[self.NUM_FRILLS]
        self.dots = VGroup(*self[self.NUM_FRILLS+1:])

        self.frills.gradient_highlight(*self.frills_colors)
        self.cone.highlight(self.cone_color)
        self.dots.gradient_highlight(*self.dots_colors)
开发者ID:crclayton,项目名称:manim,代码行数:27,代码来源:objects.py


示例4: __init__

 def __init__(self, integer, **kwargs):
     num_str = str(integer)
     VGroup.__init__(self, *map(TexMobject, num_str), **kwargs)
     self.arrange_submobjects(
         RIGHT, buff = self.digit_buff, aligned_edge = DOWN
     )
     if num_str[0] == "-":
         self[0].next_to(self[1], LEFT, buff = SMALL_BUFF)
开发者ID:PythonJedi,项目名称:manim,代码行数:8,代码来源:numerals.py


示例5: __init__

 def __init__(self, **kwargs):
     possible_values = map(str, range(1, 11)) + ["J", "Q", "K"]
     possible_suits = ["hearts", "diamonds", "spades", "clubs"]
     VGroup.__init__(self, *[
         PlayingCard(value = value, suit = suit, **kwargs)
         for value in possible_values
         for suit in possible_suits
     ])
开发者ID:PythonJedi,项目名称:manim,代码行数:8,代码来源:probability.py


示例6: name_parts

 def name_parts(self):
     self.mouth = self.submobjects[MOUTH_INDEX]
     self.body = self.submobjects[BODY_INDEX]
     self.pupils = VGroup(*[
         self.submobjects[LEFT_PUPIL_INDEX],
         self.submobjects[RIGHT_PUPIL_INDEX]
     ])
     self.eyes = VGroup(*[
         self.submobjects[LEFT_EYE_INDEX],
         self.submobjects[RIGHT_EYE_INDEX]
     ])
     self.parts_named = True
开发者ID:PythonJedi,项目名称:manim,代码行数:12,代码来源:characters.py


示例7: arrange_subparts

 def arrange_subparts(self, *subparts):
     for i, piece in enumerate(subparts):
         piece.rotate(i*np.pi/12)
     p1, p2, p3, p4, p5, p6, p7 = subparts
     center_row = VGroup(p1, p4, p7)
     center_row.arrange_submobjects(RIGHT, buff = 0)
     for p in p2, p3, p5, p6:
         p.scale_to_fit_width(p1.get_width())
     p2.move_to(p1.get_top(), DOWN+LEFT)
     p3.move_to(p1.get_bottom(), UP+LEFT)
     p5.move_to(p4.get_top(), DOWN+LEFT)
     p6.move_to(p4.get_bottom(), UP+LEFT)
开发者ID:PythonJedi,项目名称:manim,代码行数:12,代码来源:fractals.py


示例8: generate_points

    def generate_points(self):
        body = Cube(side_length = 1)
        for dim, scale_factor in enumerate(self.body_dimensions):
            body.stretch(scale_factor, dim = dim)
        body.scale_to_fit_width(self.width)
        body.set_fill(self.shaded_body_color, opacity = 1)
        body.sort_submobjects(lambda p : p[2])
        body[-1].set_fill(self.body_color)
        keyboard = VGroup(*[
            VGroup(*[
                Square(**self.key_color_kwargs)
                for x in range(12-y%2)
            ]).arrange_submobjects(RIGHT, buff = SMALL_BUFF)
            for y in range(4)
        ]).arrange_submobjects(DOWN, buff = MED_SMALL_BUFF)
        keyboard.stretch_to_fit_width(
            self.keyboard_width_to_body_width*body.get_width(),
        )
        keyboard.stretch_to_fit_height(
            self.keyboard_height_to_body_height*body.get_height(),
        )
        keyboard.next_to(body, OUT, buff = 0.1*SMALL_BUFF)
        keyboard.shift(MED_SMALL_BUFF*UP)
        body.add(keyboard)

        screen_plate = body.copy()
        screen_plate.stretch(self.screen_thickness/self.body_dimensions[2], dim = 2)
        screen = Rectangle(
            stroke_width = 0,
            fill_color = BLACK,
            fill_opacity = 1,
        )
        screen.replace(screen_plate, stretch = True)
        screen.scale_in_place(self.screen_width_to_screen_plate_width)
        screen.next_to(screen_plate, OUT, buff = 0.1*SMALL_BUFF)
        screen_plate.add(screen)
        screen_plate.next_to(body, UP, buff = 0)
        screen_plate.rotate(
            self.open_angle, RIGHT, 
            about_point = screen_plate.get_bottom()
        )
        self.screen_plate = screen_plate
        self.screen = screen

        axis = Line(
            body.get_corner(UP+LEFT+OUT),
            body.get_corner(UP+RIGHT+OUT),
            color = BLACK,
            stroke_width = 2
        )
        self.axis = axis

        self.add(body, screen_plate, axis)
        self.rotate(5*np.pi/12, LEFT)
        self.rotate(np.pi/6, DOWN)
开发者ID:crclayton,项目名称:manim,代码行数:55,代码来源:objects.py


示例9: get_number_mob

 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,代码行数:14,代码来源:counting.py


示例10: get_number_mobjects

 def get_number_mobjects(self, *numbers, **kwargs):
     #TODO, handle decimals
     if len(numbers) == 0:
         numbers = self.default_numbers_to_display()
     result = VGroup()
     for number in numbers:
         mob = TexMobject(str(int(number)))
         mob.scale_to_fit_height(3*self.tick_size)
         mob.shift(
             self.number_to_point(number),
             self.get_vertical_number_offset(**kwargs)
         )
         result.add(mob)
     return result
开发者ID:PythonJedi,项目名称:manim,代码行数:14,代码来源:number_line.py


示例11: get_dot_template

 def get_dot_template(self, place):
     #This should be replaced for non-base-10 counting scenes
     down_right = (0.5)*RIGHT + (np.sqrt(3)/2)*DOWN
     dots = VGroup(*[
         Dot(
             point, 
             radius = 0.25,
             fill_opacity = 0,
             stroke_width = 2,
             stroke_color = WHITE,
         )
         for point in self.get_template_configuration(place)
     ])
     dots.scale_to_fit_height(self.dot_configuration_height)
     return dots
开发者ID:PythonJedi,项目名称:manim,代码行数:15,代码来源:counting.py


示例12: get_division_along_dimension

    def get_division_along_dimension(self, p_list, dim, colors, vect):
        p_list = self.complete_p_list(p_list)
        colors = color_gradient(colors, len(p_list))

        last_point = self.full_space.get_edge_center(-vect)
        parts = VGroup()
        for factor, color in zip(p_list, colors):
            part = SampleSpace()
            part.set_fill(color, 1)
            part.replace(self.full_space, stretch = True)
            part.stretch(factor, dim)
            part.move_to(last_point, -vect)
            last_point = part.get_edge_center(vect)
            parts.add(part)
        return parts
开发者ID:PythonJedi,项目名称:manim,代码行数:15,代码来源:probability.py


示例13: get_order_n_self

    def get_order_n_self(self, order):
        if order == 0:
            result = self.get_seed_shape()
        else:
            lower_order = self.get_order_n_self(order - 1)
            subparts = [
                lower_order.copy()
                for x in range(self.num_subparts)
            ]
            self.arrange_subparts(*subparts)
            result = VGroup(*subparts)

        result.scale_to_fit_height(self.height)
        result.center()
        return result
开发者ID:PythonJedi,项目名称:manim,代码行数:15,代码来源:fractals.py


示例14: setup

    def setup(self):
        self.dots = VGroup()
        self.number = 0        
        self.max_place = 0
        self.number_mob = VGroup(TexMobject(str(self.number)))
        self.number_mob.scale(self.num_scale_factor)
        self.number_mob.shift(self.num_start_location)

        self.dot_templates = []
        self.dot_template_iterators = []
        self.curr_configurations = []

        self.arrows = VGroup()

        self.add(self.number_mob)
开发者ID:PythonJedi,项目名称:manim,代码行数:15,代码来源:counting.py


示例15: get_axis_labels

 def get_axis_labels(self, x_label = "x", y_label = "y"):
     x_axis, y_axis = self.get_axes().split()
     quads = [
         (x_axis, x_label, UP, RIGHT),
         (y_axis, y_label, RIGHT, UP),
     ]
     labels = VGroup()
     for axis, tex, vect, edge in quads:
         label = TexMobject(tex)
         label.add_background_rectangle()
         label.next_to(axis, vect)
         label.to_edge(edge)
         labels.add(label)
     self.axis_labels = labels
     return labels
开发者ID:PythonJedi,项目名称:manim,代码行数:15,代码来源:number_line.py


示例16: get_riemann_rectangles

    def get_riemann_rectangles(
        self, 
        graph,
        x_min = None, 
        x_max = None, 
        dx = 0.1, 
        input_sample_type = "left",
        stroke_width = 1,
        stroke_color = BLACK,
        fill_opacity = 1,
        start_color = None,
        end_color = None,
        show_signed_area = True,
        width_scale_factor = 1.001
        ):
        x_min = x_min if x_min is not None else self.x_min
        x_max = x_max if x_max is not None else self.x_max
        if start_color is None:
            start_color = self.default_riemann_start_color
        if end_color is None:
            end_color = self.default_riemann_end_color
        rectangles = VGroup()
        x_range = np.arange(x_min, x_max, dx) 
        colors = color_gradient([start_color, end_color], len(x_range))
        for x, color in zip(x_range, colors):
            if input_sample_type == "left":
                sample_input = x
            elif input_sample_type == "right":
                sample_input = x+dx
            else:
                raise Exception("Invalid input sample type")
            graph_point = self.input_to_graph_point(sample_input, graph)
            points = VGroup(*map(VectorizedPoint, [
                self.coords_to_point(x, 0),
                self.coords_to_point(x+width_scale_factor*dx, 0),
                graph_point
            ]))

            rect = Rectangle()
            rect.replace(points, stretch = True)
            if graph_point[1] < self.graph_origin[1] and show_signed_area:
                fill_color = invert_color(color)
            else:
                fill_color = color
            rect.set_fill(fill_color, opacity = fill_opacity)
            rect.set_stroke(stroke_color, width = stroke_width)
            rectangles.add(rect)
        return rectangles
开发者ID:PythonJedi,项目名称:manim,代码行数:48,代码来源:graph_scene.py


示例17: get_riemann_rectangles

    def get_riemann_rectangles(
        self, 
        graph,
        x_min = None, 
        x_max = None, 
        dx = 0.1, 
        input_sample_type = "left",
        stroke_width = 1,
        start_color = BLUE,
        end_color = GREEN):
        x_min = x_min if x_min is not None else self.x_min
        x_max = x_max if x_max is not None else self.x_max
        rectangles = VGroup()
        for x in np.arange(x_min, x_max, dx):
            if input_sample_type == "left":
                sample_input = x
            elif input_sample_type == "right":
                sample_input = x+dx
            else:
                raise Exception("Invalid input sample type")
            graph_point = self.input_to_graph_point(sample_input, graph)
            points = VGroup(*map(VectorizedPoint, [
                self.coords_to_point(x, 0),
                self.coords_to_point(x+dx, 0),
                graph_point
            ]))

            rect = Rectangle()
            rect.replace(points, stretch = True)
            rect.set_fill(opacity = 1)
            rectangles.add(rect)
        rectangles.gradient_highlight(start_color, end_color)
        rectangles.set_stroke(BLACK, width = stroke_width)
        return rectangles
开发者ID:crclayton,项目名称:manim,代码行数:34,代码来源:graph_scene.py


示例18: get_subdivision_braces_and_labels

    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,代码行数:30,代码来源:probability.py


示例19: get_number_design

    def get_number_design(self, value, symbol):
        num = int(value)
        n_rows = {
            2 : 2, 
            3 : 3, 
            4 : 2, 
            5 : 2, 
            6 : 3, 
            7 : 3, 
            8 : 3, 
            9 : 4, 
            10 : 4,
        }[num]
        n_cols = 1 if num in [2, 3] else 2
        insertion_indices = {
            5 : [0], 
            7 : [0], 
            8 : [0, 1], 
            9 : [1], 
            10 : [0, 2],
        }.get(num, [])

        top = self.get_top() + symbol.get_height()*DOWN
        bottom = self.get_bottom() + symbol.get_height()*UP
        column_points = [
            interpolate(top, bottom, alpha)
            for alpha in np.linspace(0, 1, n_rows)
        ]

        design = VGroup(*[
            symbol.copy().move_to(point)
            for point in column_points
        ])
        if n_cols == 2:
            space = 0.2*self.get_width()
            column_copy = design.copy().shift(space*RIGHT)
            design.shift(space*LEFT)
            design.add(*column_copy)
        design.add(*[
            symbol.copy().move_to(
                center_of_mass(column_points[i:i+2])
            )
            for i in insertion_indices
        ])
        for symbol in design:
            if symbol.get_center()[1] < self.get_center()[1]:
                symbol.rotate_in_place(np.pi)
        return design
开发者ID:PythonJedi,项目名称:manim,代码行数:48,代码来源:probability.py


示例20: __init__

    def __init__(self, **kwargs):
        circle = Circle()
        ticks = []
        for x in range(12):
            alpha = x/12.
            point = complex_to_R3(
                np.exp(2*np.pi*alpha*complex(0, 1))
            )
            length = 0.2 if x%3 == 0 else 0.1
            ticks.append(
                Line(point, (1-length)*point)
            )
        self.hour_hand = Line(ORIGIN, 0.3*UP)
        self.minute_hand = Line(ORIGIN, 0.6*UP)
        # for hand in self.hour_hand, self.minute_hand:
        #     #Balance out where the center is
        #     hand.add(VectorizedPoint(-hand.get_end()))

        VGroup.__init__(
            self, circle, 
            self.hour_hand, self.minute_hand,
            *ticks
        )
开发者ID:aquafemi,项目名称:manim,代码行数:23,代码来源:objects.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python vectorized_mobject.VMobject类代码示例发布时间:2022-05-27
下一篇:
Python tex_mobject.TextMobject类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap