本文整理汇总了Python中mobject.tex_mobject.TexMobject.get_height方法的典型用法代码示例。如果您正苦于以下问题:Python TexMobject.get_height方法的具体用法?Python TexMobject.get_height怎么用?Python TexMobject.get_height使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mobject.tex_mobject.TexMobject
的用法示例。
在下文中一共展示了TexMobject.get_height方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: generate_points
# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import get_height [as 别名]
def generate_points(self):
self.cell_height = self.height / self.nrows
self.cell_width = self.width / self.nrows
self.bottom_left = (self.cell_width * self.nrows / 2.0)*LEFT + \
(self.cell_height * self.nrows / 2.0)*DOWN
num_to_num_mob = {}
self.coords_to_mobs = {}
self.coords = [
(n, k)
for n in range(self.nrows)
for k in range(n+1)
]
for n, k in self.coords:
num = choose(n, k)
center = self.coords_to_center(n, k)
num_mob = TexMobject(str(num))
scale_factor = min(
1,
self.portion_to_fill * self.cell_height / num_mob.get_height(),
self.portion_to_fill * self.cell_width / num_mob.get_width(),
)
num_mob.center().scale(scale_factor).shift(center)
if n not in self.coords_to_mobs:
self.coords_to_mobs[n] = {}
self.coords_to_mobs[n][k] = num_mob
self.add(*[
self.coords_to_mobs[n][k]
for n, k in self.coords
])
return self
示例2: side_project
# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import get_height [as 别名]
def side_project(self, morty):
rect = PictureInPictureFrame()
rect.next_to(morty, UP+LEFT)
side_project = TextMobject("Side project")
side_project.next_to(rect, UP)
dollar_sign = TexMobject("\\$")
cross = VGroup(*[
Line(vect, -vect, color = RED)
for vect in UP+RIGHT, UP+LEFT
])
cross.scale_to_fit_height(dollar_sign.get_height())
no_money = VGroup(dollar_sign, cross)
no_money.next_to(rect, DOWN)
self.play(
morty.change_mode, "raise_right_hand",
morty.look_at, rect
)
self.play(
Write(side_project),
ShowCreation(rect)
)
self.dither()
self.play(Blink(morty))
self.dither()
self.play(Write(dollar_sign))
self.play(ShowCreation(cross))
self.screen_title = side_project
self.cross = cross
示例3: get_number_mobjects
# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import get_height [as 别名]
def get_number_mobjects(self, *numbers):
# TODO, handle decimals
if len(numbers) == 0:
numbers = self.default_numbers_to_display()
result = []
for number in numbers:
mob = TexMobject(str(int(number)))
vert_scale = 2 * self.tick_size / mob.get_height()
hori_scale = self.tick_frequency * self.unit_length_to_spatial_width / mob.get_width()
mob.scale(min(vert_scale, hori_scale))
mob.shift(self.number_to_point(number))
mob.shift(self.get_vertical_number_offset())
result.append(mob)
return result
示例4: generate_n_choose_k_mobs
# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import get_height [as 别名]
def generate_n_choose_k_mobs(self):
self.coords_to_n_choose_k = {}
for n, k in self.coords:
nck_mob = TexMobject(r"{%d \choose %d}"%(n, k))
scale_factor = min(
1,
self.portion_to_fill * self.cell_height / nck_mob.get_height(),
self.portion_to_fill * self.cell_width / nck_mob.get_width(),
)
center = self.coords_to_mobs[n][k].get_center()
nck_mob.center().scale(scale_factor).shift(center)
if n not in self.coords_to_n_choose_k:
self.coords_to_n_choose_k[n] = {}
self.coords_to_n_choose_k[n][k] = nck_mob
return self
示例5: scale_vector
# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import get_height [as 别名]
def scale_vector(self, v, factor, v_label,
v_name = "v", factor_tex = None):
starting_mobjects = list(self.mobjects)
if factor_tex is None:
factor_tex = str(factor)
scaled_vector = self.add_vector(
factor*v.get_end(), animate = False
)
self.remove(scaled_vector)
label_tex = "%s\\vec{\\textbf{%s}}"%(factor_tex, v_name)
label = self.label_vector(
scaled_vector, label_tex, animate = False,
add_to_vector = False
)
self.remove(label)
factor_mob = TexMobject(factor_tex)
if factor_mob.get_height() > 1:
factor_mob.scale_to_fit_height(0.9)
if factor_mob.get_width() > 1:
factor_mob.scale_to_fit_width(0.9)
factor_mob.shift(1.5*RIGHT+2.5*UP)
num_factor_parts = len(factor_mob.split())
factor_mob_parts_in_label = label.split()[:num_factor_parts]
label_remainder_parts = label.split()[num_factor_parts:]
factor_in_label = VMobject(*factor_mob_parts_in_label)
label_remainder = VMobject(*label_remainder_parts)
self.play(Write(factor_mob, run_time = 1))
self.dither()
self.play(
ApplyMethod(v.copy().highlight, DARK_GREY),
ApplyMethod(v_label.copy().highlight, DARK_GREY),
Transform(factor_mob, factor_in_label),
Transform(v.copy(), scaled_vector),
Transform(v_label.copy(), label_remainder),
)
self.dither(2)
self.clear()
self.add(*starting_mobjects)
示例6: construct
# 需要导入模块: from mobject.tex_mobject import TexMobject [as 别名]
# 或者: from mobject.tex_mobject.TexMobject import get_height [as 别名]
def construct(self):
base_str = self.base_str
func_def = TexMobject("M(", "t", ")", "= ", "%s^"%base_str, "t")
func_def.to_corner(UP+LEFT)
self.add(func_def)
ratio = TexMobject(
"{ {%s^"%base_str, "{t", "+", "dt}", "-",
"%s^"%base_str, "t}",
"\\over \\,", "dt}"
)
ratio.shift(UP+LEFT)
lhs = TexMobject("{dM", "\\over \\,", "dt}", "(", "t", ")", "=")
lhs.next_to(ratio, LEFT)
two_to_t_plus_dt = VGroup(*ratio[:4])
two_to_t = VGroup(*ratio[5:7])
two_to_t_two_to_dt = TexMobject(
"%s^"%base_str, "t",
"%s^"%base_str, "{dt}"
)
two_to_t_two_to_dt.move_to(two_to_t_plus_dt, DOWN+LEFT)
exp_prop_brace = Brace(two_to_t_two_to_dt, UP)
one = TexMobject("1")
one.move_to(ratio[5], DOWN)
lp, rp = parens = TexMobject("()")
parens.stretch(1.3, 1)
parens.scale_to_fit_height(ratio.get_height())
lp.next_to(ratio, LEFT, buff = 0)
rp.next_to(ratio, RIGHT, buff = 0)
extracted_two_to_t = TexMobject("%s^"%base_str, "t")
extracted_two_to_t.next_to(lp, LEFT, buff = SMALL_BUFF)
expressions = [
ratio, two_to_t_two_to_dt,
extracted_two_to_t, lhs, func_def
]
for expression in expressions:
expression.highlight_by_tex("t", YELLOW)
expression.highlight_by_tex("dt", GREEN)
#Apply exponential property
self.play(
Write(ratio), Write(lhs),
self.pi_creature.change_mode, "raise_right_hand"
)
self.dither(2)
self.play(
two_to_t_plus_dt.next_to, exp_prop_brace, UP,
self.pi_creature.change_mode, "pondering"
)
self.play(
ReplacementTransform(
two_to_t_plus_dt.copy(), two_to_t_two_to_dt,
run_time = 2,
path_arc = np.pi,
),
FadeIn(exp_prop_brace)
)
self.dither(2)
#Talk about exponential property
add_exp_rect, mult_rect = rects = [
Rectangle(
stroke_color = BLUE,
stroke_width = 2,
).replace(mob).scale_in_place(1.1)
for mob in [
VGroup(*two_to_t_plus_dt[1:]),
two_to_t_two_to_dt
]
]
words = VGroup(*[
TextMobject(s, " ideas")
for s in "Additive", "Multiplicative"
])
words[0].move_to(words[1], LEFT)
words.highlight(BLUE)
words.next_to(two_to_t_plus_dt, RIGHT, buff = 1.5*LARGE_BUFF)
arrows = VGroup(*[
Arrow(word.get_left(), rect, color = words.get_color())
for word, rect in zip(words, rects)
])
self.play(ShowCreation(add_exp_rect))
self.dither()
self.play(ReplacementTransform(
add_exp_rect.copy(), mult_rect
))
self.dither()
self.change_mode("happy")
self.play(Write(words[0], run_time = 2))
self.play(ShowCreation(arrows[0]))
self.dither()
self.play(
#.........这里部分代码省略.........