本文整理汇总了Python中mobject.tex_mobject.TexMobject.highlight_by_tex方法的典型用法代码示例。如果您正苦于以下问题:Python TexMobject.highlight_by_tex方法的具体用法?Python TexMobject.highlight_by_tex怎么用?Python TexMobject.highlight_by_tex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mobject.tex_mobject.TexMobject
的用法示例。
在下文中一共展示了TexMobject.highlight_by_tex方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: construct
# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import highlight_by_tex [as 别名]
def construct(self):
note = TexMobject(
"{ d(a^", "t", ")", "\\over \\,", "dt}",
"=", "a^", "t", "(\\text{Some constant})"
)
note.highlight_by_tex("t", YELLOW)
note.highlight_by_tex("dt", GREEN)
note.highlight_by_tex("constant", BLUE)
note.to_corner(UP+LEFT)
self.add(note)
self.student_says(
"Is there a base where\\\\",
"that constant is 1?"
)
self.change_student_modes(
"pondering", "raise_right_hand", "thinking",
# look_at_arg = self.get_students()[1].bubble
)
self.dither(2)
self.play(FadeOut(note[-1], run_time = 3))
self.dither()
self.teacher_says(
"There is!\\\\",
"$e = 2.71828\\dots$",
target_mode = "hooray"
)
self.change_student_modes(*["confused"]*3)
self.dither(3)
示例2: construct
# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import highlight_by_tex [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)
示例3: try_specific_dt_values
# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import highlight_by_tex [as 别名]
def try_specific_dt_values(self):
expressions = []
for num_zeros in [1, 2, 4, 7]:
dt_str = "0." + num_zeros*"0" + "1"
dt_num = float(dt_str)
output_num = (self.base**dt_num - 1) / dt_num
output_str = "%.7f\\dots"%output_num
expression = TexMobject(
"{%s^"%self.base_str, "{%s}"%dt_str, "-1",
"\\over \\,", "%s}"%dt_str,
"=", output_str
)
expression.highlight_by_tex(dt_str, GREEN)
expression.highlight_by_tex(output_str, BLUE)
expression.to_corner(UP+RIGHT)
expressions.append(expression)
curr_expression = expressions[0]
self.play(
Write(curr_expression),
self.pi_creature.change_mode, "pondering"
)
self.dither(2)
for expression in expressions[1:]:
self.play(Transform(curr_expression, expression))
self.dither(2)
return curr_expression[-1]
示例4: get_label_group
# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import highlight_by_tex [as 别名]
def get_label_group(self, t):
graph = self.graph
v_line = self.get_vertical_line_to_graph(
t, graph,
color = YELLOW,
)
brace = Brace(v_line, RIGHT)
height_label = brace.get_text("$2^%d$"%t)
ss_group = self.get_secant_slope_group(
t, graph, dx = 0.01,
df_label = "dM",
dx_label = "dt",
dx_line_color = GREEN,
secant_line_color = RED,
)
slope_label = TexMobject(
"\\text{Slope}", "=",
"2^%d"%t,
"(%.7f\\dots)"%np.log(2)
)
slope_label.next_to(
ss_group.secant_line.point_from_proportion(0.65),
DOWN+RIGHT,
buff = 0
)
slope_label.highlight_by_tex("Slope", RED)
return VGroup(
v_line, brace, height_label,
ss_group, slope_label
)
示例5: introduce_acceleration
# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import highlight_by_tex [as 别名]
def introduce_acceleration(self):
a_words = TexMobject(
"{d^2 s \\over dt^2}(t)", "\\Leftrightarrow",
"\\text{Acceleration}"
)
a_words.highlight_by_tex("d^2 s", MAROON_B)
a_words.highlight_by_tex("Acceleration", YELLOW)
a_words.to_corner(UP+RIGHT )
self.add(a_words)
self.show_car_movement()
self.dither()
self.a_words = a_words
示例6: construct
# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import highlight_by_tex [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)
示例7: construct
# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import highlight_by_tex [as 别名]
def construct(self):
v_tex, w_tex, p_tex = get_vect_tex(*"vwp")
equation = TexMobject(
v_tex, "\\times", w_tex, "=", p_tex
)
equation.highlight_by_tex(v_tex, V_COLOR)
equation.highlight_by_tex(w_tex, W_COLOR)
equation.highlight_by_tex(p_tex, P_COLOR)
brace = Brace(equation[-1])
brace.stretch_to_fit_width(0.7)
vector_text = brace.get_text("Vector")
vector_text.highlight(RED)
self.add(equation)
self.play(*map(Write, [brace, vector_text]))
self.dither()
示例8: get_expression
# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import highlight_by_tex [as 别名]
def get_expression(self, base):
expression = TexMobject(
"{d(", "%d^"%base, "t", ")", "\\over \\,", "dt}",
"=", "%d^"%base, "t", "(%.4f\\dots)"%np.log(base),
)
expression.highlight_by_tex("t", YELLOW)
expression.highlight_by_tex("dt", GREEN)
expression.highlight_by_tex("\\dots", BLUE)
brace = Brace(expression.get_part_by_tex("\\dots"), UP)
brace_text = brace.get_text("$\\ln(%d)$"%base)
for mob in brace, brace_text:
mob.set_fill(opacity = 0)
expression.add(brace, brace_text)
return expression
示例9: write_second_derivative
# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import highlight_by_tex [as 别名]
def write_second_derivative(self):
ddf_over_dx_squared = TexMobject(
"{d(df)", "\\over", "(dx)^2}"
)
ddf_over_dx_squared.scale(0.8)
ddf_over_dx_squared.move_to(self.ddf, RIGHT)
ddf_over_dx_squared.highlight_by_tex("df", self.ddf.get_color())
parens = VGroup(
ddf_over_dx_squared[0][1],
ddf_over_dx_squared[0][4],
ddf_over_dx_squared[2][0],
ddf_over_dx_squared[2][3],
)
right_shifter = ddf_over_dx_squared[0][0]
left_shifter = ddf_over_dx_squared[2][4]
exp_two = TexMobject("2")
exp_two.highlight(self.ddf.get_color())
exp_two.scale(0.5)
exp_two.move_to(right_shifter.get_corner(UP+RIGHT), LEFT)
exp_two.shift(MED_SMALL_BUFF*RIGHT)
pre_exp_two = VGroup(ddf_over_dx_squared[0][2])
self.play(
Write(ddf_over_dx_squared.get_part_by_tex("over")),
*[
ReplacementTransform(
mob,
ddf_over_dx_squared.get_part_by_tex(tex),
path_arc = -np.pi/2,
)
for mob, tex in (self.ddf, "df"), (self.dx_squared, "dx")
]
)
self.dither(2)
self.play(FadeOut(parens))
self.play(
left_shifter.shift, 0.2*LEFT,
right_shifter.shift, 0.2*RIGHT,
ReplacementTransform(pre_exp_two, exp_two),
ddf_over_dx_squared.get_part_by_tex("over").scale_in_place, 0.8
)
self.dither(2)
示例10: construct
# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import highlight_by_tex [as 别名]
def construct(self):
rect = Rectangle(width = 5, height = 3)
# f = lambda t : 4*np.sin(t*np.pi/2)
f = lambda t : 4*t
g = lambda t : 3*smooth(t)
curve = ParametricFunction(lambda t : f(t)*RIGHT + g(t)*DOWN)
curve.highlight(YELLOW)
curve.center()
rect = Rectangle()
rect.replace(curve, stretch = True)
regions = []
for vect, color in (UP+RIGHT, BLUE), (DOWN+LEFT, GREEN):
region = curve.copy()
region.add_control_points(3*[rect.get_corner(vect)])
region.set_stroke(width = 0)
region.set_fill(color = color, opacity = 0.5)
regions.append(region)
upper_right, lower_left = regions
v_lines, h_lines = VGroup(), VGroup()
for alpha in np.linspace(0, 1, 30):
point = curve.point_from_proportion(alpha)
top_point = curve.points[0][1]*UP + point[0]*RIGHT
left_point = curve.points[0][0]*RIGHT + point[1]*UP
v_lines.add(Line(top_point, point))
h_lines.add(Line(left_point, point))
v_lines.highlight(BLUE_E)
h_lines.highlight(GREEN_E)
equation = TexMobject(
"\\int_0^1 g\\,df",
"+\\int_0^1 f\\,dg",
"= \\big(fg \\big)_0^1"
)
equation.to_edge(UP)
equation.highlight_by_tex(
"\\int_0^1 g\\,df",
upper_right.get_color()
)
equation.highlight_by_tex(
"+\\int_0^1 f\\,dg",
lower_left.get_color()
)
left_brace = Brace(rect, LEFT)
down_brace = Brace(rect, DOWN)
g_T = left_brace.get_text("$g(t)\\big|_0^1$")
f_T = down_brace.get_text("$f(t)\\big|_0^1$")
self.draw_curve(curve)
self.play(ShowCreation(rect))
self.play(*map(Write, [down_brace, left_brace, f_T, g_T]))
self.dither()
self.play(FadeIn(upper_right))
self.play(
ShowCreation(
v_lines,
submobjects = "one_at_a_time",
run_time = 2
),
Animation(curve),
Animation(rect)
)
self.play(Write(equation[0]))
self.dither()
self.play(FadeIn(lower_left))
self.play(
ShowCreation(
h_lines,
submobjects = "one_at_a_time",
run_time = 2
),
Animation(curve),
Animation(rect)
)
self.play(Write(equation[1]))
self.dither()
self.play(Write(equation[2]))
self.dither()
示例11: show_functions
# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import highlight_by_tex [as 别名]
def show_functions(self):
def get_deriv(n):
return lambda x : derivative(
s_scene.graph.underlying_function, x, n
)
s_scene = TrajectoryGraphScene()
v_scene = TrajectoryGraphScene(
func = get_deriv(1),
color = GREEN,
y_max = 4,
y_axis_label = "v",
)
a_scene = TrajectoryGraphScene(
func = get_deriv(2),
color = MAROON_B,
y_axis_label = "a",
y_min = -2,
y_max = 2,
)
j_scene = TrajectoryGraphScene(
func = get_deriv(3),
color = PINK,
y_axis_label = "j",
y_min = -2,
y_max = 2,
)
s_graph, v_graph, a_graph, j_graph = graphs = [
VGroup(*scene.get_top_level_mobjects())
for scene in s_scene, v_scene, a_scene, j_scene
]
for i, graph in enumerate(graphs):
graph.scale_to_fit_height(SPACE_HEIGHT)
graph.to_corner(UP+LEFT)
graph.shift(i*DOWN/2.0)
s_words = TexMobject(
"s(t)", "\\Leftrightarrow", "\\text{Displacement}"
)
s_words.highlight_by_tex("s(t)", s_scene.graph.get_color())
v_words = TexMobject(
"\\frac{ds}{dt}(t)", "\\Leftrightarrow",
"\\text{Velocity}"
)
v_words.highlight_by_tex("ds", v_scene.graph.get_color())
j_words = TexMobject(
"\\frac{d^3 s}{dt^3}(t)", "\\Leftrightarrow",
"\\text{Jerk}"
)
j_words.highlight_by_tex("d^3", j_scene.graph.get_color())
self.a_words.generate_target()
words_group = VGroup(s_words, v_words, self.a_words.target, j_words)
words_group.arrange_submobjects(
DOWN,
buff = MED_LARGE_BUFF,
aligned_edge = LEFT
)
words_group.to_corner(UP+RIGHT)
j_graph.scale(0.3).next_to(j_words, LEFT)
positive_rect = Rectangle()
positive_rect.set_stroke(width = 0)
positive_rect.set_fill(GREEN, 0.5)
positive_rect.replace(
Line(
a_scene.coords_to_point(0, -1),
a_scene.coords_to_point(5, 1),
),
stretch = True
)
negative_rect = Rectangle()
negative_rect.set_stroke(width = 0)
negative_rect.set_fill(RED, 0.5)
negative_rect.replace(
Line(
a_scene.coords_to_point(5, 1),
a_scene.coords_to_point(10, -1),
),
stretch = True
)
self.show_car_movement(
MoveToTarget(self.a_words),
FadeIn(s_words),
FadeIn(s_graph),
)
self.play(
s_graph.scale, 0.3,
s_graph.next_to, s_words, LEFT
)
self.play(*map(FadeIn, [v_graph, v_words]) )
self.dither(2)
self.play(
v_graph.scale, 0.3,
v_graph.next_to, v_words, LEFT
)
self.dither(2)
self.play(
Indicate(self.a_words),
FadeIn(a_graph),
)
#.........这里部分代码省略.........