本文整理汇总了Python中mobject.vectorized_mobject.VMobject.to_corner方法的典型用法代码示例。如果您正苦于以下问题:Python VMobject.to_corner方法的具体用法?Python VMobject.to_corner怎么用?Python VMobject.to_corner使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mobject.vectorized_mobject.VMobject
的用法示例。
在下文中一共展示了VMobject.to_corner方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: construct
# 需要导入模块: from mobject.vectorized_mobject import VMobject [as 别名]
# 或者: from mobject.vectorized_mobject.VMobject import to_corner [as 别名]
def construct(self):
physy = Physicist()
mathy = Mathematician(mode = "pondering")
compy = ComputerScientist()
creatures = [physy, compy, mathy]
physy.title = TextMobject("Physics student").to_corner(DOWN+LEFT)
compy.title = TextMobject("CS student").to_corner(DOWN+RIGHT)
mathy.title = TextMobject("Mathematician").to_edge(DOWN)
names = VMobject(physy.title, mathy.title, compy.title)
names.arrange_submobjects(RIGHT, buff = 1)
names.to_corner(DOWN+LEFT)
for pi in creatures:
pi.next_to(pi.title, UP)
vector, symbol, coordinates = self.intro_vector()
for pi in creatures:
self.play(
Write(pi.title),
FadeIn(pi),
run_time = 1
)
self.dither(2)
self.remove(symbol, coordinates)
self.physics_conception(creatures, vector)
self.cs_conception(creatures)
self.handle_mathy(creatures)
示例2: add_symbols
# 需要导入模块: from mobject.vectorized_mobject import VMobject [as 别名]
# 或者: from mobject.vectorized_mobject.VMobject import to_corner [as 别名]
def add_symbols(self):
v = matrix_to_mobject(self.v_coords).highlight(self.v_color)
w = matrix_to_mobject(self.w_coords).highlight(self.w_color)
v.add_background_rectangle()
w.add_background_rectangle()
dot = TexMobject("\\cdot")
eq = VMobject(v, dot, w)
eq.arrange_submobjects(RIGHT, buff = SMALL_BUFF)
eq.to_corner(UP+LEFT)
self.play(Write(eq), run_time = 1)
示例3: construct
# 需要导入模块: from mobject.vectorized_mobject import VMobject [as 别名]
# 或者: from mobject.vectorized_mobject.VMobject import to_corner [as 别名]
def construct(self):
morty = Mortimer(mode = "speaking")
morty.to_corner(DOWN + RIGHT)
bubble = morty.get_bubble(SpeechBubble)
bubble.write("I'm assuming you \\\\ know linear algebra\\dots")
words = bubble.content
bubble.clear()
randys = VMobject(*[
Randolph(color = c)
for c in BLUE_D, BLUE_C, BLUE_E
])
randys.arrange_submobjects(RIGHT)
randys.scale(0.8)
randys.to_corner(DOWN+LEFT)
self.add(randys, morty)
self.play(FadeIn(bubble), Write(words), run_time = 3)
for randy in np.array(randys.split())[[2,0,1]]:
self.play(Blink(randy))
self.dither()
示例4: TeacherStudentsScene
# 需要导入模块: from mobject.vectorized_mobject import VMobject [as 别名]
# 或者: from mobject.vectorized_mobject.VMobject import to_corner [as 别名]
class TeacherStudentsScene(Scene):
def setup(self):
self.teacher = Mortimer()
self.teacher.to_corner(DOWN + RIGHT)
self.teacher.look(DOWN+LEFT)
self.students = VMobject(*[
Randolph(color = c)
for c in BLUE_D, BLUE_C, BLUE_E
])
self.students.arrange_submobjects(RIGHT)
self.students.scale(0.8)
self.students.to_corner(DOWN+LEFT)
self.students = self.students.split()
for pi_creature in self.get_everyone():
pi_creature.bubble = None
self.add(*self.get_everyone())
def get_teacher(self):
return self.teacher
def get_students(self):
return self.students
def get_everyone(self):
return [self.get_teacher()] + self.get_students()
def get_bubble_intro_animation(self, content, bubble_type,
pi_creature,
**bubble_kwargs):
bubble = pi_creature.get_bubble(bubble_type, **bubble_kwargs)
bubble.add_content(content)
if pi_creature.bubble:
content_intro_anims = [
Transform(pi_creature.bubble, bubble),
Transform(pi_creature.bubble.content, bubble.content)
]
else:
content_intro_anims = [
FadeIn(bubble),
Write(content),
]
pi_creature.bubble = bubble
return content_intro_anims
def introduce_bubble(self, content, bubble_type, pi_creature,
pi_creature_target_mode = None,
added_anims = [],
**bubble_kwargs):
if all(map(lambda s : isinstance(s, str), content)):
content = TextMobject(*content)
elif len(content) == 1 and isinstance(content[0], TexMobject):
content = content[0]
else:
raise Exception("Invalid content type")
content_intro_anims = self.get_bubble_intro_animation(
content, bubble_type, pi_creature, **bubble_kwargs
)
if not pi_creature_target_mode:
if bubble_type is "speech":
pi_creature_target_mode = "speaking"
else:
pi_creature_target_mode = "pondering"
for p in self.get_everyone():
if p.bubble and p is not pi_creature:
added_anims += [
FadeOut(p.bubble),
FadeOut(p.bubble.content)
]
p.bubble = None
added_anims.append(ApplyMethod(p.change_mode, "plain"))
anims = added_anims + content_intro_anims + [
ApplyMethod(
pi_creature.change_mode,
pi_creature_target_mode,
),
]
self.play(*anims)
return pi_creature.bubble
def teacher_says(self, *content, **kwargs):
return self.introduce_bubble(
content, "speech", self.get_teacher(), **kwargs
)
def student_says(self, *content, **kwargs):
student = self.get_students()[kwargs.get("student_index", 1)]
return self.introduce_bubble(content, "speech", student, **kwargs)
def teacher_thinks(self, *content, **kwargs):
return self.introduce_bubble(
content, "thought", self.get_teacher(), **kwargs
)
def student_thinks(self, *content, **kwargs):
student = self.get_students()[kwargs.get("student_index", 1)]
return self.introduce_bubble(content, "thought", student, **kwargs)
#.........这里部分代码省略.........
示例5: TeacherStudentsScene
# 需要导入模块: from mobject.vectorized_mobject import VMobject [as 别名]
# 或者: from mobject.vectorized_mobject.VMobject import to_corner [as 别名]
class TeacherStudentsScene(Scene):
def setup(self):
self.teacher = Mortimer()
self.teacher.to_corner(DOWN + RIGHT)
self.teacher.look(DOWN+LEFT)
self.students = VMobject(*[
Randolph(color = c)
for c in BLUE_D, BLUE_C, BLUE_E
])
self.students.arrange_submobjects(RIGHT)
self.students.scale(0.8)
self.students.to_corner(DOWN+LEFT)
for pi_creature in self.get_everyone():
pi_creature.bubble = None
self.add(*self.get_everyone())
def get_teacher(self):
return self.teacher
def get_students(self):
return self.students.split()
def get_everyone(self):
return [self.get_teacher()] + self.get_students()
def get_bubble_intro_animation(self, content, bubble_type,
pi_creature,
**bubble_kwargs):
bubble = pi_creature.get_bubble(bubble_type, **bubble_kwargs)
bubble.add_content(content)
if pi_creature.bubble:
content_intro_anims = [
Transform(pi_creature.bubble, bubble),
Transform(pi_creature.bubble.content, bubble.content)
]
else:
content_intro_anims = [
FadeIn(bubble),
Write(content),
]
pi_creature.bubble = bubble
return content_intro_anims
def introduce_bubble(self, content, bubble_type, pi_creature,
pi_creature_target_mode = None,
added_anims = [],
**bubble_kwargs):
if isinstance(content, str):
content = TextMobject(content)
content_intro_anims = self.get_bubble_intro_animation(
content, bubble_type, pi_creature, **bubble_kwargs
)
if not pi_creature_target_mode:
if bubble_type is "speech":
pi_creature_target_mode = "speaking"
else:
pi_creature_target_mode = "pondering"
for p in self.get_everyone():
if p.bubble and p is not pi_creature:
added_anims += [
FadeOut(p.bubble),
FadeOut(p.bubble.content)
]
p.bubble = None
added_anims.append(ApplyMethod(p.change_mode, "plain"))
anims = added_anims + content_intro_anims + [
ApplyMethod(
pi_creature.change_mode,
pi_creature_target_mode,
),
]
self.play(*anims)
return pi_creature.bubble
def teacher_says(self, content = "", **kwargs):
return self.introduce_bubble(
content, "speech", self.get_teacher(), **kwargs
)
def student_says(self, content = "", student_index = 1, **kwargs):
student = self.get_students()[student_index]
return self.introduce_bubble(content, "speech", student, **kwargs)
def teacher_thinks(self, content = "", **kwargs):
return self.introduce_bubble(
content, "thought", self.get_teacher(), **kwargs
)
def student_thinks(self, content = "", student_index = 1, **kwargs):
student = self.get_students()[student_index]
return self.introduce_bubble(content, "thought", student, **kwargs)
def random_blink(self, num_times = 1):
for x in range(num_times):
pi_creature = random.choice(self.get_everyone())
self.play(Blink(pi_creature))
#.........这里部分代码省略.........