data

class janim.components.data.Cmpt_Data

详见 ValueTracker

copy() Self
become(other: Cmpt_Data) Self
not_changed(other: Cmpt_Data) bool
classmethod align_for_interpolate(cmpt1: Cmpt_Data, cmpt2: Cmpt_Data) AlignedData[Self]
interpolate(cmpt1: Cmpt_Data, cmpt2: Cmpt_Data, alpha: float, *, path_func=None) None
set(value: T) Self

设置当前值

get() T

得到当前值

increment(value: T) Self

将值增加 value,只对一些简单的类型有效

update(patch: T) Self

基于字典的部分项更新原有字典

set_func(copy_func: CopyFn[T] | None = None, not_changed_func: NotChangedFn[T] | None = None, interpolate_func: InterpolateFn[T] | None = None) Self
class IsinstanceResolver
register(isinstance_check: ClassInfo, resolved: T) None
update_cache(value, resolved: T) None
resolve(value) T | None
clear_cache() None
static register_funcs(isinstance_check: ClassInfo, copy_func: CopyFn, not_changed_func: NotChangedFn, interpolate_func: InterpolateFn) None
static copy_for_value(value: T) T
static check_not_changed_for_value(a: T, b: T) bool
static interpolate_for_value(a: T, b: T, alpha: float) T
static register_update_func(isinstance_check: ClassInfo, update_func: UpdateFn) None
static update_for_value(state: T, patch: T) T
class janim.components.data.CustomData

用于例如

class PhysicalBlock(Square):
    physic = CustomData()

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.physic.set({
            'speed': ORIGIN,    # 默认静止
            'accel': ORIGIN,    # 并且没有加速度
        })

可以完善类型注解

from typing import TypedDict

class PhysicData(TypedDict):
    speed: np.ndarray
    accel: np.ndarray

class PhysicalBlock(Square):
    physic = CustomData[Self, PhysicData]()

    ...
exception janim.components.data.TrackerShapeError(message: str, *, missing: set | None = None, extra: set | None = None)
source_cls_name_ctx: ContextVar = <ContextVar name='config_ctx_var'>
static get_source_cls_name() str