本文整理汇总了Python中mobject.tex_mobject.TexMobject.add_background_rectangle方法的典型用法代码示例。如果您正苦于以下问题:Python TexMobject.add_background_rectangle方法的具体用法?Python TexMobject.add_background_rectangle怎么用?Python TexMobject.add_background_rectangle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mobject.tex_mobject.TexMobject
的用法示例。
在下文中一共展示了TexMobject.add_background_rectangle方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_vector_label
# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import add_background_rectangle [as 别名]
def get_vector_label(self, vector, label,
direction = "left",
rotate = False,
color = None,
label_scale_factor = VECTOR_LABEL_SCALE_FACTOR):
if not isinstance(label, TexMobject):
if len(label) == 1:
label = "\\vec{\\textbf{%s}}"%label
label = TexMobject(label)
if color is None:
color = vector.get_color()
label.highlight(color)
label.scale(label_scale_factor)
label.add_background_rectangle()
angle = vector.get_angle()
if not rotate:
label.rotate(-angle)
if direction is "left":
label.shift(-label.get_bottom() + 0.1*UP)
else:
label.shift(-label.get_top() + 0.1*DOWN)
label.rotate(angle)
label.shift((vector.get_end() - vector.get_start())/2)
return label
示例2: get_matrices
# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import add_background_rectangle [as 别名]
def get_matrices(self):
m1_mob = Matrix(np.array(self.t_matrix1).transpose())
m2_mob = Matrix(np.array(self.t_matrix2).transpose())
comp_matrix = Matrix([["?", "?"], ["?", "?"]])
m1_mob.highlight(YELLOW)
m2_mob.highlight(PINK)
comp_matrix.get_entries().submobject_gradient_highlight(YELLOW, PINK)
equals = TexMobject("=")
equals.next_to(comp_matrix, LEFT)
comp_matrix.add(equals)
m1_mob = VMobject(BackgroundRectangle(m1_mob), m1_mob)
m2_mob = VMobject(BackgroundRectangle(m2_mob), m2_mob)
comp_matrix = VMobject(BackgroundRectangle(comp_matrix), comp_matrix)
VMobject(
m2_mob, m1_mob, comp_matrix
).arrange_submobjects(buff = 0.1).to_corner(UP+LEFT).shift(DOWN)
for i, mob in enumerate([m1_mob, m2_mob]):
brace = Brace(mob, UP)
text = TexMobject("M_%d"%(i+1))
text.next_to(brace, UP)
brace.add_background_rectangle()
text.add_background_rectangle()
brace.add(text)
mob.label = brace
return m1_mob, m2_mob, comp_matrix
示例3: construct
# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import add_background_rectangle [as 别名]
def construct(self):
v_tex = "\\vec{\\textbf{v}}"
eq = TexMobject("A", v_tex, "=", "\\lambda", v_tex)
eq.highlight_by_tex(v_tex, YELLOW)
eq.highlight_by_tex("\\lambda", MAROON_B)
eq.scale(3)
eq.add_background_rectangle()
eq.shift(2*DOWN)
title = TextMobject(
"Eigen", "vectors \\\\",
"Eigen", "values"
, arg_separator = "")
title.scale(2.5)
title.to_edge(UP)
# title.highlight_by_tex("Eigen", MAROON_B)
title[0].highlight(YELLOW)
title[2].highlight(MAROON_B)
title.add_background_rectangle()
self.add_vector([-1, 1], color = YELLOW, animate = False)
self.apply_transposed_matrix([[3, 0], [1, 2]])
self.plane.fade()
self.remove(self.j_hat)
self.add(eq, title)
示例4: get_axis_labels
# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import add_background_rectangle [as 别名]
def get_axis_labels(self, x_label = "x", y_label = "y"):
x_axis, y_axis = self.get_axes().split()
quads = [
(x_axis, x_label, UP, RIGHT),
(y_axis, y_label, RIGHT, UP),
]
labels = VGroup()
for axis, tex, vect, edge in quads:
label = TexMobject(tex)
label.add_background_rectangle()
label.next_to(axis, vect)
label.to_edge(edge)
labels.add(label)
self.axis_labels = labels
return labels
示例5: construct
# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import add_background_rectangle [as 别名]
def construct(self):
self.setup()
self.add_unit_square()
a, b, c, d = 3, 2, 3.5, 2
self.dither()
self.apply_transposed_matrix([[a, 0], [0, 1]])
i_brace = Brace(self.i_hat, DOWN)
width = TexMobject("a").scale(1.5)
i_brace.put_at_tip(width)
width.highlight(X_COLOR)
width.add_background_rectangle()
self.play(GrowFromCenter(i_brace), Write(width))
self.dither()
self.apply_transposed_matrix([[1, 0], [0, d]])
side_brace = Brace(self.square, RIGHT)
height = TexMobject("d").scale(1.5)
side_brace.put_at_tip(height)
height.highlight(Y_COLOR)
height.add_background_rectangle()
self.play(GrowFromCenter(side_brace), Write(height))
self.dither()
self.apply_transposed_matrix(
[[1, 0], [float(b)/d, 1]],
added_anims = [
ApplyMethod(m.shift, b*RIGHT)
for m in side_brace, height
]
)
self.dither()
self.play(*map(FadeOut, [i_brace, side_brace, width, height]))
matrix1 = np.dot(
[[a, b], [c, d]],
np.linalg.inv([[a, b], [0, d]])
)
matrix2 = np.dot(
[[a, b], [-c, d]],
np.linalg.inv([[a, b], [c, d]])
)
self.apply_transposed_matrix(matrix1.transpose(), path_arc = 0)
self.dither()
self.apply_transposed_matrix(matrix2.transpose(), path_arc = 0)
self.dither()
示例6: get_coordinate_labels
# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import add_background_rectangle [as 别名]
def get_coordinate_labels(self, x_vals = None, y_vals = None):
result = []
if x_vals == None and y_vals == None:
x_vals = range(-int(self.x_radius), int(self.x_radius))
y_vals = range(-int(self.y_radius), int(self.y_radius))
for index, vals in enumerate([x_vals, y_vals]):
num_pair = [0, 0]
for val in vals:
if val == 0:
continue
num_pair[index] = val
point = self.coords_to_point(*num_pair)
num = TexMobject(str(val))
num.add_background_rectangle()
num.scale_to_fit_height(
self.written_coordinate_height
)
vect = DOWN if index == 0 else LEFT
num.next_to(point, vect, buff = SMALL_BUFF)
result.append(num)
return result
示例7: get_line_brace_text
# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import add_background_rectangle [as 别名]
def get_line_brace_text(self, func_name = "sin"):
line = self.get_trig_line(func_name)
angle = line.get_angle()
vect = rotate_vector(UP, angle)
vect = np.round(vect, 1)
if (vect[1] < 0) ^ (func_name is "sec"):
vect = -vect
angle += np.pi
brace = Brace(
Line(
line.get_length()*LEFT/2,
line.get_length()*RIGHT/2,
),
UP
)
brace.rotate(angle)
brace.shift(line.get_center())
brace.highlight(line.get_color())
text = TexMobject("\\%s(\\theta)"%func_name)
text.scale(0.75)
text[-2].highlight(self.theta_color)
text.add_background_rectangle()
text.next_to(brace.get_center_of_mass(), vect, buff = 1.2*MED_SMALL_BUFF)
return VGroup(line, brace, text)
示例8: construct
# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import add_background_rectangle [as 别名]
def construct(self):
self.setup()
symbols = TexMobject(list(self.symbols_str))
symbols.scale(1.5)
symbols.to_edge(UP)
a, b, c = None, None, None
for mob, letter in zip(symbols.split(), self.symbols_str):
if letter == "A":
a = mob
elif letter == "B":
b = mob
elif letter == "C":
c = mob
symbols.add_background_rectangle()
self.add_foreground_mobject(symbols)
brace = Brace(c, DOWN)
words = TextMobject("Apply this transformation")
words.add_background_rectangle()
words.next_to(brace, DOWN)
brace.add(words)
self.play(Write(brace, run_time = 1))
self.add_foreground_mobject(brace)
last = VectorizedPoint()
for t_matrix, sym in zip(self.t_matrices, [c, b, a]):
self.play(
brace.next_to, sym, DOWN,
sym.highlight, YELLOW,
last.highlight, WHITE
)
self.apply_transposed_matrix(t_matrix, run_time = 1)
last = sym
self.dither()