本文整理汇总了Python中mobject.Mobject.submobject_family方法的典型用法代码示例。如果您正苦于以下问题:Python Mobject.submobject_family方法的具体用法?Python Mobject.submobject_family怎么用?Python Mobject.submobject_family使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mobject.Mobject
的用法示例。
在下文中一共展示了Mobject.submobject_family方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: play
# 需要导入模块: from mobject import Mobject [as 别名]
# 或者: from mobject.Mobject import submobject_family [as 别名]
def play(self, *animations, **kwargs):
self.num_animations += 1
if "run_time" in kwargs:
run_time = kwargs["run_time"]
else:
run_time = animations[0].run_time
for animation in animations:
animation.set_run_time(run_time)
moving_mobjects = [mobject for anim in animations for mobject in anim.mobject.submobject_family()]
bundle = Mobject(*self.mobjects)
static_mobjects = filter(lambda m: m not in moving_mobjects, bundle.submobject_family())
background = disp.paint_mobjects(static_mobjects, self.background, include_sub_mobjects=False)
times = np.arange(0, run_time, self.frame_duration)
time_progression = ProgressDisplay(times)
time_progression.set_description(
"Animation %d: " % self.num_animations + str(animations[0]) + (", etc." if len(animations) > 1 else "")
)
for t in time_progression:
for animation in animations:
animation.update(t / animation.run_time)
new_frame = disp.paint_mobjects([anim.mobject for anim in animations], background)
self.frames.append(new_frame)
for animation in animations:
animation.clean_up()
self.add(*[anim.mobject for anim in animations])
self.repaint_mojects()
return self
示例2: separate_moving_and_static_mobjects
# 需要导入模块: from mobject import Mobject [as 别名]
# 或者: from mobject.Mobject import submobject_family [as 别名]
def separate_moving_and_static_mobjects(self, *animations):
moving_mobjects = list(it.chain(*[
anim.mobject.submobject_family()
for anim in animations
]))
bundle = Mobject(*self.mobjects)
static_mobjects = filter(
lambda m : m not in moving_mobjects,
bundle.submobject_family()
)
return moving_mobjects, static_mobjects