From 603a773847821ef3b08a19e71b94b4b560a941ba Mon Sep 17 00:00:00 2001 From: widcardw Date: Sun, 11 Sep 2022 22:59:43 +0800 Subject: [PATCH] fix: pass args by calling `animate` that borrowed from CE --- manimlib/mobject/mobject.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/manimlib/mobject/mobject.py b/manimlib/mobject/mobject.py index a1d54fe8..8a1a5bff 100644 --- a/manimlib/mobject/mobject.py +++ b/manimlib/mobject/mobject.py @@ -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):