正方形转换圆
完成圆圈动画后,让我们继续进行更复杂的作。
打开
scene.py
,并在CreateCircle
类下方添加以下代码片段:
class SquareToCircle(Scene):
def construct(self):
circle = Circle() # create a circle
circle.set_fill(PINK, opacity=0.5) # set color and transparency
square = Square() # create a square
square.rotate(PI / 4) # rotate a certain amount
self.play(Create(square)) # animate the creation of the square
self.play(Transform(square, circle)) # interpolate the square into the circle
self.play(FadeOut(square)) # fade out animation
通过在命令行中运行以下命令进行渲染:
SquareToCircle
manim -pql scene.py SquareToCircle
此示例显示了 Manim 的主要功能之一:能够只需几行代码即可实现复杂且数学密集型的动画(例如干净地在两个几何形状之间插值)。
Last updated