fix: pass args by calling animate that borrowed from CE

This commit is contained in:
widcardw
2022-09-11 22:59:43 +08:00
parent 2f691355db
commit 603a773847

View File

@ -2017,6 +2017,7 @@ class _AnimationBuilder:
self.is_chaining = False
self.methods: list[Callable] = []
self.anim_args = {}
self.can_pass_args = True
def __getattr__(self, method_name: str):
method = getattr(self.mobject.target, method_name)
@ -2041,6 +2042,9 @@ class _AnimationBuilder:
self.is_chaining = True
return update_target
def __call__(self, **kwargs):
return self.set_anim_args(**kwargs)
def set_anim_args(self, **kwargs):
'''
You can change the args of :class:`~manimlib.animation.transform.Transform`, such as
@ -2054,7 +2058,15 @@ class _AnimationBuilder:
and so on.
'''
if not self.can_pass_args:
raise ValueError(
"Animation arguments can only be passed by calling ``animate`` "
"or ``set_anim_args`` and can only be passed once",
)
self.anim_args = kwargs
self.can_pass_args = False
return self
def build(self):