creation¶
- class janim.anims.creation.ShowPartial(item: Item, bound_func: Callable[[UpdaterParams], tuple[int, int]], *, auto_close_path: bool = False, become_at_end: bool = False, root_only: bool = False, zero_bound: int | None = None, **kwargs)¶
基类:
DataUpdater显示物件一部分的动画,显示的部分由
bound_func决定
ShowPartialExample ¶
from janim.imports import *
class ShowPartialExample(Timeline):
def construct(self):
group = Group(
Line(path_arc=PI),
Line(path_arc=PI),
Circle(),
Circle()
)
group.points.arrange(aligned_edge=DOWN)
func1 = lambda p: (0, p.alpha)
func2 = lambda p: (.5 - .5 * p.alpha, .5 + .5 * p.alpha)
self.play(
ShowPartial(group[0], func1),
ShowPartial(group[1], func2),
ShowPartial(group[2], func1),
ShowPartial(group[3], func2),
duration=3
)
- class janim.anims.creation.Create(item: Item, auto_close_path: bool = True, **kwargs)¶
基类:
ShowPartial显示物件的创建过程
CreateExample ¶
from janim.imports import *
class CreateExample(Timeline):
def construct(self):
group = Group(
Square(),
Square(),
Circle(fill_alpha=0.5),
Text('Text', font_size=48),
color=BLUE
)
group.points.arrange(buff=LARGE_BUFF)
self.play(
Create(group[0], auto_close_path=False),
Create(group[1:]),
duration=3
)
- class janim.anims.creation.Uncreate(item: Item, hide_at_end: bool = True, auto_close_path: bool = True, **kwargs)¶
基类:
ShowPartial显示物件的销毁过程(
Create的倒放)
UncreateExample ¶
from janim.imports import *
class UncreateExample(Timeline):
def construct(self):
group = Group(
Square(),
Square(),
Circle(fill_alpha=0.5),
Text('Text', font_size=48),
color=BLUE
)
group.points.arrange(buff=LARGE_BUFF)
self.play(
Uncreate(group[0], auto_close_path=False),
Uncreate(group[1:]),
duration=3
)
- class janim.anims.creation.Destruction(item: Item, hide_at_end: bool = True, auto_close_path: bool = True, **kwargs)¶
基类:
ShowPartial显示物件的销毁过程
与
Uncreate方向相反
DestructionExample ¶
class DestructionExample(Timeline):
def construct(self):
group = Group(
Square(),
Square(),
Circle(fill_alpha=0.5),
Text('Text', font_size=48),
color=BLUE
)
group.points.arrange(buff=LARGE_BUFF)
self.play(
Destruction(group[0], auto_close_path=False),
Destruction(group[1:]),
duration=3
)
- class janim.anims.creation.DrawBorderThenFill(item: ~janim.items.item.Item, *, duration: float = 2.0, stroke_radius: float = 0.01, scale_with_camera: bool = False, stroke_color: JAnimColor = None, rate_func: RateFunc = <function double_smooth>, become_at_end: bool = False, root_only: bool = False, **kwargs)¶
基类:
DataUpdater画出边缘,然后填充颜色
可以使用
stroke_radius参数调整“画出边缘”时的描边粗细,在默认画面下的值是 0.01如果设置了
scale_with_camera参数,描边粗细会随着camera大小的变化而调整,画面尺寸越小,描边越细
DrawBorderThenFillExample ¶
from janim.imports import *
class DrawBorderThenFillExample(Timeline):
def construct(self):
group = Group(
Square(fill_alpha=0.5),
Circle(fill_alpha=0.5),
Text('Text', font_size=48),
color=BLUE
)
group.points.arrange(buff=LARGE_BUFF)
self.play(
DrawBorderThenFill(group),
duration=3
)
self.forward()
self.play(
DrawBorderThenFill(group, stroke_radius=0.02),
duration=3
)
self.forward()
- class janim.anims.creation.Write(item: ~janim.items.item.Item, *, duration: float | None = None, lag_ratio: float | None = None, rate_func: RateFunc = <function linear>, skip_null_items: bool = True, root_only: bool = False, **kwargs)¶
-
显示书写过程(对每个子物件应用
DrawBorderThenFill)
WriteExample ¶
from janim.imports import *
class WriteExample(Timeline):
def construct(self):
dots = Dot(color=BLUE) * 10
dots.points.arrange().shift(UP)
txt = Text('Text text Text text')
txt.points.shift(DOWN)
self.play(
Write(dots, duration=2),
Write(txt, duration=2),
)
- class janim.anims.creation.ShowIncreasingSubsets(group: ~janim.items.points.Group[~janim.items.item.Item], *, int_func=<built-in function round>, show_at_begin: bool = True, hide_at_end: bool = False, **kwargs)¶
基类:
Animation
ShowIncreasingSubsetsExample ¶
from janim.imports import *
class ShowIncreasingSubsetsExample(Timeline):
def construct(self):
text = Text('ShowIncreasingSubsets')
text.points.set_width(11)
self.forward(0.5)
self.play(ShowIncreasingSubsets(text[0], duration=3))
self.forward(0.5)
- class janim.anims.creation.ShowSubitemsOneByOne(group: ~janim.items.points.Group, *, int_func=<built-in function ceil>, hide_at_end: bool = True, **kwargs)¶
ShowSubitemsOneByOneExample ¶
from janim.imports import *
class ShowSubitemsOneByOneExample(Timeline):
def construct(self):
text = Text('ShowSubitemsOneByOne')
text.points.set_width(11)
self.forward(0.5)
self.play(ShowSubitemsOneByOne(text[0], duration=3))
self.forward(0.5)