本文整理汇总了Python中mobject.tex_mobject.TexMobject.get_part_by_tex方法的典型用法代码示例。如果您正苦于以下问题:Python TexMobject.get_part_by_tex方法的具体用法?Python TexMobject.get_part_by_tex怎么用?Python TexMobject.get_part_by_tex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mobject.tex_mobject.TexMobject
的用法示例。
在下文中一共展示了TexMobject.get_part_by_tex方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: show_proportionality_to_dx_squared
# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import get_part_by_tex [as 别名]
def show_proportionality_to_dx_squared(self):
ddf = self.ddf.copy()
ddf.generate_target()
ddf.target.next_to(self.ddf, UP, LARGE_BUFF)
rhs = TexMobject(
"\\approx", "(\\text{Some constant})", "(dx)^2"
)
rhs.scale(0.8)
rhs.next_to(ddf.target, RIGHT)
example_dx = TexMobject(
"dx = 0.01 \\Rightarrow (dx)^2 = 0.0001"
)
example_dx.scale(0.8)
example_dx.to_corner(UP+RIGHT)
self.play(MoveToTarget(ddf))
self.play(Write(rhs))
self.dither()
self.play(Write(example_dx))
self.dither(2)
self.play(FadeOut(example_dx))
self.ddf = ddf
self.dx_squared = rhs.get_part_by_tex("dx")
示例2: write_second_derivative
# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import get_part_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)
示例3: get_expression
# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import get_part_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
示例4: construct
# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import get_part_by_tex [as 别名]
def construct(self):
clunky_deriv = TexMobject(
"{d", "\\big(", "{df", "\\over", "dx}", "\\big)",
"\\over", "dx }"
)
over_index = clunky_deriv.index_of_part(
clunky_deriv.get_parts_by_tex("\\over")[1]
)
numerator = VGroup(*clunky_deriv[:over_index])
denominator = VGroup(*clunky_deriv[over_index+1:])
rp = clunky_deriv.get_part_by_tex("(")
lp = clunky_deriv.get_part_by_tex(")")
dfs, overs, dxs = map(clunky_deriv.get_parts_by_tex, [
"df", "over", "dx"
])
df_over_dx = VGroup(dfs[0], overs[0], dxs[0])
d = clunky_deriv.get_part_by_tex("d")
d_over_dx = VGroup(d, overs[1], dxs[1])
d2f_over_dx2 = TexMobject("{d^2 f", "\\over", "dx", "^2}")
d2f_over_dx2.highlight_by_tex("dx", YELLOW)
for mob in clunky_deriv, d2f_over_dx2:
mob.next_to(self.teacher, UP+LEFT)
for mob in numerator, denominator:
circle = Circle(color = YELLOW)
circle.replace(mob, stretch = True)
circle.scale_in_place(1.3)
mob.circle = circle
dx_to_zero = TexMobject("dx \\to 0")
dx_to_zero.highlight(YELLOW)
dx_to_zero.next_to(clunky_deriv, UP+LEFT)
self.student_says(
"What's that notation?",
target_mode = "raise_left_hand"
)
self.change_student_modes("confused", "raise_left_hand", "confused")
self.play(
FadeIn(
clunky_deriv,
run_time = 2,
submobject_mode = "lagged_start"
),
RemovePiCreatureBubble(self.get_students()[1]),
self.teacher.change_mode, "raise_right_hand"
)
self.dither()
self.play(ShowCreation(numerator.circle))
self.dither()
self.play(ReplacementTransform(
numerator.circle,
denominator.circle,
))
self.dither()
self.play(
FadeOut(denominator.circle),
Write(dx_to_zero),
dxs.highlight, YELLOW
)
self.dither()
self.play(
FadeOut(dx_to_zero),
*[ApplyMethod(pi.change, "plain") for pi in self.get_pi_creatures()]
)
self.play(
df_over_dx.scale, dxs[1].get_height()/dxs[0].get_height(),
df_over_dx.move_to, d_over_dx, RIGHT,
FadeOut(VGroup(lp, rp)),
d_over_dx.shift, 0.8*LEFT + 0.05*UP,
)
self.dither()
self.play(*[
ReplacementTransform(
group,
VGroup(d2f_over_dx2.get_part_by_tex(tex))
)
for group, tex in [
(VGroup(d, dfs[0]), "d^2"),
(overs, "over"),
(dxs, "dx"),
(VGroup(dxs[1].copy()), "^2}"),
]
])
self.dither(2)
self.student_says(
"How does one... \\\\ read that?",
student_index = 0,
)
self.play(self.teacher.change, "happy")
self.dither(2)