本文整理汇总了Python中mobject.tex_mobject.TexMobject.replace方法的典型用法代码示例。如果您正苦于以下问题:Python TexMobject.replace方法的具体用法?Python TexMobject.replace怎么用?Python TexMobject.replace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mobject.tex_mobject.TexMobject
的用法示例。
在下文中一共展示了TexMobject.replace方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: initialize_bits
# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import replace [as 别名]
def initialize_bits(self):
bits = bit_string_to_mobject("")
bits.to_corner(UP+LEFT)
one = TexMobject("1")[0]
one.replace(bits[0], dim_to_match = 1)
self.add(bits)
self.add_foreground_mobject(VGroup(*bits[-15:]))
self.number = 0
self.bits = bits
self.one = one
self.zero = bits[0].copy()
示例2: construct
# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import replace [as 别名]
def construct(self):
top = TOP()
times = top.put_in_vertex(0, TexMobject("\\times"))
times.highlight(YELLOW)
oplus = top.put_in_vertex(1, TexMobject("\\oplus"))
oplus.highlight(BLUE)
dot = top.put_in_vertex(2, Dot())
eight = top.put_on_vertex(2, TexMobject("8"))
self.add(top)
self.play(ShowCreation(eight))
for mob in dot, oplus, times:
self.play(ShowCreation(mob))
self.dither()
top.add(eight)
top.add(times, oplus, dot)
top1, top2, top3 = tops = [
top.copy() for i in range(3)
]
big_oplus = TexMobject("\\oplus").scale(2).highlight(BLUE)
equals = TexMobject("=")
equation = VMobject(
top1, big_oplus, top2, equals, top3
)
equation.arrange_submobjects()
top3.shift(0.5*RIGHT)
x, y, xy = [
t.put_on_vertex(0, s)
for t, s in zip(tops, ["x", "y", "xy"])
]
old_style_eq = TexMobject(
"\\dfrac{1}{\\frac{1}{\\log_x(8)} + \\frac{1}{\\log_y(8)}} = \\log_{xy}(8)"
)
old_style_eq.to_edge(UP).highlight(RED)
triple_top_copy = VMobject(*[
top.copy() for i in range(3)
])
self.clear()
self.play(
Transform(triple_top_copy, VMobject(*tops)),
FadeIn(VMobject(x, y, xy, big_oplus, equals))
)
self.remove(triple_top_copy)
self.add(*tops)
self.play(Write(old_style_eq))
self.dither(3)
syms = VMobject(x, y, xy)
new_syms = VMobject(*[
t.put_on_vertex(1, s)
for t, s in zip(tops, ["x", "y", "x \\oplus y"])
])
new_old_style_eq = TexMobject(
"\\sqrt[x]{8} \\sqrt[y]{8} = \\sqrt[X]{8}"
)
X = new_old_style_eq.split()[-4]
frac = TexMobject("\\frac{1}{\\frac{1}{x} + \\frac{1}{y}}")
frac.replace(X)
frac_lower_right = frac.get_corner(DOWN+RIGHT)
frac.scale(2)
frac.shift(frac_lower_right - frac.get_corner(DOWN+RIGHT))
new_old_style_eq.submobjects[-4] = frac
new_old_style_eq.to_edge(UP)
new_old_style_eq.highlight(RED)
big_times = TexMobject("\\times").highlight(YELLOW)
big_times.shift(big_oplus.get_center())
self.play(
Transform(old_style_eq, new_old_style_eq),
Transform(syms, new_syms, path_arc = np.pi/2),
Transform(big_oplus, big_times)
)
self.dither(4)
示例3: construct
# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import replace [as 别名]
def construct(self):
title = TextMobject("``Linearly dependent'' ")
title.highlight(YELLOW)
title.scale(2)
title.to_edge(UP)
self.add(title)
equation1 = TexMobject([
"\\vec{\\textbf{w}}",
"=",
"a",
"\\vec{\\textbf{v}}",
])
w, eq, a, v = equation1.split()
w.highlight(BLUE)
v.highlight(MAROON_C)
equation1.scale(2)
eq1_copy = equation1.copy()
low_words1 = TextMobject("For some value of $a$")
low_words1.scale(2)
low_words1.to_edge(DOWN)
arrow = Arrow(low_words1, a)
arrow_copy = arrow.copy()
equation2 = TexMobject([
"\\vec{\\textbf{u}}",
"=",
"a",
"\\vec{\\textbf{v}}",
"+",
"b",
"\\vec{\\textbf{w}}",
])
u, eq, a, v, plus, b, w = equation2.split()
u.highlight(RED)
w.highlight(BLUE)
v.highlight(MAROON_C)
equation2.scale(2)
eq2_copy = equation2.copy()
low_words2 = TextMobject("For some values of a and b")
low_words2.scale(2)
low_words2.to_edge(DOWN)
arrows = VMobject(*[
Arrow(low_words2, var)
for var in a, b
])
self.play(Write(equation1))
self.play(
ShowCreation(arrow),
Write(low_words1)
)
self.dither()
self.play(
Transform(equation1, equation2),
Transform(low_words1, low_words2),
Transform(arrow, arrows)
)
self.dither(2)
new_title = TextMobject("``Linearly independent'' ")
new_title.highlight(GREEN)
new_title.replace(title)
for eq_copy in eq1_copy, eq2_copy:
neq = TexMobject("\\neq")
neq.replace(eq_copy.submobjects[1])
eq_copy.submobjects[1] = neq
new_low_words1 = TextMobject(["For", "all", "values of a"])
new_low_words2 = TextMobject(["For", "all", "values of a and b"])
for low_words in new_low_words1, new_low_words2:
low_words.split()[1].highlight(GREEN)
low_words.scale(2)
low_words.to_edge(DOWN)
self.play(
Transform(title, new_title),
Transform(equation1, eq1_copy),
Transform(arrow, arrow_copy),
Transform(low_words1, new_low_words1)
)
self.dither()
self.play(
Transform(equation1, eq2_copy),
Transform(arrow, arrows),
Transform(low_words1, new_low_words2)
)
self.dither()