本文整理汇总了Python中mobject.tex_mobject.TextMobject.to_edge方法的典型用法代码示例。如果您正苦于以下问题:Python TextMobject.to_edge方法的具体用法?Python TextMobject.to_edge怎么用?Python TextMobject.to_edge使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mobject.tex_mobject.TextMobject
的用法示例。
在下文中一共展示了TextMobject.to_edge方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: construct
# 需要导入模块: from mobject.tex_mobject import TextMobject [as 别名]
# 或者: from mobject.tex_mobject.TextMobject import to_edge [as 别名]
def construct(self):
text = TextMobject("Which path minimizes travel time?")
text.to_edge(UP)
self.generate_start_and_end_points()
point_a = Dot(self.start_point)
point_b = Dot(self.end_point)
A = TextMobject("A").next_to(point_a, UP)
B = TextMobject("B").next_to(point_b, DOWN)
paths = self.get_paths()
for point, letter in [(point_a, A), (point_b, B)]:
self.play(
ShowCreation(point),
ShimmerIn(letter)
)
self.play(ShimmerIn(text))
curr_path = paths[0].copy()
curr_path_copy = curr_path.copy().ingest_submobjects()
self.play(
self.photon_run_along_path(curr_path),
ShowCreation(curr_path_copy, rate_func = rush_into)
)
self.remove(curr_path_copy)
for path in paths[1:] + [paths[0]]:
self.play(Transform(curr_path, path, run_time = 4))
self.dither()
self.path = curr_path.ingest_submobjects()
示例2: construct
# 需要导入模块: from mobject.tex_mobject import TextMobject [as 别名]
# 或者: from mobject.tex_mobject.TextMobject import to_edge [as 别名]
def construct(self):
scale_factor = 0.9
grid = Grid(4, 4, point_thickness = 1)
curve = HilbertCurve(order = 2)
for mob in grid, curve:
mob.scale(scale_factor)
words = TextMobject("""
Sequence of curves is stable
$\\leftrightarrow$ existence of limit curve
""", size = "\\normal")
words.scale(1.25)
words.to_edge(UP)
self.add(curve, grid)
self.dither()
for n in range(3, 7):
if n == 5:
self.play(ShimmerIn(words))
new_grid = Grid(2**n, 2**n, point_thickness = 1)
new_curve = HilbertCurve(order = n)
for mob in new_grid, new_curve:
mob.scale(scale_factor)
self.play(
ShowCreation(new_grid),
Animation(curve)
)
self.remove(grid)
grid = new_grid
self.play(Transform(curve, new_curve))
self.dither()
示例3: construct
# 需要导入模块: from mobject.tex_mobject import TextMobject [as 别名]
# 或者: from mobject.tex_mobject.TextMobject 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()
示例4: construct
# 需要导入模块: from mobject.tex_mobject import TextMobject [as 别名]
# 或者: from mobject.tex_mobject.TextMobject import to_edge [as 别名]
def construct(self):
point_a, point_b = 3*LEFT, 3*RIGHT
dots = []
for point, char in [(point_a, "A"), (point_b, "B")]:
dot = Dot(point)
letter = TexMobject(char)
letter.next_to(dot, UP+LEFT)
dot.add(letter)
dots.append(dot)
path = ParametricFunction(
lambda t : (t/2 + np.cos(t))*RIGHT + np.sin(t)*UP,
start = -2*np.pi,
end = 2*np.pi
)
path.scale(6/(2*np.pi))
path.shift(point_a - path.points[0])
path.highlight(RED)
line = Line(point_a, point_b)
words = TextMobject("Shortest path from $A$ to $B$")
words.to_edge(UP)
self.play(
ShimmerIn(words),
*map(GrowFromCenter, dots)
)
self.play(ShowCreation(path))
self.play(Transform(
path, line,
path_func = path_along_arc(np.pi)
))
self.dither()
示例5: add_title
# 需要导入模块: from mobject.tex_mobject import TextMobject [as 别名]
# 或者: from mobject.tex_mobject.TextMobject import to_edge [as 别名]
def add_title(self, title, scale_factor = 1.5, animate = False):
if not isinstance(title, Mobject):
title = TextMobject(title).scale(scale_factor)
title.to_edge(UP)
title.add_background_rectangle()
if animate:
self.play(Write(title))
self.add_foreground_mobject(title)
self.title = title
return self
示例6: construct
# 需要导入模块: from mobject.tex_mobject import TextMobject [as 别名]
# 或者: from mobject.tex_mobject.TextMobject import to_edge [as 别名]
def construct(self):
name = TextMobject("Steven Strogatz")
name.to_edge(UP)
contributions = TextMobject("Frequent Contributions")
contributions.scale(0.5).to_edge(RIGHT).shift(2*UP)
books_word = TextMobject("Books")
books_word.scale(0.5).to_edge(LEFT).shift(2*UP)
radio_lab, sci_fri, cornell, book2, book3, book4 = [
ImageMobject(filename, invert = False, filter_color = WHITE)
for filename in [
"radio_lab",
"science_friday",
"cornell",
"strogatz_book2",
"strogatz_book3",
"strogatz_book4",
]
]
book1 = ImageMobject("strogatz_book1", invert = False)
nyt = ImageMobject("new_york_times")
logos = [radio_lab, nyt, sci_fri]
books = [book1, book2, book3, book4]
sample_size = Square(side_length = 2)
last = contributions
for image in logos:
image.replace(sample_size)
image.next_to(last, DOWN)
last = image
sci_fri.scale_in_place(0.9)
shift_val = 0
sample_size.scale(0.75)
for book in books:
book.replace(sample_size)
book.next_to(books_word, DOWN)
book.shift(shift_val*(RIGHT+DOWN))
shift_val += 0.5
sample_size.scale(2)
cornell.replace(sample_size)
cornell.next_to(name, DOWN)
self.add(name)
self.play(FadeIn(cornell))
self.play(ShimmerIn(books_word))
for book in books:
book.shift(5*LEFT)
self.play(ApplyMethod(book.shift, 5*RIGHT))
self.play(ShimmerIn(contributions))
for logo in logos:
self.play(FadeIn(logo))
self.dither()
示例7: construct
# 需要导入模块: from mobject.tex_mobject import TextMobject [as 别名]
# 或者: from mobject.tex_mobject.TextMobject import to_edge [as 别名]
def construct(self):
curve = HilbertCurve(order = 1)
words = TextMobject("``Hilbert Curve''")
words.to_edge(UP, buff = 0.2)
self.play(
ShimmerIn(words),
Transform(curve, HilbertCurve(order = 2)),
run_time = 2
)
for n in range(3, 8):
self.play(
Transform(curve, HilbertCurve(order = n)),
run_time = 5. /n
)
示例8: construct
# 需要导入模块: from mobject.tex_mobject import TextMobject [as 别名]
# 或者: from mobject.tex_mobject.TextMobject import to_edge [as 别名]
def construct(self):
words = TextMobject("""
It might come as a surprise how some well-known
fractals can be described with curves.
""")
words.to_edge(UP)
self.setup(Sierpinski)
self.add(TextMobject("Speaking of other fractals\\dots"))
self.dither(3)
self.clear()
self.play(ShimmerIn(words))
for x in range(9):
self.increase_order()
示例9: label_spaces
# 需要导入模块: from mobject.tex_mobject import TextMobject [as 别名]
# 或者: from mobject.tex_mobject.TextMobject import to_edge [as 别名]
def label_spaces(self):
input_space = TextMobject("Input Space")
input_space.to_edge(UP)
input_space.shift(LEFT*SPACE_WIDTH/2)
output_space = TextMobject("Output Space")
output_space.to_edge(UP)
output_space.shift(RIGHT*SPACE_WIDTH/2)
line = Line(
UP*SPACE_HEIGHT, DOWN*SPACE_HEIGHT,
color = WHITE
)
self.play(
ShimmerIn(input_space),
ShimmerIn(output_space),
ShowCreation(line),
ShowCreation(self.interval),
)
self.dither()
示例10: get_quote
# 需要导入模块: from mobject.tex_mobject import TextMobject [as 别名]
# 或者: from mobject.tex_mobject.TextMobject import to_edge [as 别名]
def get_quote(self, max_width = 2*SPACE_WIDTH-1):
text_mobject_kwargs = {
"alignment" : "",
"arg_separator" : self.quote_arg_separator,
}
if isinstance(self.quote, str):
quote = TextMobject("``%s''"%self.quote.strip(), **text_mobject_kwargs)
else:
words = ["``"] + list(self.quote) + ["''"]
quote = TextMobject(*words, **text_mobject_kwargs)
##TODO, make less hacky
quote[0].shift(0.2*RIGHT)
quote[-1].shift(0.2*LEFT)
for term, color in self.highlighted_quote_terms.items():
quote.highlight_by_tex(term, color)
quote.to_edge(UP)
if quote.get_width() > max_width:
quote.scale_to_fit_width(max_width)
return quote
示例11: label
# 需要导入模块: from mobject.tex_mobject import TextMobject [as 别名]
# 或者: from mobject.tex_mobject.TextMobject import to_edge [as 别名]
def label(self, text, time = 5):
mob = TextMobject(text)
mob.scale(1.5)
mob.to_edge(UP)
rectangle = region_from_polygon_vertices(*[
mob.get_corner(vect) + 0.3*vect
for vect in [
UP+RIGHT,
UP+LEFT,
DOWN+LEFT,
DOWN+RIGHT
]
])
mob.highlight(self.text_color)
rectangle = MobjectFromRegion(rectangle, "#111111")
rectangle.point_thickness = 3
self.add(rectangle, mob)
self.dither(time)
self.remove(mob, rectangle)
示例12: show_angles
# 需要导入模块: from mobject.tex_mobject import TextMobject [as 别名]
# 或者: from mobject.tex_mobject.TextMobject import to_edge [as 别名]
def show_angles(self):
words = TextMobject("""
Let's see what happens as we change
the angle in this seed
""")
words.to_edge(UP)
koch, sharper_koch, duller_koch = curves = [
CurveClass(order = 1)
for CurveClass in StraightKoch, SharperKoch, DullerKoch
]
arcs = [
Arc(
2*(np.pi/2 - curve.angle),
radius = r,
start_angle = np.pi+curve.angle
).shift(curve.points[curve.get_num_points()/2])
for curve, r in zip(curves, [0.6, 0.7, 0.4])
]
theta = TexMobject("\\theta")
theta.shift(arcs[0].get_center()+2.5*DOWN)
arrow = Arrow(theta, arcs[0])
self.add(words, koch)
self.play(ShowCreation(arcs[0]))
self.play(
ShowCreation(arrow),
ShimmerIn(theta)
)
self.dither(2)
self.remove(theta, arrow)
self.play(
Transform(koch, duller_koch),
Transform(arcs[0], arcs[2]),
)
self.play(
Transform(koch, sharper_koch),
Transform(arcs[0], arcs[1]),
)
self.clear()
示例13: construct
# 需要导入模块: from mobject.tex_mobject import TextMobject [as 别名]
# 或者: from mobject.tex_mobject.TextMobject import to_edge [as 别名]
def construct(self):
randy = Randolph()
randy.scale(RANDY_SCALE_VAL)
randy.shift(-randy.get_bottom())
self.add_cycloid_end_points()
points = self.cycloid.points
ceiling = points[0, 1]
n = len(points)
broken_points = [
points[k*n/self.num_pieces:(k+1)*n/self.num_pieces]
for k in range(self.num_pieces)
]
words = TextMobject("""
What determines the speed\\\\
at each point?
""")
words.to_edge(UP)
self.add(self.cycloid)
sliders, vectors = [], []
for points in broken_points:
path = Mobject().add_points(points)
vect = points[-1] - points[-2]
magnitude = np.sqrt(ceiling - points[-1, 1])
vect = magnitude*vect/np.linalg.norm(vect)
slider = self.slide(randy, path, ceiling = ceiling)
vector = Vector(slider.get_center(), vect)
self.add(slider, vector)
sliders.append(slider)
vectors.append(vector)
self.dither()
self.play(ShimmerIn(words))
self.dither(3)
slider = sliders.pop(1)
vector = vectors.pop(1)
faders = sliders+vectors+[words]
self.play(*map(FadeOut, faders))
self.remove(*faders)
self.show_geometry(slider, vector)