Rotation

声明

这一页翻译自elteoremadebeethoven的 manim_3feb_docs

由鹤翔万里补充

Rotating

class manimlib.animation.rotation.Rotating(mobject, **kwargs)
RotatingExample
class RotatingExample(Scene):
    def construct(self):
        square=Square().scale(2)
        self.add(square)

        self.play(
            Rotating(
                square,
                radians=PI/4,
                run_time=2
            )
        )
        self.wait(0.3)
        self.play(
            Rotating(
                square,
                radians=PI,
                run_time=2,
                axis=RIGHT
            )
        )
        self.wait(0.3)

Rotate

class manimlib.animation.rotation.Rotate(mobject, angle=3.141592653589793, axis=array([0.0, 0.0, 1.0]), **kwargs)
RotateExample
class RotateExample(Scene):
    def construct(self):
        square=Square().scale(2)
        self.add(square)

        self.play(
            Rotate(
                square,
                PI/4,
                run_time=2
            )
        )
        self.wait(0.3)
        self.play(
            Rotate(
                square,
                PI,
                run_time=2,
                axis=RIGHT
            )
        )
        self.wait(0.3)

Rotate和Rotating的区别

Rotate 目前是 Transform 的子类,即带有 path_arcTransform ,所有会有扭曲

Rotating 直接继承自 Animation ,根据角度插值,比较顺滑,推荐使用

另外,请不要尝试直接使用 ApplyMethodself.play(mob.rotate, ...) 来旋转, 因为这只是在当前和结果之间进行 Transform ,并无旋转效果