曲线作为子对象

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

class CurvesAsSubmobjects(vmobject, **kwargs)[来源]

基础类: VGroup

将曲线的元素转换为子对象。

示例

示例:LineGradientExample

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

class LineGradientExample(Scene):
    def construct(self):
        curve = ParametricFunction(lambda t: [t, np.sin(t), 0], t_range=[-PI, PI, 0.01], stroke_width=10)
        new_curve = CurvesAsSubmobjects(curve)
        new_curve.set_color_by_gradient(BLUE, RED)
        self.add(new_curve.shift(UP), curve)
class LineGradientExample(Scene):
    def construct(self):
        curve = ParametricFunction(lambda t: [t, np.sin(t), 0], t_range=[-PI, PI, 0.01], stroke_width=10)
        new_curve = CurvesAsSubmobjects(curve)
        new_curve.set_color_by_gradient(BLUE, RED)
        self.add(new_curve.shift(UP), curve)

方法

point_from_proportion

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

属性

animate

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

animation_overrides

color

depth

mobject的深度。

fill_color

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

height

mobject的高度。

n_points_per_curve

sheen_factor

stroke_color

width

mobject的宽度。

Parameters:

vmobject (VMobject)

_original__init__(vmobject, **kwargs)

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

Parameters:

vmobject (VMobject)

Return type:

point_from_proportion(alpha)[source]

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

Parameters:

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

Returns:

曲线作为子对象的点。

Return type:

numpy.ndarray

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

  • 异常 – 如果 CurvesAsSubmobjects 没有子对象,或者没有子对象有点。