本文整理汇总了Python中mobject.tex_mobject.TextMobject.split方法的典型用法代码示例。如果您正苦于以下问题:Python TextMobject.split方法的具体用法?Python TextMobject.split怎么用?Python TextMobject.split使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mobject.tex_mobject.TextMobject
的用法示例。
在下文中一共展示了TextMobject.split方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: construct
# 需要导入模块: from mobject.tex_mobject import TextMobject [as 别名]
# 或者: from mobject.tex_mobject.TextMobject import split [as 别名]
def construct(self):
words = TextMobject([
"Fermat's principle:",
"""
If a beam of light travels
from point $A$ to $B$, it does so along the
fastest path possible.
"""
])
words.split()[0].highlight(BLUE)
everything = MobjectFromRegion(Region())
everything.scale(0.9)
angles = np.apply_along_axis(
angle_of_vector, 1, everything.points
)
norms = np.apply_along_axis(
np.linalg.norm, 1, everything.points
)
norms -= np.min(norms)
norms /= np.max(norms)
alphas = 0.25 + 0.75 * norms * (1 + np.sin(12*angles))/2
everything.rgbs = alphas.repeat(3).reshape((len(alphas), 3))
Mobject(everything, words).show()
everything.sort_points(np.linalg.norm)
self.add(words)
self.play(
DelayByOrder(FadeIn(everything, run_time = 3)),
Animation(words)
)
self.play(
ApplyMethod(everything.highlight, WHITE),
)
self.dither()
示例2: construct
# 需要导入模块: from mobject.tex_mobject import TextMobject [as 别名]
# 或者: from mobject.tex_mobject.TextMobject import split [as 别名]
def construct(self):
words = TextMobject([
"A function must be",
"\\emph{continuous}",
"if it is to represent a curve."
])
words.split()[1].highlight(YELLOW_C)
self.add(words)
self.dither()
示例3: snells_law_at_every_point
# 需要导入模块: from mobject.tex_mobject import TextMobject [as 别名]
# 或者: from mobject.tex_mobject.TextMobject import split [as 别名]
def snells_law_at_every_point(self, cycloid, chopped_cycloid):
square = Square(side_length = 0.2, color = WHITE)
words = TextMobject(["Snell's law ", "everywhere"])
snells, rest = words.split()
colon = TextMobject(":")
words.next_to(square)
words.shift(0.3*UP)
combo = Mobject(square, words)
combo.get_center = lambda : square.get_center()
new_snells = snells.copy().center().to_edge(UP, buff = 1.5)
colon.next_to(new_snells)
colon.shift(0.05*DOWN)
self.play(MoveAlongPath(
combo, cycloid,
run_time = 5
))
self.play(MoveAlongPath(
combo, chopped_cycloid,
run_time = 4
))
dot = Dot(combo.get_center())
self.play(Transform(square, dot))
self.play(
Transform(snells, new_snells),
Transform(rest, colon)
)
self.dither()
return colon
示例4: construct
# 需要导入模块: from mobject.tex_mobject import TextMobject [as 别名]
# 或者: from mobject.tex_mobject.TextMobject import split [as 别名]
def construct(self):
words = TextMobject(
["Which path ", "would \\emph{light} take", "?"]
)
words.split()[1].highlight(YELLOW)
words.to_corner(UP+RIGHT)
self.add_cycloid_end_points()
anims = [
self.photon_run_along_path(
path,
rate_func = smooth
)
for path in self.get_paths()
]
self.play(anims[0], ShimmerIn(words))
for anim in anims[1:]:
self.play(anim)
示例5: __init__
# 需要导入模块: from mobject.tex_mobject import TextMobject [as 别名]
# 或者: from mobject.tex_mobject.TextMobject import split [as 别名]
def __init__(self, word, **kwargs):
self.path = Cycloid(end_theta = np.pi)
word_mob = TextMobject(list(word))
end_word = word_mob.copy()
end_word.shift(-end_word.get_bottom())
end_word.shift(self.path.get_corner(DOWN+RIGHT))
end_word.shift(3*RIGHT)
self.end_letters = end_word.split()
for letter in word_mob.split():
letter.center()
letter.angle = 0
unit_interval = np.arange(0, 1, 1./len(word))
self.start_times = 0.5*(1-(unit_interval))
Animation.__init__(self, word_mob, **kwargs)
示例6: construct
# 需要导入模块: from mobject.tex_mobject import TextMobject [as 别名]
# 或者: from mobject.tex_mobject.TextMobject import split [as 别名]
def construct(self):
clock = Circle(radius = 2, color = WHITE)
clock.add(Dot(ORIGIN))
ticks = Mobject(*[
Line(1.8*vect, 2*vect, color = GREY)
for vect in compass_directions(12)
])
clock.add(ticks)
hour_hand = Line(ORIGIN, UP)
minute_hand = Line(ORIGIN, 1.5*UP)
clock.add(hour_hand, minute_hand)
clock.to_corner(UP+RIGHT)
hour_hand.get_center = lambda : clock.get_center()
minute_hand.get_center = lambda : clock.get_center()
solution = ImageMobject(
"Newton_brachistochrone_solution2",
use_cache = False
)
solution.stroke_width = 3
solution.highlight(GREY)
solution.scale_to_fit_width(5)
solution.to_corner(UP+RIGHT)
newton = ImageMobject("Old_Newton", invert = False)
newton.scale(0.8)
phil_trans = TextMobject("Philosophical Transactions")
rect = Rectangle(height = 6, width = 4.5, color = WHITE)
rect.to_corner(UP+RIGHT)
rect.shift(DOWN)
phil_trans.scale_to_fit_width(0.8*rect.get_width())
phil_trans.next_to(Point(rect.get_top()), DOWN)
new_solution = solution.copy()
new_solution.scale_to_fit_width(phil_trans.get_width())
new_solution.next_to(phil_trans, DOWN, buff = 1)
not_newton = TextMobject("-Totally not by Newton")
not_newton.scale_to_fit_width(2.5)
not_newton.next_to(new_solution, DOWN, aligned_edge = RIGHT)
phil_trans.add(rect)
newton_complaint = TextMobject([
"``I do not love to be",
" \\emph{dunned} ",
"and teased by foreigners''"
], size = "\\small")
newton_complaint.to_edge(UP, buff = 0.2)
dunned = newton_complaint.split()[1]
dunned.highlight()
dunned_def = TextMobject("(old timey term for making \\\\ demands on someone)")
dunned_def.scale(0.7)
dunned_def.next_to(phil_trans, LEFT)
dunned_def.shift(2*UP)
dunned_arrow = Arrow(dunned_def, dunned)
johann = ImageMobject("Johann_Bernoulli2", invert = False)
johann.scale(0.4)
johann.to_edge(LEFT)
johann.shift(DOWN)
johann_quote = TextMobject("``I recognize the lion by his claw''")
johann_quote.next_to(johann, UP, aligned_edge = LEFT)
self.play(ApplyMethod(newton.to_edge, LEFT))
self.play(ShowCreation(clock))
kwargs = {
"axis" : OUT,
"rate_func" : smooth
}
self.play(
Rotating(hour_hand, radians = -2*np.pi, **kwargs),
Rotating(minute_hand, radians = -12*2*np.pi, **kwargs),
run_time = 5
)
self.dither()
self.clear()
self.add(newton)
clock.ingest_submobjects()
self.play(Transform(clock, solution))
self.remove(clock)
self.add(solution)
self.dither()
self.play(
FadeIn(phil_trans),
Transform(solution, new_solution)
)
self.dither()
self.play(ShimmerIn(not_newton))
phil_trans.add(solution, not_newton)
self.dither()
self.play(*map(ShimmerIn, newton_complaint.split()))
self.dither()
self.play(
ShimmerIn(dunned_def),
ShowCreation(dunned_arrow)
)
self.dither()
self.remove(dunned_def, dunned_arrow)
self.play(FadeOut(newton_complaint))
self.remove(newton_complaint)
self.play(
FadeOut(newton),
GrowFromCenter(johann)
#.........这里部分代码省略.........