manim - 类型对象“动画”没有属性“mobject”
问题描述
我在这里练习示例
从 SuccessionExample1 开始,只要存在:
Succession(Animation, Mobject(),...
会出现如下错误:
AttributeError: type object 'Animation' has no attribute 'mobject'
查了animation.py,发现self.mobject = mobject,也就是Animation类有mobject属性,是不是那些样本过时了?还是其他原因?
解决方案
这是因为那是旧版本的代码(我在教程中使用了 2 月 3 日的版本),我忘记在你之前的问题中告诉你只渲染更新函数,而不是继承的那些。要使用继承,必须更改代码格式,这是最新版本的代码。
在 SuccessionExample1 的情况下:
class SuccessionExample1(Scene):
def construct(self):
number_line=NumberLine(x_min=-2,x_max=2)
text=TextMobject("Text")\
.next_to(number_line,DOWN)
dashed_line=DashedLine(
number_line.get_left(),
number_line.get_right(),
color=YELLOW,
).set_stroke(width=11)
self.add(number_line)
self.wait(0.3)
self.play(
LaggedStart(
*[ShowCreationThenDestruction(dashed_segment)
for dashed_segment in dashed_line],
run_time=5
),
AnimationGroup(
Animation(Mobject(),run_time=2.1),
Write(text),lag_ratio=1
)
)
self.wait()
推荐阅读
- python - Virtualenv 环境不会在 Windows 10 上的 CMD 中激活
- python - Django Rest Framework:当默认排序字段可为空时,详细视图中的 Paginaion 中断
- java - 用许多方法分解一个类以提高可读性
- linux - 获取警告:modpost:使用多个 Src 文件编译 LKM 时缺少 MODULE_LICENSE()
- javascript - 为 REST 更新 amplify express 服务器的最快方法?
- delphi - Devexpress VCL-Grid Excel 过滤模式
- asynchronous - Datastax Cassandra 驱动程序异步结果集获取不起作用
- python - 如何合并两个 CNN 模型?
- scala - 如何提取缩小类型并将其用于 Shapeless 的副产品?
- python - Numpy:ix_和ogrid有什么区别吗?