VMobject

限定名称: manim.mobject.types.vectorized\_mobject.VMobject

class VMobject(fill_color=None, fill_opacity=0.0, stroke_color=None, stroke_opacity=1.0, stroke_width=4, background_stroke_color=ManimColor('#000000'), background_stroke_opacity=1.0, background_stroke_width=0, sheen_factor=0.0, joint_type=None, sheen_direction=array([-1., 1., 0.]), close_new_points=False, pre_function_handle_to_anchor_scale_factor=0.01, make_smooth_after_applying_functions=False, background_image=None, shade_in_3d=False, tolerance_for_point_equality=1e-06, n_points_per_cubic_curve=4, cap_style=CapStyleType.AUTO, **kwargs)[来源]

基础类: Mobject

一个向量化的mobject。

Parameters:
  • background_stroke_color (ParsableManimColor | None) – 背景描边的目的是为了拥有一些不会与填充重叠的内容,例如,对于某些纹理背景上的文本。

  • sheen_factor (float) – 当设置颜色c时,将根据sheen_factor将c插值到白色来计算第二种颜色,并且显示将沿sheen_direction方向渐变到这种次要颜色。

  • close_new_points (bool) – 表示它不会被显示,但应该计入父mobject的路径中

  • tolerance_for_point_equality (float) – 这是在像素范围内的

  • joint_type (LineJointType | None) – 用于连接此向量化对象的曲线段的线连接类型。有关选项,请参见LineJointType

  • fill_color (ParsableManimColor | None)

  • fill_opacity (float)

  • stroke_color (ParsableManimColor | None)

  • stroke_opacity (float)

  • stroke_width (float)

  • background_stroke_opacity (float)

  • background_stroke_width (float)

  • sheen_direction (Vector3D)

  • pre_function_handle_to_anchor_scale_factor (float)

  • make_smooth_after_applying_functions (bool)

  • background_image (图片 | str | None)

  • shade_in_3d (bool)

  • n_points_per_cubic_curve (int)

  • cap_style (CapStyleType)

方法

add_cubic_bezier_curve

add_cubic_bezier_curve_to

向路径添加三次贝塞尔曲线。

add_cubic_bezier_curves

add_line_to

从VMobject的最后一个点到给定点添加一条直线。

add_points_as_corners

add_quadratic_bezier_curve_to

向路径添加二次贝塞尔曲线。

add_smooth_curve_to

从给定的点创建一条平滑曲线并将其添加到VMobject中。

add_subpath

align_points

向self和vmobject添加点,使它们具有相同数量的子路径,每个对应的子路径包含相同数量的点。

align_rgbas

append_points

append_vectorized_mobject

apply_function

change_anchor_mode

更改贝塞尔曲线的锚点模式。

clear_points

close_path

color_using_background_image

consider_points_equals

consider_points_equals_2d

确定两个点是否足够接近以被视为相等。

fade

force_direction

确保点要么顺时针方向,要么逆时针方向。

gen_cubic_bezier_tuples_from_points

从点数组中返回贝塞尔元组。

gen_subpaths_from_points_2d

generate_rgbas_array

第一个参数可以是颜色,也可以是颜色元组/列表。

get_anchors

返回形成VMobject的曲线的锚点。

get_anchors_and_handles

返回anchors1, handles1, handles2, anchors2,其中(anchors1[i], handles1[i], handles2[i], anchors2[i])将定义任何i在范围(0, len(anchors1))内的三次贝塞尔曲线的四个点

get_arc_length

返回整个曲线的近似长度。

get_background_image

get_color

返回Mobject的颜色

get_cubic_bezier_tuples

get_cubic_bezier_tuples_from_points

get_curve_functions

获取mobject曲线的函数。

get_curve_functions_with_lengths

获取mobject的曲线函数和长度。

get_direction

使用 shoelace_direction() 来计算方向。

get_end_anchors

返回贝塞尔曲线的末端锚点。

get_fill_color

如果有多种颜色(用于渐变),则返回第一个颜色

get_fill_colors

get_fill_opacities

get_fill_opacity

如果有多个不透明度,则返回第一个

get_fill_rgbas

get_gradient_start_and_end_points

get_group_class

get_last_point

get_mobject_type_class

返回此mobject类型的基类。

get_nth_curve_function

返回第n条曲线的表达式。

get_nth_curve_function_with_length

返回第n条曲线的表达式及其(近似)长度。

get_nth_curve_length

返回第n条曲线的(近似)长度。

get_nth_curve_length_pieces

返回用于长度近似的短线段长度数组。

get_nth_curve_points

返回定义vmobject的第n条曲线的点。

get_num_curves

返回vmobject的曲线数量。

get_point_mobject

最简单的 Mobject 可以转换为自身或从自身转换而来。

get_points_defining_boundary

get_sheen_direction

get_sheen_factor

get_start_anchors

返回贝塞尔曲线的起始锚点。

get_stroke_color

get_stroke_colors

get_stroke_opacities

get_stroke_opacity

get_stroke_rgbas

get_stroke_width

get_style

get_subcurve

返回VMobject在区间[a, b]内的子曲线。

get_subpaths

返回由VMobject的曲线形成的子路径。

get_subpaths_from_points

has_new_path_started

init_colors

初始化颜色。

insert_n_curves

向 vmobject 的贝塞尔曲线插入 n 条曲线。

insert_n_curves_to_point_list

给定一个定义贝塞尔曲线的k个点(锚点和控制点),返回定义恰好k + n个贝塞尔曲线的点。

interpolate_color

is_closed

make_jagged

make_smooth

match_background_image

match_style

point_from_proportion

获取沿着VMobject路径的比例点。

pointwise_become_partial

给定两个边界a和b,将self vmobject的点转换为作为参数传递的vmobject的点,相对于边界。

proportion_from_point

返回特定给定点在VMobject路径上的比例。

resize_points

调整锚点和控制点的数组大小以具有指定的大小。

reverse_direction

通过反转点的顺序来恢复点的方向。

rotate

围绕某个点旋转Mobject

rotate_sheen_direction

旋转所应用的光泽方向。

scale_handle_to_anchor_distances

如果给定手柄点H与其关联的锚点A之间的距离为d,则将其更改为距离A的距离为factor*d,但确保从A到H的线不变。

set_anchors_and_handles

给定两组锚点和控制点,处理它们以将它们设置为VMobject的锚点和控制点。

set_background_stroke

set_cap_style

设置VMobject的端点样式。

set_color

条件是一个函数,它接受一个参数,(x, y, z)。

set_fill

设置VMobject的填充颜色和填充不透明度。

set_opacity

set_points

set_points_as_corners

给定一个点数组,将它们设置为vmobject的角点。

set_points_smoothly

set_shade_in_3d

set_sheen

从某个方向应用颜色渐变。

set_sheen_direction

设置应用的光泽方向。

set_stroke

set_style

start_new_path

update_rgbas_array

属性

animate

用于动画化self的任何方法的应用。

animation_overrides

color

depth

mobject的深度。

fill_color

如果有多种颜色(用于渐变),则返回第一个颜色

height

mobject的高度。

n_points_per_curve

sheen_factor

stroke_color

width

mobject的宽度。

_gen_subpaths_from_points(points, filter_func)[来源]

给定一个定义vmobject贝塞尔曲线的点数组,返回由这些点形成的子路径。 在这里,如果至少有两个锚点通过filter_func定义的关系评估为True,则两条贝塞尔曲线形成一条路径。

算法对self.points中的每个贝塞尔元组(锚点和控制点)进行处理(通过将每n个元素重新分组,其中n是每条三次曲线的点数),并使用filter_func评估两个锚点之间的关系。 注意:filter_func接受一个整数n作为参数,并将评估points[n]和points[n - 1]之间的关系。这可能应该更改,以便函数接受两个点作为参数。

Parameters:
  • points (Point3D_Array) – 定义贝塞尔曲线的点。

  • filter_func (Callable[[int], bool]) – 定义关系的过滤函数。

Returns:

由点形成的子路径。

Return type:

生成器[Point3D_Array]

_original__init__(fill_color=None, fill_opacity=0.0, stroke_color=None, stroke_opacity=1.0, stroke_width=4, background_stroke_color=ManimColor('#000000'), background_stroke_opacity=1.0, background_stroke_width=0, sheen_factor=0.0, joint_type=None, sheen_direction=array([-1., 1., 0.]), close_new_points=False, pre_function_handle_to_anchor_scale_factor=0.01, make_smooth_after_applying_functions=False, background_image=None, shade_in_3d=False, tolerance_for_point_equality=1e-06, n_points_per_cubic_curve=4, cap_style=CapStyleType.AUTO, **kwargs)

初始化自身。有关准确的签名,请参阅 help(type(self))。

Parameters:
  • fill_color (ParsableManimColor | None)

  • fill_opacity (float)

  • stroke_color (ParsableManimColor | None)

  • stroke_opacity (float)

  • stroke_width (float)

  • background_stroke_color (ParsableManimColor | None)

  • background_stroke_opacity (float)

  • background_stroke_width (float)

  • sheen_factor (float)

  • joint_type (LineJointType | None)

  • sheen_direction (Vector3D)

  • close_new_points (bool)

  • pre_function_handle_to_anchor_scale_factor (float)

  • make_smooth_after_applying_functions (bool)

  • background_image (图片 | str | None)

  • shade_in_3d (bool)

  • tolerance_for_point_equality (float)

  • n_points_per_cubic_curve (int)

  • cap_style (CapStyleType)

add_cubic_bezier_curve_to(handle1, handle2, anchor)[来源]

向路径添加三次贝塞尔曲线。

注意:第一个锚点不是参数,因为默认情况下它是最后一个子路径的结尾!

Parameters:
Returns:

self

Return type:

VMobject

add_line_to(point)[来源]

从VMobject的最后一个点到给定点添加一条直线。

Parameters:

(Point3D) – 直线的终点。

Returns:

self

Return type:

VMobject

add_quadratic_bezier_curve_to(handle, anchor)[来源]

向路径添加二次贝塞尔曲线。

Returns:

self

Return type:

VMobject

Parameters:
add_smooth_curve_to(*points)[source]

从给定的点创建一条平滑曲线并将其添加到VMobject中。如果传入两个点,第一个点被解释为控制点,第二个点被解释为锚点。

Parameters:

points (Point3D) – 要从中添加平滑曲线的点(锚点和控制点,或仅锚点)

Returns:

self

Return type:

VMobject

Raises:

ValueError – 如果给出0个或超过2个点。

align_points(vmobject)[source]

向self和vmobject添加点,使它们都具有相同数量的子路径,每个对应的子路径包含相同数量的点。

点的添加方式有两种:一种是在子路径上均匀细分曲线,另一种是创建由重复的单个点组成的新子路径。

Parameters:

vmobject (VMobject) – 用于对齐点的对象。

Returns:

self

Return type:

VMobject

change_anchor_mode(mode)[来源]

更改贝塞尔曲线的锚点模式。这将修改控制柄。

只能有两种模式,“jagged”和“smooth”。

Returns:

self

Return type:

VMobject

Parameters:

mode (Literal['jagged', 'smooth'])

consider_points_equals_2d(p0, p1)[来源]

确定两个点是否足够接近以被视为相等。

这里使用了来自 np.isclose() 的算法,但在这里扩展用于二维点的情况。对于这么小的问题,NumPy 有点大材小用。 :param p0: 第一个点 :param p1: 第二个点

Returns:

是否认为两个点接近。

Return type:

布尔

Parameters:
property fill_color: ManimColor

如果有多种颜色(用于渐变) 这将返回第一个颜色

force_direction(target_direction)[source]

确保点要么顺时针方向,要么逆时针方向。

Parameters:

target_direction (Literal['CW', 'CCW']) – 可以是 "CW""CCW"

Return type:

自我

gen_cubic_bezier_tuples_from_points(points)[source]

从点数组中返回贝塞尔元组。

self.points 是 mobject 的贝塞尔曲线的锚点和控制点的列表(即 [anchor1, handle1, handle2, anchor2, anchor3 ..]) 这个算法基本上通过每隔 n 个元素取一个元素来检索它们,其中 n 是贝塞尔曲线的控制点的数量。

Parameters:

points (Point3D_Array) – 从中提取控制点的点。

Returns:

贝塞尔控制点。

Return type:

元组

generate_rgbas_array(color, opacity)[source]

第一个参数可以是颜色,也可以是颜色元组/列表。 同样,不透明度可以是浮点数,也可以是浮点数元组。 如果 self.sheen_factor 不为零,并且只传入了一种颜色, 则会自动添加第二种稍浅的颜色用于渐变。

Parameters:
Return type:

RGBA_Array_Float

get_anchors()[source]

返回形成VMobject的曲线的锚点。

Returns:

锚点。

Return type:

Point3D_Array

get_anchors_and_handles()[来源]

返回 anchors1, handles1, handles2, anchors2, 其中 (anchors1[i], handles1[i], handles2[i], anchors2[i]) 将是定义三次贝塞尔曲线的四个点 对于任何 i 在范围 (0, len(anchors1)) 内

Returns:

锚点和手柄的可迭代对象。

Return type:

list[Point3D_Array]

get_arc_length(sample_points_per_curve=None)[source]

返回整个曲线的近似长度。

Parameters:

sample_points_per_curve (int | None) – 每条曲线用于近似长度的采样点数。点数越多,近似效果越好。

Returns:

VMobject的长度。

Return type:

浮点数

get_color()[source]

返回Mobject的颜色

示例

>>> from manim import Square, RED
>>> Square(color=RED).get_color() == RED
True
Return type:

ManimColor

get_curve_functions()[来源]

获取mobject曲线的函数。

Returns:

曲线的函数。

Return type:

生成器[可调用[[浮点数], Point3D]]

get_curve_functions_with_lengths(**kwargs)[来源]

获取mobject的曲线函数和长度。

Parameters:

**kwargs – 传递给get_nth_curve_function_with_length()的关键字参数

Returns:

曲线的函数和长度。

Return type:

生成器[元组[可调用[[浮点数], Point3D], 浮点数]]

get_direction()[source]

使用 shoelace_direction() 来计算方向。 点的方向决定了对象是顺时针还是逆时针绘制。

示例

Circle 的默认方向是逆时针方向:

>>> from manim import Circle
>>> Circle().get_direction()
'CCW'
Returns:

要么是 "CW" 要么是 "CCW"

Return type:

str

get_end_anchors()[source]

返回贝塞尔曲线的末端锚点。

Returns:

起始锚点

Return type:

Point3D_Array

get_fill_color()[来源]

如果有多种颜色(用于渐变) 这将返回第一个颜色

Return type:

ManimColor

get_fill_opacity()[来源]

如果有多个不透明度,则返回第一个

Return type:

ManimFloat

static get_mobject_type_class()[来源]

返回此mobject类型的基类。

Return type:

类型[VMobject]

get_nth_curve_function(n)[source]

返回第n条曲线的表达式。

Parameters:

n (int) – 所需曲线的索引。

Returns:

第n条贝塞尔曲线的表达式。

Return type:

可调用的[float, Point3D]

get_nth_curve_function_with_length(n, sample_points=None)[来源]

返回第n条曲线的表达式及其(近似)长度。

Parameters:
  • n (int) – 所需曲线的索引。

  • sample_points (int | None) – 用于查找长度的采样点数。

Returns:

  • curve (Callable[[float], Point3D]) – 第n条曲线的函数。

  • length (float) – 第n条曲线的长度。

Return type:

元组[可调用[[浮点数], 点3D], 浮点数]

get_nth_curve_length(n, sample_points=None)[来源]

返回第n条曲线的(近似)长度。

Parameters:
  • n (int) – 所需曲线的索引。

  • sample_points (int | None) – 用于查找长度的采样点数。

Returns:

length – 第n条曲线的长度。

Return type:

float

get_nth_curve_length_pieces(n, sample_points=None)[source]

返回用于长度近似的短线段长度数组。

Parameters:
  • n (int) – 所需曲线的索引。

  • sample_points (int | None) – 用于查找长度的采样点数。

Return type:

第n条曲线的短长度片段。

get_nth_curve_points(n)[来源]

返回定义vmobject的第n条曲线的点。

Parameters:

n (int) – 所需贝塞尔曲线的索引。

Returns:

定义第n个贝塞尔曲线的点(锚点,控制点)

Return type:

Point3D_Array

get_num_curves()[来源]

返回vmobject的曲线数量。

Returns:

vmobject的曲线数量。

Return type:

整数

get_point_mobject(center=None)[来源]

最简单的Mobject可以转换为自身或从自身转换而来。应该是一个适当类型的点。

Parameters:

中心 (Point3D | )

Return type:

VectorizedPoint

get_start_anchors()[来源]

返回贝塞尔曲线的起始锚点。

Returns:

起始锚点

Return type:

Point3D_Array

get_subcurve(a, b)[来源]

返回VMobject在区间[a, b]内的子曲线。该曲线本身也是一个VMobject。

Parameters:
  • a (float) – 下界。

  • b (float) – 上界。

Returns:

[a, b] 之间的子曲线

Return type:

VMobject

get_subpaths()[来源]

返回由VMobject的曲线形成的子路径。

子路径是曲线的范围,其中每对连续的曲线的结束/起点是重合的。

Returns:

子路径。

Return type:

列表[Point3D_Array]

init_colors(propagate_colors=True)[来源]

初始化颜色。

在创建时调用。这是一个可以由子类实现的空方法。

Parameters:

propagate_colors (bool)

Return type:

自我

insert_n_curves(n)[source]

向 vmobject 的贝塞尔曲线插入 n 条曲线。

Parameters:

n (int) – 要插入的曲线数量。

Returns:

self

Return type:

VMobject

insert_n_curves_to_point_list(n, points)[来源]

给定一个定义贝塞尔曲线的k个点(锚点和控制点),返回定义恰好k + n个贝塞尔曲线的点。

Parameters:
  • n (int) – 所需曲线的数量。

  • points (Point3D_Array) – 起始点。

Return type:

生成的积分。

point_from_proportion(alpha)[来源]

获取沿着VMobject路径的比例点。

Parameters:

alpha (float) – 沿着VMobject路径的比例。

Returns:

VMobject上的点。

Return type:

numpy.ndarray

Raises:
  • ValueError – 如果 alpha 不在 0 和 1 之间。

  • 异常 – 如果VMobject没有点。

示例

示例:PointFromProportion

../_images/PointFromProportion-1.png
from manim import *

class PointFromProportion(Scene):
    def construct(self):
        line = Line(2*DL, 2*UR)
        self.add(line)
        colors = (RED, BLUE, YELLOW)
        proportions = (1/4, 1/2, 3/4)
        for color, proportion in zip(colors, proportions):
            self.add(Dot(color=color).move_to(
                    line.point_from_proportion(proportion)
            ))
class PointFromProportion(Scene):
    def construct(self):
        line = Line(2*DL, 2*UR)
        self.add(line)
        colors = (RED, BLUE, YELLOW)
        proportions = (1/4, 1/2, 3/4)
        for color, proportion in zip(colors, proportions):
            self.add(Dot(color=color).move_to(
                    line.point_from_proportion(proportion)
            ))

pointwise_become_partial(vmobject, a, b)[来源]

给定两个边界a和b,将self vmobject的点转换为作为参数传递的vmobject的点,这些转换是相对于边界的。这里的点指的是贝塞尔曲线的控制点(锚点和手柄)。

Parameters:
  • vmobject (VMobject) – 将作为模型的vmobject。

  • a (float) – 上界。

  • b (float) – 下界

Returns:

self

Return type:

VMobject

proportion_from_point(point)[来源]

返回特定给定点在VMobject路径上的比例。

Parameters:

(可迭代[浮点数 | 整数]) – 该点的笛卡尔坐标,可能位于VMobject上,也可能不在其上。

Returns:

沿着VMobject路径的比例。

Return type:

浮点数

Raises:
  • ValueError – 如果 point 不在曲线上。

  • 异常 – 如果VMobject没有点。

resize_points(new_length, resize_func=<function resize_array>)[source]

调整锚点和控制点的数组大小,使其具有指定的大小。

Parameters:
  • new_length (int) – 新的(总)点数。

  • resize_func (Callable[[Point3D, int], Point3D]) – 一个将Numpy数组(点)和一个整数(目标大小)映射到Numpy数组的函数。默认实现基于Numpy的resize函数。

Return type:

自我

reverse_direction()[来源]

通过反转点的顺序来恢复点的方向。

Returns:

返回自身。

Return type:

VMobject

示例

示例:ChangeOfDirection

from manim import *

class ChangeOfDirection(Scene):
    def construct(self):
        ccw = RegularPolygon(5)
        ccw.shift(LEFT)
        cw = RegularPolygon(5)
        cw.shift(RIGHT).reverse_direction()

        self.play(Create(ccw), Create(cw),
        run_time=4)
class ChangeOfDirection(Scene):
    def construct(self):
        ccw = RegularPolygon(5)
        ccw.shift(LEFT)
        cw = RegularPolygon(5)
        cw.shift(RIGHT).reverse_direction()

        self.play(Create(ccw), Create(cw),
        run_time=4)

rotate(angle, axis=array([0., 0., 1.]), about_point=None, **kwargs)[source]

围绕某个点旋转Mobject

Parameters:
Return type:

自我

rotate_sheen_direction(angle, axis=array([0., 0., 1.]), family=True)[source]

旋转所应用的光泽方向。

Parameters:
  • angle (float) – 光泽方向旋转的角度。

  • axis (Vector3D) – 旋转轴。

  • family (bool)

Return type:

自我

示例

正常用法:

Circle().set_sheen_direction(UP).rotate_sheen_direction(PI)

另请参阅

set_sheen_direction()

scale_handle_to_anchor_distances(factor)[来源]

如果给定手柄点H与其关联的锚点A之间的距离为d,则它将H更改为距离A为factor*d的位置,但确保从A到H的线不变。这在应用(可微分的)函数以保持切线属性时非常有用。人们会将所有手柄拉近其锚点,应用函数,然后再将它们推回原位。

Parameters:

factor (float) – 用于缩放的比例因子。

Returns:

self

Return type:

VMobject

set_anchors_and_handles(anchors1, handles1, handles2, anchors2)[source]

给定两组锚点和控制点,处理它们以将它们设置为VMobject的锚点和控制点。

anchors1[i], handles1[i], handles2[i] 和 anchors2[i] 定义了 vmobject 的第 i 条贝塞尔曲线。这里有四个硬编码的参数,这是一个问题,因为它使得每条三次曲线的点数无法从 4(两个锚点和两个控制点)改变。

Returns:

self

Return type:

VMobject

Parameters:
set_cap_style(cap_style)[来源]

设置VMobject的端点样式。

Parameters:

cap_style (CapStyleType) – 要设置的帽样式。请参阅 CapStyleType 以获取选项。

Returns:

self

Return type:

VMobject

示例

示例:CapStyleExample

../_images/CapStyleExample-1.png
from manim import *

class CapStyleExample(Scene):
    def construct(self):
        line = Line(LEFT, RIGHT, color=YELLOW, stroke_width=20)
        line.set_cap_style(CapStyleType.ROUND)
        self.add(line)
class CapStyleExample(Scene):
    def construct(self):
        line = Line(LEFT, RIGHT, color=YELLOW, stroke_width=20)
        line.set_cap_style(CapStyleType.ROUND)
        self.add(line)

set_color(color, family=True)[source]

条件是一个接受一个参数的函数,(x, y, z)。 这里它只是递归到子对象,但在子类中,这应该根据颜色的内部工作原理进一步实现。

Parameters:
Return type:

自我

set_fill(color=None, opacity=None, family=True)[source]

设置VMobject的填充颜色和填充不透明度。

Parameters:
  • color (ParsableManimColor | None) – VMobject的填充颜色。

  • opacity (float | None) – VMobject的填充不透明度。

  • family (bool) – 如果 True,所有子对象的填充颜色也会被设置。

Returns:

self

Return type:

VMobject

示例

示例:SetFill

../_images/SetFill-1.png
from manim import *

class SetFill(Scene):
    def construct(self):
        square = Square().scale(2).set_fill(WHITE,1)
        circle1 = Circle().set_fill(GREEN,0.8)
        circle2 = Circle().set_fill(YELLOW) # No fill_opacity
        circle3 = Circle().set_fill(color = '#FF2135', opacity = 0.2)
        group = Group(circle1,circle2,circle3).arrange()
        self.add(square)
        self.add(group)
class SetFill(Scene):
    def construct(self):
        square = Square().scale(2).set_fill(WHITE,1)
        circle1 = Circle().set_fill(GREEN,0.8)
        circle2 = Circle().set_fill(YELLOW) # No fill_opacity
        circle3 = Circle().set_fill(color = '#FF2135', opacity = 0.2)
        group = Group(circle1,circle2,circle3).arrange()
        self.add(square)
        self.add(group)

另请参阅

set_style()

set_points_as_corners(points)[source]

给定一个点数组,将它们设置为vmobject的角点。

为了实现这一点,该算法设置了与锚点对齐的句柄,使得生成的贝塞尔曲线将是两个锚点之间的线段。

Parameters:

points (Point3D_Array) – 将被设置为角点的点数组。

Returns:

self

Return type:

VMobject

示例

示例:PointsAsCornersExample

../_images/PointsAsCornersExample-1.png
from manim import *

class PointsAsCornersExample(Scene):
    def construct(self):
        corners = (
            # create square
            UR, UL,
            DL, DR,
            UR,
            # create crosses
            DL, UL,
            DR
        )
        vmob = VMobject(stroke_color=RED)
        vmob.set_points_as_corners(corners).scale(2)
        self.add(vmob)
class PointsAsCornersExample(Scene):
    def construct(self):
        corners = (
            # create square
            UR, UL,
            DL, DR,
            UR,
            # create crosses
            DL, UL,
            DR
        )
        vmob = VMobject(stroke_color=RED)
        vmob.set_points_as_corners(corners).scale(2)
        self.add(vmob)

set_sheen(factor, direction=None, family=True)[source]

从某个方向应用颜色渐变。

Parameters:
  • factor (float) – 应用的光泽/渐变程度。如果为负值,渐变从黑色开始;如果为正值,渐变从白色开始并变化到当前颜色。

  • direction (Vector3D | None) – 应用梯度的方向。

  • family (bool)

Return type:

自我

示例

示例:SetSheen

../_images/SetSheen-1.png
from manim import *

class SetSheen(Scene):
    def construct(self):
        circle = Circle(fill_opacity=1).set_sheen(-0.3, DR)
        self.add(circle)
class SetSheen(Scene):
    def construct(self):
        circle = Circle(fill_opacity=1).set_sheen(-0.3, DR)
        self.add(circle)

set_sheen_direction(direction, family=True)[source]

设置应用的光泽方向。

Parameters:
  • direction (Vector3D) – 应用梯度的方向。

  • family (bool)

Return type:

自我

示例

正常用法:

Circle().set_sheen_direction(UP)