manim 5.0

5.0 版本是最终的版本,我将学习 3b1b 的类设计以及场景设计,并实现长视频的精美效果。我自己写的类缺点是需要重复查看物件的位置、大小等等,耗时太长

1、2022 borwein

第一个 Scene 中主要是对于函数图像进行操作:

class ShowIntegrals(InteractiveScene):
    def construct(self):
        # Setup axes
        axes = self.get_axes()
        graph = axes.get_graph(sinc, color=BLUE)
    def get_axes(self,
                 x_range=(-10 * PI, 10 * PI, PI),
                 y_range=(-0.5, 1, 0.5),
                 width=1.3 * FRAME_WIDTH,
                 height=3.5,
                 ):
        axes = Axes(x_range, y_range, width=width, height=height)
        axes.center()
        if self.add_axis_labels:
            axes.y_axis.add_numbers(num_decimal_places=1, font_size=20)
            for u in -1, 1:
                axes.x_axis.add_numbers(
                    u * np.arange(PI, 15 * PI, PI),
                    unit=PI,
                    unit_tex=R"\pi",
                    font_size=20
                )
        return axes
get_axes()

第二个 Scene 是一个小动画,在圆上演示了 sinx/x 的极限:

class SineLimit(InteractiveScene):
    def construct(self):
        axes = Axes((-4, 4), (-2, 2), width=14, height=7, axis_config=dict(tick_size=0))
        circle = Circle(radius=radius)

接下来的几个 Scene 都是写下一连串的积分公式,其中还使用了类的继承:

class WriteOutIntegrals(InteractiveScene):
    def construct(self):
        ints = self.get_integrals()

    def get_integrals(self):
        …
class WriteOutIntegralsWithPi(WriteOutIntegrals):
    def get_integrals(self):
        …

下面的场景都大同小异

posted @ 2023-02-12 12:20  树叶本子  阅读(52)  评论(0编辑  收藏  举报