本文整理汇总了Python中mobject.tex_mobject.TexMobject.get_center方法的典型用法代码示例。如果您正苦于以下问题:Python TexMobject.get_center方法的具体用法?Python TexMobject.get_center怎么用?Python TexMobject.get_center使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mobject.tex_mobject.TexMobject
的用法示例。
在下文中一共展示了TexMobject.get_center方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: construct
# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import get_center [as 别名]
def construct(self):
in_vect = Matrix(self.input_coords)
out_vect = Matrix(self.output_coords)
in_vect.highlight(BLUE)
out_vect.highlight(GREEN)
func = TexMobject("L(\\vec{\\textbf{v}})")
point = VectorizedPoint(func.get_center())
in_vect.next_to(func, LEFT, buff = 1)
out_vect.next_to(func, RIGHT, buff = 1)
in_words = TextMobject("Input")
in_words.next_to(in_vect, DOWN)
in_words.highlight(BLUE_C)
out_words = TextMobject("Output")
out_words.next_to(out_vect, DOWN)
out_words.highlight(GREEN_C)
title = TextMobject(self.title)
title.to_edge(UP)
self.add(title)
self.play(Write(func))
self.play(Write(in_vect), Write(in_words))
self.dither()
self.add(in_vect.copy())
self.play(Transform(in_vect, point, submobject_mode = "lagged_start"))
self.play(Transform(in_vect, out_vect, submobject_mode = "lagged_start"))
self.add(out_words)
self.dither()
示例2: construct
# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import get_center [as 别名]
def construct(self, order):
if order == 2:
result_tex = "(0.125, 0.75)"
elif order == 3:
result_tex = "(0.0758, 0.6875)"
phc, arg, result = TexMobject([
"\\text{PHC}_%d"%order,
"(0.3)",
"= %s"%result_tex
]).to_edge(UP).split()
function = TextMobject("Function", size = "\\normal")
function.shift(phc.get_center()+DOWN+2*LEFT)
function_arrow = Arrow(function, phc)
line = Line(5*LEFT, 5*RIGHT)
curve = HilbertCurve(order = order)
line.match_colors(curve)
grid = Grid(2**order, 2**order)
grid.fade()
for mob in curve, grid:
mob.scale(0.7)
index = int(0.3*line.get_num_points())
dot1 = Dot(line.points[index])
arrow1 = Arrow(arg, dot1, buff = 0.1)
dot2 = Dot(curve.points[index])
arrow2 = Arrow(result.get_bottom(), dot2, buff = 0.1)
self.add(phc)
self.play(
ShimmerIn(function),
ShowCreation(function_arrow)
)
self.dither()
self.remove(function_arrow, function)
self.play(ShowCreation(line))
self.dither()
self.play(
ShimmerIn(arg),
ShowCreation(arrow1),
ShowCreation(dot1)
)
self.dither()
self.remove(arrow1)
self.play(
FadeIn(grid),
Transform(line, curve),
Transform(dot1, dot2),
run_time = 2
)
self.dither()
self.play(
ShimmerIn(result),
ShowCreation(arrow2)
)
self.dither()
示例3: solve_energy
# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import get_center [as 别名]
def solve_energy(self):
loss_in_potential = TextMobject("Loss in potential: ")
loss_in_potential.shift(2*UP)
potential = TexMobject("m g y".split())
potential.next_to(loss_in_potential)
kinetic = TexMobject([
"\\dfrac{1}{2}","m","v","^2","="
])
kinetic.next_to(potential, LEFT)
nudge = 0.1*UP
kinetic.shift(nudge)
loss_in_potential.shift(nudge)
ms = Mobject(kinetic.split()[1], potential.split()[0])
two = TexMobject("2")
two.shift(ms.split()[1].get_center())
half = kinetic.split()[0]
sqrt = TexMobject("\\sqrt{\\phantom{2mg}}")
sqrt.shift(potential.get_center())
nudge = 0.2*LEFT
sqrt.shift(nudge)
squared = kinetic.split()[3]
equals = kinetic.split()[-1]
new_eq = equals.copy().next_to(kinetic.split()[2])
self.play(
Transform(
Point(loss_in_potential.get_left()),
loss_in_potential
),
*map(GrowFromCenter, potential.split())
)
self.dither(2)
self.play(
FadeOut(loss_in_potential),
GrowFromCenter(kinetic)
)
self.dither(2)
self.play(ApplyMethod(ms.shift, 5*UP))
self.dither()
self.play(Transform(
half, two,
path_func = counterclockwise_path()
))
self.dither()
self.play(
Transform(
squared, sqrt,
path_func = clockwise_path()
),
Transform(equals, new_eq)
)
self.dither(2)
示例4: get_top_inverse_rules
# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import get_center [as 别名]
def get_top_inverse_rules():
result = []
pairs = [#Careful of order here!
(0, 2),
(0, 1),
(1, 0),
(1, 2),
(2, 0),
(2, 1),
]
for i, j in pairs:
top = get_top_inverse(i, j)
char = ["x", "y", "z"][j]
eq = TexMobject("= %s"%char)
eq.scale(2)
eq.next_to(top, RIGHT)
diff = eq.get_center() - top.triangle.get_center()
eq.shift(diff[1]*UP)
result.append(VMobject(top, eq))
return result
示例5: construct
# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import get_center [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)
示例6: Notation
# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import get_center [as 别名]
class Notation(Scene):
def construct(self):
self.introduce_notation()
self.shift_to_good_and_back()
self.shift_to_visuals()
self.swipe_left()
def introduce_notation(self):
notation = TextMobject("Notation")
notation.to_edge(UP)
self.sum1 = TexMobject("\\sum_{n=1}^\\infty \\dfrac{1}{n}")
self.prod1 = TexMobject("\\prod_{p\\text{ prime}}\\left(1-p^{-s}\\right)")
self.trigs1 = TexMobject([
["\\sin", "(x)"],
["\\cos", "(x)"],
["\\tan", "(x)"],
], next_to_direction = DOWN)
self.func1 = TexMobject("f(x) = y")
symbols = [self.sum1, self.prod1, self.trigs1, self.func1]
for sym, vect in zip(symbols, compass_directions(4, UP+LEFT)):
sym.scale(0.5)
vect[0] *= 2
sym.shift(vect)
self.symbols = VMobject(*symbols)
self.play(Write(notation))
self.play(Write(self.symbols))
self.dither()
self.add(notation, self.symbols)
def shift_to_good_and_back(self):
sum2 = self.sum1.copy()
sigma = sum2.submobjects[1]
plus = TexMobject("+").replace(sigma)
sum2.submobjects[1] = plus
prod2 = self.prod1.copy()
pi = prod2.submobjects[0]
times = TexMobject("\\times").replace(pi)
prod2.submobjects[0] = times
new_sin, new_cos, new_tan = [
VMobject().set_anchor_points(
corners, mode = "corners"
).replace(trig_part.split()[0])
for corners, trig_part in zip(
[
[RIGHT, RIGHT+UP, LEFT],
[RIGHT+UP, LEFT, RIGHT],
[RIGHT+UP, RIGHT, LEFT],
],
self.trigs1.split()
)
]
x1, x2, x3 = [
trig_part.split()[1]
for trig_part in self.trigs1.split()
]
trigs2 = VMobject(
VMobject(new_sin, x1),
VMobject(new_cos, x2),
VMobject(new_tan, x3),
)
x, arrow, y = TexMobject("x \\rightarrow y").split()
f = TexMobject("f")
f.next_to(arrow, UP)
func2 = VMobject(f, VMobject(), x, VMobject(), arrow, y)
func2.scale(0.5)
func2.shift(self.func1.get_center())
good_symbols = VMobject(sum2, prod2, trigs2, func2)
bad_symbols = self.symbols.copy()
self.play(Transform(
self.symbols, good_symbols,
path_arc = np.pi
))
self.dither(3)
self.play(Transform(
self.symbols, bad_symbols,
path_arc = np.pi
))
self.dither()
def shift_to_visuals(self):
sigma, prod, trig, func = self.symbols.split()
new_trig = trig.copy()
sin, cos, tan = [
trig_part.split()[0]
for trig_part in new_trig.split()
]
trig_anim = TrigAnimation()
sin.highlight(trig_anim.sin_color)
cos.highlight(trig_anim.cos_color)
tan.highlight(trig_anim.tan_color)
#.........这里部分代码省略.........