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: object

Used to record Animation objects acting on Item in Timeline

detect_change(item: Item, at: float, *, force: bool = False) None

Check if the item has changed compared to the item recorded in self.prev_display

If there are changes, record them as a Display object

is_changed(item: Item) bool
has_detected_change() bool
detect_change_if_not(item: Item) None
append(anim: ItemAnimation) None

Add an Animation object to AnimStack

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 animations

readonly indicates whether the caller will modify the return value

  • If 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 passing readonly=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() is readonly=False because the return value of item_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 it

  • For example, when used for rendering, the call is readonly=True because rendering does not affect item data

compute_anims(as_time: float, anims: list[ItemAnimation]) ComputeAnimsGenerator
clear_cache() None