本文整理汇总了Python中mobject.tex_mobject.TexMobject.to_edge方法的典型用法代码示例。如果您正苦于以下问题:Python TexMobject.to_edge方法的具体用法?Python TexMobject.to_edge怎么用?Python TexMobject.to_edge使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mobject.tex_mobject.TexMobject
的用法示例。
在下文中一共展示了TexMobject.to_edge方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: construct
# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import to_edge [as 别名]
def construct(self):
definition = TexMobject([
"\\text{HC}(", "x", ")",
"=\\lim_{n \\to \\infty}\\text{PHC}_n(", "x", ")"
])
definition.to_edge(UP)
definition.split()[1].highlight(BLUE)
definition.split()[-2].highlight(BLUE)
intro = TextMobject("Three things need to be proven")
prove_that = TextMobject("Prove that HC is $\\dots$")
prove_that.scale(0.7)
prove_that.to_edge(LEFT)
items = TextMobject([
"\\begin{enumerate}",
"\\item Well-defined: ",
"Points on Pseudo-Hilbert-curves really do converge",
"\\item A Curve: ",
"HC is continuous",
"\\item Space-filling: ",
"Each point in the unit square is an output of HC",
"\\end{enumerate}",
]).split()
items[1].highlight(GREEN)
items[3].highlight(YELLOW_C)
items[5].highlight(MAROON)
Mobject(*items).to_edge(RIGHT)
self.add(definition)
self.play(ShimmerIn(intro))
self.dither()
self.play(Transform(intro, prove_that))
for item in items[1:-1]:
self.play(ShimmerIn(item))
self.dither()
示例2: construct
# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import to_edge [as 别名]
def construct(self):
exp = TexMobject("x^y = z")
log = TexMobject("\\log_x(z) = y")
rad = TexMobject("\\sqrt[y]{z} = x")
exp.to_edge(LEFT).shift(2*UP)
rad.to_edge(RIGHT).shift(2*DOWN)
x1, y1, eq, z1 = exp.split()
l, o, g, x2, p, z2, p, eq, y2 = log.split()
y3, r, r, z3, eq, x3 = rad.split()
vars1 = VMobject(x1, y1, z1).copy()
vars2 = VMobject(x2, y2, z2)
vars3 = VMobject(x3, y3, z3)
self.play(Write(exp))
self.play(Transform(vars1, vars2, path_arc = -np.pi))
self.play(Write(log))
self.play(Transform(vars1, vars3, path_arc = -np.pi))
self.play(Write(rad))
self.dither()
words = TextMobject("Artificially unrelated")
words.to_corner(UP+RIGHT)
words.highlight(YELLOW)
self.play(Write(words))
self.dither()
示例3: construct
# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import to_edge [as 别名]
def construct(self):
eq1 = TexMobject(
"\\text{secant}(\\theta) = \\frac{1}{\\text{cosine}(\\theta)}"
)
eq2 = TexMobject(
"\\text{cosecant}(\\theta) = \\frac{1}{\\text{sine}(\\theta)}"
)
eq1.to_corner(UP+LEFT)
eq1.to_edge(LEFT)
eq2.next_to(eq1, DOWN, buff = LARGE_BUFF)
eqs = VGroup(eq1, eq2)
self.play(
self.get_teacher().change_mode, "speaking",
Write(eqs),
*[
ApplyMethod(pi.look_at, eqs)
for pi in self.get_students()
]
)
self.random_blink()
self.play(
VGroup(*eq1[-9:-7]).highlight, YELLOW,
VGroup(*eq2[:2]).highlight, YELLOW,
*[
ApplyMethod(pi.change_mode, "confused")
for pi in self.get_students()
]
)
self.random_blink(2)
示例4: construct
# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import to_edge [as 别名]
def construct(self):
matrix = Matrix([
[2, 0],
[-1, 1],
[-2, 1],
])
matrix.highlight_columns(X_COLOR, Y_COLOR)
rows_brace = Brace(matrix, LEFT)
rows_words = rows_brace.get_text("3", "rows")
rows_words.highlight(PINK)
cols_brace = Brace(matrix, UP)
cols_words = cols_brace.get_text("2", "columns")
cols_words.highlight(TEAL)
title = TexMobject("3", "\\times", "2", "\\text{ matrix}")
title.to_edge(UP)
self.add(matrix)
self.play(
GrowFromCenter(rows_brace),
Write(rows_words, run_time = 2)
)
self.play(
GrowFromCenter(cols_brace),
Write(cols_words, run_time = 2)
)
self.dither()
self.play(
rows_words[0].copy().move_to, title[0],
cols_words[0].copy().move_to, title[2],
Write(VMobject(title[1], title[3]))
)
self.dither()
示例5: construct
# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import to_edge [as 别名]
def construct(self):
grid = get_grid()
grid.sort_points(np.linalg.norm)
freq_line = get_freq_line()
freq_line.sort_points(lambda p : p[0])
red, blue = Color(RED), Color(BLUE)
freq_line.gradient_highlight(red, blue)
colors = [
Color(rgb = interpolate(
np.array(red.rgb),
np.array(blue.rgb),
alpha
))
for alpha in np.arange(4)/3.
]
string = Line(3*LEFT, 3*RIGHT, color = colors[1])
vibration = Vibrate(string)
vibration_copy = vibration.copy()
vibration_copy.mobject.stroke_width = 1
sub_vibrations = [
Vibrate(
string.copy().shift((n-1)*UP).highlight(colors[n]),
overtones = 1,
spatial_period = 6./(n+1),
temporal_period = 1./(n+1),
amplitude = 0.5/(n+1)
)
for n in range(4)
]
words = TexMobject("&\\vdots \\\\ \\text{thousands }& \\text{of frequencies} \\\\ &\\vdots")
words.to_edge(UP, buff = 0.1)
self.add(grid)
self.dither()
self.play(DelayByOrder(ApplyMethod(
grid.gradient_highlight, red, blue
)))
self.play(Transform(grid, freq_line))
self.dither()
self.play(
ShimmerIn(
words,
rate_func = squish_rate_func(smooth, 0, 0.2)
),
*sub_vibrations,
run_time = 5
)
self.play(
*[
TransformAnimations(
sub_vib, vibration
)
for sub_vib in sub_vibrations
]+[FadeOut(words)]
)
self.clear()
self.add(freq_line)
self.play(vibration)
示例6: get_axis_labels
# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import to_edge [as 别名]
def get_axis_labels(self, x_label = "x", y_label = "y"):
x_axis, y_axis = self.get_axes().split()
x_label_mob = TexMobject(x_label)
y_label_mob = TexMobject(y_label)
x_label_mob.next_to(x_axis, DOWN)
x_label_mob.to_edge(RIGHT)
y_label_mob.next_to(y_axis, RIGHT)
y_label_mob.to_edge(UP)
return VMobject(x_label_mob, y_label_mob)
示例7: construct
# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import to_edge [as 别名]
def construct(self):
self.setup_axes()
self.force_skipping()
self.draw_f()
self.remove(self.graph_label)
self.graph.set_stroke(GREEN, width = 8)
tex = TexMobject("{d^n f", "\\over", "dx^n}")
tex.highlight_by_tex("d^n", YELLOW)
tex.highlight_by_tex("dx", BLUE)
tex.scale_to_fit_height(4)
tex.to_edge(UP)
self.add(tex)
示例8: construct
# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import to_edge [as 别名]
def construct(self):
CycloidScene.construct(self)
equations = TexMobject([
"x(t) = Rt - R\\sin(t)",
"y(t) = -R + R\\cos(t)"
])
top, bottom = equations.split()
bottom.next_to(top, DOWN)
equations.center()
equations.to_edge(UP, buff = 1.3)
self.play(ShimmerIn(equations))
self.grow_parts()
self.draw_cycloid(rate_func = None, run_time = 5)
self.dither()
示例9: construct
# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import to_edge [as 别名]
def construct(self):
equation = VMobject(*[
TOP(2, None, "x"),
TexMobject("+"),
TOP(2, None, "y"),
TexMobject("="),
TOP(2, None, "xy")
]).arrange_submobjects()
old_eq = TexMobject("\\log_2(x) + \\log_2(y) = \\log_2(xy)")
old_eq.to_edge(UP)
self.play(FadeIn(equation))
self.dither(3)
self.play(FadeIn(old_eq))
self.dither(2)
示例10: get_axis_labels
# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import to_edge [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
示例11: ask_about_dM_dt
# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import to_edge [as 别名]
def ask_about_dM_dt(self):
dM_dt_question = TexMobject("{dM", "\\over dt}", "=", "???")
dM, dt, equals, q_marks = dM_dt_question
dM_dt_question.next_to(self.function, DOWN, buff = LARGE_BUFF)
dM_dt_question.to_edge(LEFT)
self.play(
FadeOut(self.pop_brace),
FadeOut(self.pop_brace.text),
Write(dM_dt_question)
)
self.dither(3)
for mob in dM, dt:
self.play(Indicate(mob))
self.dither()
self.dM_dt_question = dM_dt_question
示例12: construct
# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import to_edge [as 别名]
def construct(self):
glass = Region(lambda x, y : y < 0, color = BLUE_E)
equation = TexMobject("v_{\\text{air}} > v_{\\text{water}}")
equation.to_edge(UP)
path = Line(SPACE_WIDTH*LEFT, SPACE_WIDTH*RIGHT)
path1 = path.copy().shift(2*UP)
path2 = path.copy().shift(2*DOWN)
self.add(glass)
self.play(ShimmerIn(equation))
self.dither()
photon_runs = []
photon_runs.append(self.photon_run_along_path(
path1, rate_func = lambda t : min(1, 1.2*t)
))
photon_runs.append(self.photon_run_along_path(path2))
self.play(*photon_runs, **{"run_time" : 2})
self.dither()
示例13: construct
# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import to_edge [as 别名]
def construct(self):
t_axis = NumberLine()
theta_axis = NumberLine().rotate(np.pi/2)
theta_mob = TexMobject("\\theta(t)")
t_mob = TexMobject("t")
theta_mob.next_to(theta_axis, RIGHT)
theta_mob.to_edge(UP)
t_mob.next_to(t_axis, UP)
t_mob.to_edge(RIGHT)
graph = ParametricFunction(
lambda t : 4*t*RIGHT + 2*smooth(t)*UP
)
line = Line(graph.points[0], graph.points[-1], color = WHITE)
q_mark = TextMobject("?")
q_mark.next_to(Point(graph.get_center()), LEFT)
stars = Stars(color = BLACK)
stars.scale(0.1).shift(q_mark.get_center())
squiggle = ParametricFunction(
lambda t : t*RIGHT + 0.2*t*(5-t)*(np.sin(t)**2)*UP,
start = 0,
end = 5
)
self.play(
ShowCreation(t_axis),
ShowCreation(theta_axis),
ShimmerIn(theta_mob),
ShimmerIn(t_mob)
)
self.play(
ShimmerIn(q_mark),
ShowCreation(graph)
)
self.dither()
self.play(
Transform(q_mark, stars),
Transform(graph, line)
)
self.dither()
self.play(Transform(graph, squiggle))
self.dither()
示例14: construct
# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import to_edge [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()
示例15: construct
# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import to_edge [as 别名]
def construct(self):
top1 = get_const_top_TOP("x", "3")
top2 = get_const_top_TOP("y", "3")
top3 = get_const_top_TOP("xy", "3")
times = TexMobject("\\times")
equals = TexMobject("=")
top_exp_equation = VMobject(
top1, times, top2, equals, top3
)
top_exp_equation.arrange_submobjects()
old_style_exp = TexMobject("(x^3)(y^3) = (xy)^3")
old_style_exp.to_edge(UP)
old_style_exp.highlight(GREEN)
old_style_rad = TexMobject("\\sqrt[3]{x} \\sqrt[3]{y} = \\sqrt[3]{xy}")
old_style_rad.to_edge(UP)
old_style_rad.highlight(RED)
self.add(top_exp_equation, old_style_exp)
self.dither(3)
old_tops = [top1, top2, top3]
new_tops = []
for top in old_tops:
new_top = top.copy()
new_top.put_on_vertex(2, new_top.values[0])
new_top.shift(0.5*LEFT)
new_tops.append(new_top)
self.play(
Transform(old_style_exp, old_style_rad),
Transform(
VMobject(*old_tops),
VMobject(*new_tops),
path_arc = np.pi/2
)
)
self.dither(3)