本文整理汇总了Python中mobject.Mobject.ingest_submobjects方法的典型用法代码示例。如果您正苦于以下问题:Python Mobject.ingest_submobjects方法的具体用法?Python Mobject.ingest_submobjects怎么用?Python Mobject.ingest_submobjects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mobject.Mobject
的用法示例。
在下文中一共展示了Mobject.ingest_submobjects方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: show_sin_thetas
# 需要导入模块: from mobject import Mobject [as 别名]
# 或者: from mobject.Mobject import ingest_submobjects [as 别名]
def show_sin_thetas(self):
pc = Line(self.p_point, self.c_point)
mob = Mobject(self.theta, self.d_mob).copy()
mob.ingest_submobjects()
triplets = [
(pc, "D\\sin(\\theta)", 0.5),
(self.y_line, "D\\sin^2(\\theta)", 0.7),
]
for line, tex, scale in triplets:
trig_mob = TexMobject(tex)
trig_mob.scale_to_fit_width(
scale*line.get_length()
)
trig_mob.shift(-1.2*trig_mob.get_top())
trig_mob.rotate(line.get_angle())
trig_mob.shift(line.get_center())
if line is self.y_line:
trig_mob.shift(0.1*UP)
self.play(Transform(mob, trig_mob))
self.add(trig_mob)
self.dither()
self.remove(mob)
self.d_sin_squared_theta = trig_mob
示例2: get_edge_mobject
# 需要导入模块: from mobject import Mobject [as 别名]
# 或者: from mobject.Mobject import ingest_submobjects [as 别名]
def get_edge_mobject(self, image_array):
edged_image = get_edges(image_array)
individual_edges = get_connected_components(edged_image)
colored_edges = [
color_region(edge, image_array)
for edge in individual_edges
]
colored_edge_mobject_list = [
MobjectFromPixelArray(colored_edge)
for colored_edge in colored_edges
]
random.shuffle(colored_edge_mobject_list)
edge_mobject = Mobject(*colored_edge_mobject_list)
edge_mobject.ingest_submobjects()
return edge_mobject
示例3: construct
# 需要导入模块: from mobject import Mobject [as 别名]
# 或者: from mobject.Mobject import ingest_submobjects [as 别名]
def construct(self):
words = TextMobject("Order 2 Pseudo-Hilbert Curve")
words.to_edge(UP, buff = 0.3)
words.highlight(GREEN)
grid2 = Grid(2, 2)
grid4 = Grid(4, 4, stroke_width = 2)
# order_1_curve = HilbertCurve(order = 1)
# squaggle_curve = order_1_curve.copy().apply_function(
# lambda (x, y, z) : (x + np.cos(3*y), y + np.sin(3*x), z)
# )
# squaggle_curve.show()
mini_curves = [
HilbertCurve(order = 1).scale(0.5).shift(1.5*vect)
for vect in [
LEFT+DOWN,
LEFT+UP,
RIGHT+UP,
RIGHT+DOWN
]
]
last_curve = mini_curves[0]
naive_curve = Mobject(last_curve)
for mini_curve in mini_curves[1:]:
line = Line(last_curve.points[-1], mini_curve.points[0])
naive_curve.add(line, mini_curve)
last_curve = mini_curve
naive_curve.ingest_submobjects()
naive_curve.gradient_highlight(RED, GREEN)
order_2_curve = HilbertCurve(order = 2)
self.add(words, grid2)
self.dither()
self.play(ShowCreation(grid4))
self.play(*[
ShowCreation(mini_curve)
for mini_curve in mini_curves
])
self.dither()
self.play(ShowCreation(naive_curve, run_time = 5))
self.remove(*mini_curves)
self.dither()
self.play(Transform(naive_curve, order_2_curve))
self.dither()
示例4: construct
# 需要导入模块: from mobject import Mobject [as 别名]
# 或者: from mobject.Mobject import ingest_submobjects [as 别名]
def construct(self):
n_terms = 4
def func((x, y, ignore)):
z = complex(x, y)
if (np.abs(x%1 - 0.5)<0.01 and y < 0.01) or np.abs(z)<0.01:
return ORIGIN
out_z = 1./(2*np.tan(np.pi*z)*(z**2))
return out_z.real*RIGHT - out_z.imag*UP
arrows = Mobject(*[
Arrow(ORIGIN, np.sqrt(2)*point)
for point in compass_directions(4, RIGHT+UP)
])
arrows.highlight(YELLOW)
arrows.ingest_submobjects()
all_arrows = Mobject(*[
arrows.copy().scale(0.3/(x)).shift(x*RIGHT)
for x in range(1, n_terms+2)
])
terms = TexMobject([
"\\dfrac{1}{%d^2} + "%(x+1)
for x in range(n_terms)
]+["\\cdots"])
terms.shift(2*UP)
plane = NumberPlane(color = BLUE_E)
axes = Mobject(NumberLine(), NumberLine().rotate(np.pi/2))
axes.highlight(WHITE)
for term in terms.split():
self.play(ShimmerIn(term, run_time = 0.5))
self.dither()
self.play(ShowCreation(plane), ShowCreation(axes))
self.play(*[
Transform(*pair)
for pair in zip(terms.split(), all_arrows.split())
])
self.play(PhaseFlow(
func, plane,
run_time = 5,
virtual_time = 8
))