animation¶
警告
这部分内容涉及 JAnim 实现原理,可能较为复杂,若没有研究源码的需求,你应酌情阅读
- class janim.anims.animation.TimeRange(at: float, duration: float)¶
基类:
object标识了从
at开始,持续时间为duration的时间区段end即at + duration- at: float¶
- duration: float¶
- property end: float¶
- class janim.anims.animation.Animation(*, at: float = 0, duration: float = 1.0, rate_func: RateFunc = <function smooth>)¶
基类:
object动画基类
创建一个从
at持续至at + duration的动画指定
rate_func可以设定插值函数,默认为janim.utils.rate_functions.smooth()即平滑插值
- label_color: tuple[float, float, float] = (128, 132, 137)¶
- compute_global_range(at: float, duration: float) None¶
计算
Timeline上的时间范围该方法是被
set_global_range()调用以计算的
- set_render_call_list(lst: list[RenderCall]) None¶
设置绘制调用,具体参考
RenderCall
- anim_pre_init() None¶
在
detect_changes_of_all()执行之前调用的初始化方法
- anim_init() None¶
在
detect_changes_of_all()执行之后调用的初始化方法
- anim_on(local_t: float) None¶
将
local_t换算为alpha并调用anim_on_alpha()
- get_alpha_on_global_t(global_t: float) float¶
传入全局
global_t,得到物件在该时刻应当处于哪个alpha的插值
- is_visible(global_t: float) bool¶
- global_t_ctx: ContextVar[float] = <ContextVar name='Animation.global_t_ctx'>¶
对该值进行设置,使得进行
anim_on()和render()时不需要将global_t作为参数传递也能获取到
- anim_on_alpha(alpha: float) None¶
动画在
alpha处的行为
- class janim.anims.animation.RenderCall(depth: Cmpt_Depth, func: Callable[[], None])¶
基类:
object绘制调用
depth: 该绘制的深度func: 该绘制所调用的函数
具体机制:
在每个动画对象中,都会使用
set_render_call_list()来设置该动画进行绘制时所执行的函数在进行渲染(具体参考
render_all())时,会按照深度进行排序,依次对func进行调用,深度越高的越先调用
例:
在
Display中,设置了单个RenderCall,作用是绘制物件在
Transform中,对于每个插值物件都设置了RenderCall,绘制所有的插值物件
- depth: Cmpt_Depth¶
- func: Callable[[], None]¶