stackable¶
- class janim.anims_core.stackable.StackableAnimation(*args, **kwargs)¶
Bases:
AnimationBase class for animations that can be recorded in
AnimStackMainly implements the stack calling process of
apply()- apply(params: ApplyParams) None¶
For details, see the descriptions of
StackableAnimationandApplyParams
- add_to_stack(item: Item, *, _is_display: bool = False) None¶
Adds this animation to the animation stack of
item
- debug_str() str¶
Outputs in the form
CLASS_NAME at 0x...... order ANIM_ORDER.If the animation was generated by another animation (
_generate_by), outputs it in the formCLASS_NAME at 0x...... order ANIM_ORDER (from CLASS_NAME at 0x......).
- class janim.anims_core.stackable.ApplyParams(data: Item, global_t: float, index: int, anims: list[StackableAnimation])¶
Bases:
objectSingle-object parameters passed to
apply()datarepresents the current item state being calculated and needs to be set insideapply()It starts as
Noneand gradually has various animation effects applied to it through calls toapply()Initially,
dataisNoneand is always initialized byDisplayBecause we directly call
display()inAnimStackto record aDisplayobject, the first animation in the animation stack is alwaysDisplayAfterwards,
datais retained and passed to the next animation’sapply()function each time, allowing the entire animation stack to be processed and the final display state to be obtained
For
index, it starts from0and gradually increases with each call toapply()It represents the index of the currently applied animation in
anims
Additionally:
global_trepresents the current global timeindexrepresents the index of the current animation in the animation stackanimsis the complete current animation stack
- global_t: float¶
- index: int¶
- anims: list[StackableAnimation]¶
- class janim.anims_core.stackable.ItemAnimation(item: Item, *, show_at_begin: bool = True, hide_at_end: bool = False, **kwargs)¶
Bases:
StackableAnimationBase class for most item animations
The main differences between this class and
StackableAnimationare:Automatically adds
itemto the tracking ofAnimStackWraps the
show_at_beginandhide_at_endparameters, providing relatively direct control over when items are shown or hidden
- class janim.anims_core.stackable.ApplyAligner(item: Item, stacks: list[AnimStack], **kwargs)¶
Bases:
ItemAnimationUsed to handle coordination between multiple animation stacks
Mainly used for
GroupUpdaterDescription:
A normal
StackableAnimationsimply applies a single animation stack from beginning to endHowever, for example,
GroupUpdaterneeds to wait for the animation stacks of multiple items to reach an expected “gate” simultaneously. Only after all have reached the gate can thisGroupUpdaterbegin execution. After execution finishes, the “gate” opens and allows each animation stack to continueMechanism:
When
AnimStackencounters anApplyAligneranimation during computation, it first calls itspre_apply()method for preparation (for example, forGroupUpdater, this synchronizes the current animation stack’s calculation state to its internal item group)After calling
pre_apply(),AnimStackusesyieldto temporarily suspend the execution of the current animation stack and triggers the computation of the items that need to wait (that is, thestackscollected from the constructor arguments). After all of them have reached the “gate”, it formally executesStackableAnimation.apply()to achieve the desired resultNote: For
ApplyAlignerinstances operating on the same group of items, the samestacksmust be passed to ensure thatidentifier()identifies them correctly- property identifier: int¶
- pre_apply(params: ApplyParams) None¶