本文整理汇总了Python中mobject.Mobject.gradient_highlight方法的典型用法代码示例。如果您正苦于以下问题:Python Mobject.gradient_highlight方法的具体用法?Python Mobject.gradient_highlight怎么用?Python Mobject.gradient_highlight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mobject.Mobject
的用法示例。
在下文中一共展示了Mobject.gradient_highlight方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: construct
# 需要导入模块: from mobject import Mobject [as 别名]
# 或者: from mobject.Mobject import gradient_highlight [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()