本文整理汇总了Python中mobject.vectorized_mobject.VMobject.move_to方法的典型用法代码示例。如果您正苦于以下问题:Python VMobject.move_to方法的具体用法?Python VMobject.move_to怎么用?Python VMobject.move_to使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mobject.vectorized_mobject.VMobject
的用法示例。
在下文中一共展示了VMobject.move_to方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: construct
# 需要导入模块: from mobject.vectorized_mobject import VMobject [as 别名]
# 或者: from mobject.vectorized_mobject.VMobject import move_to [as 别名]
def construct(self):
morty = Mortimer()
morty.scale(0.8)
morty.to_corner(DOWN+RIGHT)
morty.shift(0.5*LEFT)
title = TextMobject("Associativity:")
title.to_corner(UP+LEFT)
lhs = TexMobject(list("(AB)C"))
lp, a, b, rp, c = lhs.split()
rhs = VMobject(*[m.copy() for m in a, lp, b, c, rp])
point = VectorizedPoint()
start = VMobject(*[m.copy() for m in point, a, b, point, c])
for mob in lhs, rhs, start:
mob.arrange_submobjects(buff = 0.1)
a, lp, b, c, rp = rhs.split()
rhs = VMobject(lp, a, b, rp, c)##Align order to lhs
eq = TexMobject("=")
q_marks = TextMobject("???")
q_marks.submobject_gradient_highlight(TEAL_B, TEAL_D)
q_marks.next_to(eq, UP)
lhs.next_to(eq, LEFT)
rhs.next_to(eq, RIGHT)
start.move_to(lhs)
self.add(morty, title)
self.dither()
self.play(Blink(morty))
self.play(Write(start))
self.dither()
self.play(Transform(start, lhs))
self.dither()
self.play(
Transform(lhs, rhs, path_arc = -np.pi),
Write(eq)
)
self.play(Write(q_marks))
self.play(Blink(morty))
self.play(morty.change_mode, "pondering")
lp, a, b, rp, c = start.split()
self.show_full_matrices(morty, a, b, c, title)
示例2: scale_basis_vectors
# 需要导入模块: from mobject.vectorized_mobject import VMobject [as 别名]
# 或者: from mobject.vectorized_mobject.VMobject import move_to [as 别名]
def scale_basis_vectors(self, new_array):
i_hat, j_hat = self.get_basis_vectors()
self.add_vector(i_hat)
i_hat_label = self.label_vector(
i_hat, "\\hat{\\imath}",
color = X_COLOR,
label_scale_factor = 1
)
self.add_vector(j_hat)
j_hat_label = self.label_vector(
j_hat, "\\hat{\\jmath}",
color = Y_COLOR,
label_scale_factor = 1
)
self.dither()
x, y = new_array.get_mob_matrix().flatten()
for coord, v, label, factor, shift_right in [
(x, i_hat, i_hat_label, self.vector_coords[0], False),
(y, j_hat, j_hat_label, self.vector_coords[1], True)
]:
faded_v = v.copy().fade(0.7)
scaled_v = Vector(factor*v.get_end(), color = v.get_color())
scaled_label = VMobject(coord.copy(), label.copy())
scaled_label.arrange_submobjects(RIGHT, buff = 0.1)
scaled_label.move_to(label, DOWN+RIGHT)
scaled_label.shift((scaled_v.get_end()-v.get_end())/2)
coord_copy = coord.copy()
self.play(
Transform(v.copy(), faded_v),
Transform(v, scaled_v),
Transform(VMobject(coord_copy, label), scaled_label),
)
self.dither()
if shift_right:
group = VMobject(v, coord_copy, label)
self.play(ApplyMethod(
group.shift, self.vector_coords[0]*RIGHT
))
self.dither()
示例3: construct
# 需要导入模块: from mobject.vectorized_mobject import VMobject [as 别名]
# 或者: from mobject.vectorized_mobject.VMobject import move_to [as 别名]
def construct(self):
self.setup()
self.plane.fade(0.3)
self.add_unit_square(color = YELLOW_E, opacity = 0.5)
self.add_title(
["The", "``determinant''", "of a transformation"],
scale_factor = 1
)
self.title.split()[1].split()[1].highlight(YELLOW)
matrix_background, matrix, det_text = self.get_matrix()
self.add_foreground_mobject(matrix_background, matrix)
A = TexMobject("A")
area_label = VMobject(A.copy(), A.copy(), A)
area_label.move_to(self.square)
det = np.linalg.det(self.t_matrix)
if np.round(det) == det:
det = int(det)
area_label_target = VMobject(
TexMobject(str(det)), TexMobject("\\cdot"), A.copy()
)
if det < 1 and det > 0:
area_label_target.scale(det)
area_label_target.arrange_submobjects(RIGHT, buff = 0.1)
self.add_moving_mobject(area_label, area_label_target)
self.dither()
self.apply_transposed_matrix(self.t_matrix)
self.dither()
det_mob_copy = area_label.split()[0].copy()
new_det_mob = det_mob_copy.copy().scale_to_fit_height(
det_text.split()[0].get_height()
)
new_det_mob.next_to(det_text, RIGHT, buff = 0.2)
new_det_mob.add_background_rectangle()
det_mob_copy.add_background_rectangle(opacity = 0)
self.play(Write(det_text))
self.play(Transform(det_mob_copy, new_det_mob))
self.dither()