python中的manim

1  import time
2
3   import numpy as np
4   from manim import *
5
6   class BooleanOperations(Scene):
7       def construct(self):
8            circle=Circle()
9            square=Square()
10           square.rotate(np.pi/8)
11           self.play(ShowCreationThenFadeOut(square))
12           self.play(Transform(square,circle))
13           self.wait(1)

这是我们遇到的第一个例子,按照行号的顺序详细说明一下:

    6行:建立一个场景,名字叫做 BooleanOperations

    7行:创建场景的方法

    8行:创建一个圆,命名为circle

    9行:创建一个正方形,命名为square

    10行:将square旋转π/8

    11行:播放square的创造过程

    12行:播放square到circle的变换过程

    13行:停顿1秒,随后结束 (self.dither可能无法使用)

from manim import *
class CreateCircle(Scene):
    def construct(self):
        circle=Circle()
        circle.set_fill(PINK,opacity=1)
        self.play(ShowCreationThenFadeOut(circle))
        self.wait()

circle=Circle()

circle.set_fill(PINK,opacity=0.5)  表示两行创建一个圆并设置其颜色和不透明度。

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
square=Square() 创建一个正方形
square.rotate(PI/4)   旋转π/4
self.play(ShowCreationThenFadeOut(square))  在视频中展现
self.play(Transform(square,circle))        从正方形转化为圆形
self.play(FadeOut(square)) : FadeIn(淡入)FadeOut(淡出)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值