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


Python VMobject.set_stroke方法代码示例

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


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

示例1: RightHand

# 需要导入模块: from mobject.vectorized_mobject import VMobject [as 别名]
# 或者: from mobject.vectorized_mobject.VMobject import set_stroke [as 别名]
class RightHand(VMobject):
    def __init__(self, **kwargs):
        hand = SVGMobject("RightHandOutline")
        self.inlines = VMobject(*hand.split()[:-4])
        self.outline = VMobject(*hand.split()[-4:])
        self.outline.set_stroke(color = WHITE, width = 5)
        self.inlines.set_stroke(color = DARK_GREY, width = 3)
        VMobject.__init__(self, self.outline, self.inlines)
        self.center().scale_to_fit_height(3)
开发者ID:xhrwang,项目名称:manim,代码行数:11,代码来源:chapter5.py

示例2: NumberPlane

# 需要导入模块: from mobject.vectorized_mobject import VMobject [as 别名]
# 或者: from mobject.vectorized_mobject.VMobject import set_stroke [as 别名]
class NumberPlane(VMobject):
    CONFIG = {
        "color" : BLUE_D,
        "secondary_color" : BLUE_E,
        "axes_color" : WHITE,
        "secondary_stroke_width" : 1,
        "x_radius": None,
        "y_radius": None,
        "x_unit_size" : 1,
        "y_unit_size" : 1,
        "center_point" : ORIGIN,
        "x_line_frequency" : 1,
        "y_line_frequency" : 1,
        "secondary_line_ratio" : 1,
        "written_coordinate_height" : 0.2,
        "propogate_style_to_family" : False,
    }
    
    def generate_points(self):
        if self.x_radius is None:
            center_to_edge = (SPACE_WIDTH + abs(self.center_point[0])) 
            self.x_radius = center_to_edge / self.x_unit_size
        if self.y_radius is None:
            center_to_edge = (SPACE_HEIGHT + abs(self.center_point[1])) 
            self.y_radius = center_to_edge / self.y_unit_size
        self.axes = VMobject()
        self.main_lines = VMobject()
        self.secondary_lines = VMobject()
        tuples = [
            (
                self.x_radius, 
                self.x_line_frequency, 
                self.y_radius*DOWN, 
                self.y_radius*UP,
                RIGHT
            ),
            (
                self.y_radius, 
                self.y_line_frequency, 
                self.x_radius*LEFT, 
                self.x_radius*RIGHT,
                UP,
            ),
        ]
        for radius, freq, start, end, unit in tuples:
            main_range = np.arange(0, radius, freq)
            step = freq/float(freq + self.secondary_line_ratio)
            for v in np.arange(0, radius, step):
                line1 = Line(start+v*unit, end+v*unit)
                line2 = Line(start-v*unit, end-v*unit)                
                if v == 0:
                    self.axes.add(line1)
                elif v in main_range:
                    self.main_lines.add(line1, line2)
                else:
                    self.secondary_lines.add(line1, line2)
        self.add(self.secondary_lines, self.main_lines, self.axes)
        self.stretch(self.x_unit_size, 0)
        self.stretch(self.y_unit_size, 1)
        self.shift(self.center_point)
        #Put x_axis before y_axis
        y_axis, x_axis = self.axes.split()
        self.axes = VMobject(x_axis, y_axis)

    def init_colors(self):
        VMobject.init_colors(self)
        self.axes.set_stroke(self.axes_color, self.stroke_width)
        self.main_lines.set_stroke(self.color, self.stroke_width)
        self.secondary_lines.set_stroke(
            self.secondary_color, self.secondary_stroke_width
        )
        return self

    def get_center_point(self):
        return self.coords_to_point(0, 0)

    def coords_to_point(self, x, y):
        x, y = np.array([x, y])
        result = self.axes.get_center()
        result += x*self.get_x_unit_size()*RIGHT
        result += y*self.get_y_unit_size()*UP
        return result

    def point_to_coords(self, point):
        new_point = point - self.axes.get_center()
        x = new_point[0]/self.get_x_unit_size()
        y = new_point[1]/self.get_y_unit_size()
        return x, y

    def get_x_unit_size(self):
        return self.axes.get_width() / (2.0*self.x_radius)

    def get_y_unit_size(self):
        return self.axes.get_height() / (2.0*self.y_radius)

    def get_coordinate_labels(self, x_vals = None, y_vals = None):
        result = []
        if x_vals == None and y_vals == None:
            x_vals = range(-int(self.x_radius), int(self.x_radius))
            y_vals = range(-int(self.y_radius), int(self.y_radius))
#.........这里部分代码省略.........
开发者ID:PythonJedi,项目名称:manim,代码行数:103,代码来源:number_line.py

示例3: NumberPlane

# 需要导入模块: from mobject.vectorized_mobject import VMobject [as 别名]
# 或者: from mobject.vectorized_mobject.VMobject import set_stroke [as 别名]
class NumberPlane(VMobject):
    CONFIG = {
        "color" : BLUE_D,
        "secondary_color" : BLUE_E,
        "axes_color" : WHITE,
        "secondary_stroke_width" : 1,
        "x_radius": SPACE_WIDTH,
        "y_radius": SPACE_HEIGHT,
        "space_unit_to_x_unit" : 1,
        "space_unit_to_y_unit" : 1,
        "x_line_frequency" : 1,
        "y_line_frequency" : 1,
        "secondary_line_ratio" : 1,
        "written_coordinate_height" : 0.2,
        "written_coordinate_nudge" : 0.1*(DOWN+RIGHT),
        "num_pair_at_center" : (0, 0),
        "propogate_style_to_family" : False,
        "submobject_partial_creation_mode" : "smoothed_lagged_start",
    }
    
    def generate_points(self):
        self.axes = VMobject()
        self.main_lines = VMobject()
        self.secondary_lines = VMobject()
        tuples = [
            (
                self.x_radius, 
                self.x_line_frequency, 
                self.y_radius*DOWN, 
                self.y_radius*UP,
                RIGHT
            ),
            (
                self.y_radius, 
                self.y_line_frequency, 
                self.x_radius*LEFT, 
                self.x_radius*RIGHT,
                UP,
            ),
        ]
        for radius, freq, start, end, unit in tuples:
            main_range = np.arange(0, radius, freq)
            step = freq/float(freq + self.secondary_line_ratio)
            for v in np.arange(0, radius, step):
                line1 = Line(start+v*unit, end+v*unit)
                line2 = Line(start-v*unit, end-v*unit)                
                if v == 0:
                    self.axes.add(line1)
                elif v in main_range:
                    self.main_lines.add(line1, line2)
                else:
                    self.secondary_lines.add(line1, line2)
        self.add(self.axes, self.main_lines, self.secondary_lines)
        self.stretch(self.space_unit_to_x_unit, 0)
        self.stretch(self.space_unit_to_y_unit, 1)
        #Put x_axis before y_axis
        y_axis, x_axis = self.axes.split()
        self.axes = VMobject(x_axis, y_axis)

    def init_colors(self):
        VMobject.init_colors(self)
        self.axes.set_stroke(self.axes_color, self.stroke_width)
        self.main_lines.set_stroke(self.color, self.stroke_width)
        self.secondary_lines.set_stroke(
            self.secondary_color, self.secondary_stroke_width
        )
        return self

    def get_center_point(self):
        return self.num_pair_to_point(self.num_pair_at_center)

    def num_pair_to_point(self, pair):
        pair = np.array(pair) + self.num_pair_at_center
        result = self.get_center()
        result[0] += pair[0]*self.space_unit_to_x_unit
        result[1] += pair[1]*self.space_unit_to_y_unit
        return result

    def point_to_num_pair(self, point):
        new_point = point-self.get_center()
        center_x, center_y = self.num_pair_at_center
        x = center_x + point[0]/self.space_unit_to_x_unit
        y = center_y + point[1]/self.space_unit_to_y_unit
        return x, y

    def get_coordinate_labels(self, x_vals = None, y_vals = None):
        result = []
        if x_vals == None and y_vals == None:
            x_vals = range(-int(self.x_radius), int(self.x_radius))
            y_vals = range(-int(self.y_radius), int(self.y_radius))
        for index, vals in enumerate([x_vals, y_vals]):
            num_pair = [0, 0]
            for val in vals:
                num_pair[index] = val
                point = self.num_pair_to_point(num_pair)
                num = TexMobject(str(val))
                num.scale_to_fit_height(
                    self.written_coordinate_height
                )
                num.shift(
#.........这里部分代码省略.........
开发者ID:xhrwang,项目名称:manim,代码行数:103,代码来源:number_line.py


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