rotation¶
重要
如果你想要实现旋转效果,请不要尝试直接使用 self.play(item.anim.points.rotate(...)),
因为这只是在当前和结果之间进行 MethodTransform ,并无旋转效果
- class janim.anims.rotation.Rotate(item: Item, angle: float, *, axis: Vect = array([0., 0., 1.]), about_point: Vect | None = None, about_edge: Vect = array([0., 0., 0.]), root_only: bool = False, absolute: bool = True, **kwargs)¶
基类:
DataUpdater旋转,默认对角度进行平滑插值
参数和旋转基本一致
absolute参数是为了兼容摄像机物件,对于非摄像机物件该参数无效
RotateExample ¶
from janim.imports import *
class RotateExample(Timeline):
def construct(self):
square = Square(side_length=4).show()
self.play(
Rotate(
square,
PI / 4,
duration=2
)
)
self.forward(0.3)
self.play(
Rotate(
square,
PI,
axis=RIGHT,
duration=2,
)
)
self.forward(0.3)
- class janim.anims.rotation.Rotating(item: ~janim.items.points.Points, angle: float, *, rate_func=<function linear>, **kwargs)¶
基类:
Rotate旋转,默认对角度进行线性插值
RotatingExample ¶
from janim.imports import *
class RotatingExample(Timeline):
def construct(self):
square = Square(side_length=4).show()
self.play(
Rotating(
square,
PI / 4,
duration=2
)
)
self.forward(0.3)
self.play(
Rotating(
square,
PI,
axis=RIGHT,
duration=2,
)
)
self.forward(0.3)