Skip to content

Commit

Permalink
feat: add set_anim_args to .animate method
Browse files Browse the repository at this point in the history
  • Loading branch information
widcardw committed Sep 11, 2022
1 parent 650d49c commit a613099
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions manimlib/animation/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,9 @@ def check_validity_of_input(self, mobject: Mobject) -> None:


class _MethodAnimation(MoveToTarget):
def __init__(self, mobject: Mobject, methods: Callable):
def __init__(self, mobject: Mobject, methods: list[Callable], **kwargs):
self.methods = methods
super().__init__(mobject)
super().__init__(mobject, **kwargs)


class ApplyMethod(Transform):
Expand Down
9 changes: 7 additions & 2 deletions manimlib/mobject/mobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -2015,7 +2015,8 @@ def __init__(self, mobject: Mobject):
self.overridden_animation = None
self.mobject.generate_target()
self.is_chaining = False
self.methods = []
self.methods: list[Callable] = []
self.anim_args = {}

def __getattr__(self, method_name: str):
method = getattr(self.mobject.target, method_name)
Expand All @@ -2040,13 +2041,17 @@ def update_target(*method_args, **method_kwargs):
self.is_chaining = True
return update_target

def set_anim_args(self, **kwargs):
self.anim_args = kwargs
return self

def build(self):
from manimlib.animation.transform import _MethodAnimation

if self.overridden_animation:
return self.overridden_animation

return _MethodAnimation(self.mobject, self.methods)
return _MethodAnimation(self.mobject, self.methods, **self.anim_args)


def override_animate(method):
Expand Down

0 comments on commit a613099

Please sign in to comment.