追踪路径

限定名称: manim.animation.changing.TracedPath

class TracedPath(traced_point_func, stroke_width=2, stroke_color=ManimColor('#FFFFFF'), dissipating_time=None, **kwargs)[source]

基础类: VMobject

追踪由函数调用返回的点的路径。

Parameters:
  • traced_point_func (Callable) – 要追踪的函数。

  • stroke_width (float) – 轨迹的宽度。

  • stroke_color (ParsableManimColor | None) – 轨迹的颜色。

  • dissipating_time (float | None) – 路径消散所需的时间。默认设置为 None,这将禁用消散。

示例

示例:TracedPathExample

from manim import *

class TracedPathExample(Scene):
    def construct(self):
        circ = Circle(color=RED).shift(4*LEFT)
        dot = Dot(color=RED).move_to(circ.get_start())
        rolling_circle = VGroup(circ, dot)
        trace = TracedPath(circ.get_start)
        rolling_circle.add_updater(lambda m: m.rotate(-0.3))
        self.add(trace, rolling_circle)
        self.play(rolling_circle.animate.shift(8*RIGHT), run_time=4, rate_func=linear)
class TracedPathExample(Scene):
    def construct(self):
        circ = Circle(color=RED).shift(4*LEFT)
        dot = Dot(color=RED).move_to(circ.get_start())
        rolling_circle = VGroup(circ, dot)
        trace = TracedPath(circ.get_start)
        rolling_circle.add_updater(lambda m: m.rotate(-0.3))
        self.add(trace, rolling_circle)
        self.play(rolling_circle.animate.shift(8*RIGHT), run_time=4, rate_func=linear)

示例:DissipatingPathExample

from manim import *

class DissipatingPathExample(Scene):
    def construct(self):
        a = Dot(RIGHT * 2)
        b = TracedPath(a.get_center, dissipating_time=0.5, stroke_opacity=[0, 1])
        self.add(a, b)
        self.play(a.animate(path_arc=PI / 4).shift(LEFT * 2))
        self.play(a.animate(path_arc=-PI / 4).shift(LEFT * 2))
        self.wait()
class DissipatingPathExample(Scene):
    def construct(self):
        a = Dot(RIGHT * 2)
        b = TracedPath(a.get_center, dissipating_time=0.5, stroke_opacity=[0, 1])
        self.add(a, b)
        self.play(a.animate(path_arc=PI / 4).shift(LEFT * 2))
        self.play(a.animate(path_arc=-PI / 4).shift(LEFT * 2))
        self.wait()

方法

update_path

属性

animate

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

animation_overrides

color

depth

mobject的深度。

fill_color

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

height

mobject的高度。

n_points_per_curve

sheen_factor

stroke_color

width

mobject的宽度。

_original__init__(traced_point_func, stroke_width=2, stroke_color=ManimColor('#FFFFFF'), dissipating_time=None, **kwargs)

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

Parameters:
  • traced_point_func (Callable)

  • stroke_width (float)

  • stroke_color (ParsableManimColor | None)

  • dissipating_time (float | None)