anim_stack¶
Warning
This section covers the implementations of JAnim, which may be quite complex. If you do not have the need to delve into the source code, you may choose to read it at your discretion.
- class janim.anims.anim_stack.AnimStack(item: Item, time_aligner: TimeAligner)¶
Bases:
objectUsed to record
Animationobjects acting onIteminTimeline- detect_change(item: Item, at: float, *, force: bool = False) None¶
Check if the item has changed compared to the item recorded in
self.prev_displayIf there are changes, record them as a
Displayobject
- has_detected_change() bool¶
- append(anim: ItemAnimation) None¶
- get_at_left(as_time: float) list[ItemAnimation]¶
- get(as_time: float) list[ItemAnimation]¶
- compute(as_time: float, readonly: bool, *, get_at_left: bool = False) Item¶
Get the item at the specified time
as_time, taking into account the effects of animationsreadonlyindicates whether the caller will modify the return valueIf
readonly=True, it means no modification will be made, and the method will safely return the cache directly (but this is not a hard constraint; when passingreadonly=True, please follow the principle of not modifying the return value to avoid affecting cached data)If
readonly=False, it means modification will be made, and a copy of the cache will be returned to avoid affecting cached data
For example:
The call in
item_current()isreadonly=Falsebecause the return value ofitem_current()will eventually be used by the user, and we cannot guarantee whether the user will modify it, so we simply assume the user will modify itFor example, when used for rendering, the call is
readonly=Truebecause rendering does not affect item data
- compute_anims(as_time: float, anims: list[ItemAnimation]) ComputeAnimsGenerator¶
- clear_cache() None¶