Skip to content

Commit

Permalink
fix: pass args by calling animate that borrowed from CE
Browse files Browse the repository at this point in the history
  • Loading branch information
widcardw committed Sep 11, 2022
1 parent 2f69135 commit 603a773
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions manimlib/mobject/mobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -2017,6 +2017,7 @@ def __init__(self, mobject: Mobject):
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)
Expand All @@ -2041,6 +2042,9 @@ def update_target(*method_args, **method_kwargs):
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
Expand All @@ -2054,7 +2058,15 @@ def set_anim_args(self, **kwargs):
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):
Expand Down

0 comments on commit 603a773

Please sign in to comment.