rotation¶
Important
If you want to achieve a rotation effect, please avoid attempting to directly use self.play(item.anim.points.rotate(...)). This method only performs a MethodTransform between the current and resulting states, without creating a rotation effect.
To achieve a rotation effect, please use the provided Rotate and Rotating classes as shown below:
- 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)¶
Bases:
DataUpdaterRotation animation, default smooth interpolation for angles.
参数和旋转基本一致
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)¶
Bases:
RotateRotation animation, default linear interpolation for angles.
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)