是否可以在manim中对图形对象使用ReplacementTransform?

2024-09-29 17:21:42 发布

您现在位置:Python中文网/ 问答频道 /正文

我对曼尼姆还不太熟悉

我想画一个线图,画完线后,围绕截距旋转它。但是现在,转换并没有发生:我的代码只是显示了相同的不变的图形0行,而没有执行ReplacementTransform

我也试过pivot,它是有效的,但它会绕着它的中心旋转,即使我能让它绕着它的截距旋转,我也不知道如何让它精确到我想要的每个轴的方程

有没有办法让这条线旋转到我用graph0、graph1和graph2指定的不同方程式

这是我的密码

class LinePivot(GraphScene):
CONFIG = {
    "y_max": 40,
    "y_min": 0,
    "x_max": 14,
    "x_min": 0,
    "y_tick_frequency": 5,
    "x_tick_frequency": 1,
    "axes_color": BLACK,
    "y_label_direction": LEFT,
    "x_label_direction": DOWN,
    "label_nums_color": BLACK,
    "camera_config": {
        "background_color": WHITE,
    },
}

def construct(self):
    self.setup_axes()

    graph0 = self.get_graph(lambda x: 5 + 2 * x, color=BLACK)
    graph1 = self.get_graph(lambda x: 5 + 3 * x, color=BLACK)
    graph2 = self.get_graph(lambda x: 5 + 4 * x, color=BLACK)

    self.play(ShowCreation(graph0))
    self.wait()
    ReplacementTransform(graph0, graph1, run_time=1)
    self.wait()
    ReplacementTransform(graph1, graph2, run_time=1)
    self.wait()

Tags: lambdaselfgetminlabelmaxgraphcolor
1条回答
网友
1楼 · 发布于 2024-09-29 17:21:42
ReplacementTransform(graph0, graph1, run_time=1)

仅创建变换,但不将其添加到场景或渲染。你想改用

self.play(ReplacementTransform(graph0, graph1), run_time=1)

相关问题 更多 >

    热门问题