本文整理汇总了Python中mobject.vectorized_mobject.VMobject.copy方法的典型用法代码示例。如果您正苦于以下问题:Python VMobject.copy方法的具体用法?Python VMobject.copy怎么用?Python VMobject.copy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mobject.vectorized_mobject.VMobject
的用法示例。
在下文中一共展示了VMobject.copy方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: record_basis_coordinates
# 需要导入模块: from mobject.vectorized_mobject import VMobject [as 别名]
# 或者: from mobject.vectorized_mobject.VMobject import copy [as 别名]
def record_basis_coordinates(self, vect_array, vect):
i_label = vector_coordinate_label(self.i_hat)
i_label.highlight(X_COLOR)
j_label = vector_coordinate_label(self.j_hat)
j_label.highlight(Y_COLOR)
for mob in i_label, j_label:
mob.scale_in_place(0.8)
background = BackgroundRectangle(mob)
self.play(ShowCreation(background), Write(mob))
self.dither()
x, y = vect_array.get_entries().split()
pre_formula = VMobject(
x, i_label, TexMobject("+"),
y, j_label
)
post_formula = pre_formula.copy()
pre_formula.split()[2].fade(1)
post_formula.arrange_submobjects(buff = 0.1)
post_formula.next_to(vect, DOWN)
background = BackgroundRectangle(post_formula)
everything = self.get_mobjects()
everything.remove(vect)
self.play(*[
ApplyMethod(m.fade) for m in everything
] + [
ShowCreation(background, run_time = 2, rate_func = squish_rate_func(smooth, 0.5, 1)),
Transform(pre_formula.copy(), post_formula, run_time = 2),
ApplyMethod(vect.set_stroke, width = 7)
])
self.dither()
示例2: show_scaled_vectors
# 需要导入模块: from mobject.vectorized_mobject import VMobject [as 别名]
# 或者: from mobject.vectorized_mobject.VMobject import copy [as 别名]
def show_scaled_vectors(self, vect_array, vect_coords, i_label, j_label):
x, y = vect_array.get_entries().split()
scaled_i_label = VMobject(x.copy(), i_label.copy())
scaled_j_label = VMobject(y.copy(), j_label.copy())
scaled_i = self.i_hat.copy().scale(vect_coords[0])
scaled_j = self.j_hat.copy().scale(vect_coords[1])
for mob in scaled_i, scaled_j:
mob.fade(0.3)
scaled_i_label_target = scaled_i_label.copy()
scaled_i_label_target.arrange_submobjects(buff = 0.1)
scaled_i_label_target.next_to(scaled_i.get_center(), DOWN)
scaled_j_label_target = scaled_j_label.copy()
scaled_j_label_target.arrange_submobjects(buff = 0.1)
scaled_j_label_target.next_to(scaled_j.get_center(), LEFT)
self.play(
Transform(self.i_hat.copy(), scaled_i),
Transform(scaled_i_label, scaled_i_label_target)
)
scaled_i = self.get_mobjects_from_last_animation()[0]
self.play(
Transform(self.j_hat.copy(), scaled_j),
Transform(scaled_j_label, scaled_j_label_target)
)
scaled_j = self.get_mobjects_from_last_animation()[0]
self.play(*[
ApplyMethod(mob.shift, scaled_i.get_end())
for mob in scaled_j, scaled_j_label
])
self.dither()
self.play(*map(FadeOut, [
scaled_i, scaled_j, scaled_i_label, scaled_j_label,
]))
示例3: construct
# 需要导入模块: from mobject.vectorized_mobject import VMobject [as 别名]
# 或者: from mobject.vectorized_mobject.VMobject import copy [as 别名]
def construct(self):
self.setup()
self.add_unit_square()
matrix = Matrix(np.array(self.t_matrix).transpose())
matrix.next_to(ORIGIN, LEFT)
matrix.to_edge(UP)
matrix.highlight_columns(X_COLOR, Y_COLOR)
det_text = get_det_text(
matrix, determinant = np.linalg.det(self.t_matrix)
)
three = VMobject(*det_text.split()[-1].split()[1:])
for mob in det_text.split():
if isinstance(mob, TexMobject):
mob.add_background_rectangle()
matrix_background = BackgroundRectangle(matrix)
self.play(
ShowCreation(matrix_background),
Write(matrix),
Write(det_text),
)
self.add_foreground_mobject(matrix_background, matrix, det_text)
self.dither()
self.apply_transposed_matrix(self.t_matrix)
self.play(three.copy().move_to, self.square)
self.dither()
示例4: construct
# 需要导入模块: from mobject.vectorized_mobject import VMobject [as 别名]
# 或者: from mobject.vectorized_mobject.VMobject import copy [as 别名]
def construct(self):
vect_coords = [-1, 2]
t_matrix = np.array([[2, 2], [-2, 1]])
#Draw vectors
self.setup()
i_label = self.add_transformable_label(
self.i_hat, "\\hat{\\imath}", animate = False,
direction = "right", color = X_COLOR
)
j_label = self.add_transformable_label(
self.j_hat, "\\hat{\\jmath}", animate = False,
direction = "right", color = Y_COLOR
)
vect = self.add_vector(vect_coords)
vect_array = Matrix(["x", "y"], add_background_rectangles = True)
v_equals = TexMobject(["\\vec{\\textbf{v}}", "="])
v_equals.split()[0].highlight(YELLOW)
v_equals.next_to(vect_array, LEFT)
vect_array.add(v_equals)
vect_array.to_edge(UP, buff = 0.2)
background_rect = BackgroundRectangle(vect_array)
vect_array.get_entries().highlight(YELLOW)
self.play(ShowCreation(background_rect), Write(vect_array))
self.add_foreground_mobject(background_rect, vect_array)
#Show scaled vectors
x, y = vect_array.get_entries().split()
scaled_i_label = VMobject(x.copy(), i_label)
scaled_j_label = VMobject(y.copy(), j_label)
scaled_i = self.i_hat.copy().scale(vect_coords[0])
scaled_j = self.j_hat.copy().scale(vect_coords[1])
for mob in scaled_i, scaled_j:
mob.fade(0.3)
scaled_i_label_target = scaled_i_label.copy()
scaled_i_label_target.arrange_submobjects(buff = 0.1)
scaled_i_label_target.next_to(scaled_i, DOWN)
scaled_j_label_target = scaled_j_label.copy()
scaled_j_label_target.arrange_submobjects(buff = 0.1)
scaled_j_label_target.next_to(scaled_j, LEFT)
self.show_scaled_vectors(vect_array, vect_coords, i_label, j_label)
self.apply_transposed_matrix(t_matrix)
self.show_scaled_vectors(vect_array, vect_coords, i_label, j_label)
self.record_basis_coordinates(vect_array, vect)
示例5: construct
# 需要导入模块: from mobject.vectorized_mobject import VMobject [as 别名]
# 或者: from mobject.vectorized_mobject.VMobject import copy [as 别名]
def construct(self):
physy = Physicist()
compy = ComputerScientist()
physy.title = TextMobject("Physics student").to_corner(DOWN+LEFT)
compy.title = TextMobject("CS student").to_corner(DOWN+RIGHT)
for pi in physy, compy:
pi.next_to(pi.title, UP)
self.add(pi, pi.title)
compy_speech = compy.get_bubble("speech")
physy_speech = physy.get_bubble("speech")
arrow = Vector([2, 1])
array = matrix_to_mobject([2, 1])
goes_to = TexMobject("\\Rightarrow")
physy_statement = VMobject(arrow, goes_to, array)
physy_statement.arrange_submobjects(RIGHT)
compy_statement = physy_statement.copy()
compy_statement.arrange_submobjects(LEFT)
physy_speech.position_mobject_inside(physy_statement)
compy_speech.position_mobject_inside(compy_statement)
new_arrow = Vector([2, 1])
x_line = Line(ORIGIN, 2*RIGHT, color = X_COLOR)
y_line = Line(2*RIGHT, 2*RIGHT+UP, color = Y_COLOR)
x_mob = TexMobject("2").next_to(x_line, DOWN)
y_mob = TexMobject("1").next_to(y_line, RIGHT)
new_arrow.add(x_line, y_line, x_mob, y_mob)
back_and_forth = VMobject(
new_arrow,
TexMobject("\\Leftrightarrow"),
matrix_to_mobject([2, 1])
)
back_and_forth.arrange_submobjects(LEFT).center()
self.dither()
self.play(
ApplyMethod(physy.change_mode, "speaking"),
ShowCreation(physy_speech),
Write(physy_statement),
run_time = 1
)
self.play(Blink(compy))
self.play(
ApplyMethod(physy.change_mode, "sassy"),
ApplyMethod(compy.change_mode, "speaking"),
FadeOut(physy_speech),
ShowCreation(compy_speech),
Transform(physy_statement, compy_statement, path_arc = np.pi)
)
self.dither(2)
self.play(
ApplyMethod(physy.change_mode, "pondering"),
ApplyMethod(compy.change_mode, "pondering"),
Transform(compy_speech, VectorizedPoint(compy_speech.get_tip())),
Transform(physy_statement, back_and_forth)
)
self.dither()
示例6: show_ghost_movement
# 需要导入模块: from mobject.vectorized_mobject import VMobject [as 别名]
# 或者: from mobject.vectorized_mobject.VMobject import copy [as 别名]
def show_ghost_movement(self, vector):
if isinstance(vector, Arrow):
vector = vector.get_end() - vector.get_start()
elif len(vector) == 2:
vector = np.append(np.array(vector), 0.0)
x_max = int(SPACE_WIDTH + abs(vector[0]))
y_max = int(SPACE_HEIGHT + abs(vector[1]))
dots = VMobject(*[
Dot(x*RIGHT + y*UP)
for x in range(-x_max, x_max)
for y in range(-y_max, y_max)
])
dots.set_fill(BLACK, opacity = 0)
dots_halfway = dots.copy().shift(vector/2).set_fill(WHITE, 1)
dots_end = dots.copy().shift(vector)
self.play(Transform(
dots, dots_halfway, rate_func = rush_into
))
self.play(Transform(
dots, dots_end, rate_func = rush_from
))
self.remove(dots)
示例7: series_of_videos
# 需要导入模块: from mobject.vectorized_mobject import VMobject [as 别名]
# 或者: from mobject.vectorized_mobject.VMobject import copy [as 别名]
def series_of_videos(self, chapters):
icon = SVGMobject("video_icon")
icon.center()
icon.scale_to_fit_width(2*SPACE_WIDTH/12.)
icon.set_stroke(color = WHITE, width = 0)
icons = [icon.copy() for chapter in chapters.split()]
colors = Color(BLUE_A).range_to(BLUE_D, len(icons))
for icon, color in zip(icons, colors):
icon.set_fill(color, opacity = 1)
icons = VMobject(*icons)
icons.arrange_submobjects(RIGHT)
icons.to_edge(LEFT)
icons.shift(UP)
randy = Randolph()
randy.to_corner()
bubble = randy.get_bubble()
new_icons = icons.copy().scale(0.2)
bubble.position_mobject_inside(new_icons)
self.play(Transform(
chapters, icons,
path_arc = np.pi/2,
))
self.clear()
self.add(icons)
self.play(FadeIn(randy))
self.play(Blink(randy))
self.dither()
self.play(
ShowCreation(bubble),
Transform(icons, new_icons)
)
self.remove(icons)
bubble.make_green_screen()
self.dither()
示例8: get_piece_movement
# 需要导入模块: from mobject.vectorized_mobject import VMobject [as 别名]
# 或者: from mobject.vectorized_mobject.VMobject import copy [as 别名]
def get_piece_movement(self, pieces):
start = VMobject(*pieces)
target = VMobject(*[mob.target for mob in pieces])
if self.leave_ghost_vectors:
self.add(start.copy().fade(0.7))
return Transform(start, target, submobject_mode = "all_at_once")
示例9: construct
# 需要导入模块: from mobject.vectorized_mobject import VMobject [as 别名]
# 或者: from mobject.vectorized_mobject.VMobject import copy [as 别名]
def construct(self):
matrix = Matrix(np.arange(9).reshape((3, 3)))
vect = Matrix(list("xyz"))
vect.scale_to_fit_height(matrix.get_height())
col1, col2, col3 = columns = [
Matrix(col)
for col in matrix.copy().get_mob_matrix().transpose()
]
coords = x, y, z = [m.copy() for m in vect.get_entries().split()]
eq, plus1, plus2 = map(TexMobject, list("=++"))
everything = VMobject(
matrix, vect, eq,
x, col1, plus1,
y, col2, plus2,
z, col3
)
everything.arrange_submobjects(buff = 0.1)
everything.scale_to_fit_width(2*SPACE_WIDTH-1)
result = VMobject(x, col1, plus1, y, col2, plus2, z, col3)
trips = [
(matrix, DOWN, "Transformation"),
(vect, UP, "Input vector"),
(result, DOWN, "Output vector"),
]
braces = []
for mob, direction, text in trips:
brace = Brace(mob, direction)
words = TextMobject(text)
words.next_to(brace, direction)
brace.add(words)
braces.append(brace)
matrix_brace, vect_brace, result_brace = braces
self.play(*map(Write, [matrix, vect]), run_time = 2)
self.play(Write(matrix_brace, run_time = 1))
self.play(Write(vect_brace, run_time = 1))
sexts = zip(
matrix.get_mob_matrix().transpose(),
columns,
vect.get_entries().split(),
coords,
[eq, plus1, plus2],
[X_COLOR, Y_COLOR, Z_COLOR]
)
for o_col, col, start_coord, coord, sym, color in sexts:
o_col = VMobject(*o_col)
self.play(
start_coord.highlight, YELLOW,
o_col.highlight, color
)
coord.highlight(YELLOW)
col.highlight(color)
self.play(
Write(col.get_brackets()),
Transform(
o_col.copy(), col.get_entries(),
path_arc = -np.pi
),
Transform(
start_coord.copy(), coord,
path_arc = -np.pi
),
Write(sym)
)
self.dither()
self.play(Write(result_brace, run_time = 1))
self.dither()