mirror of
https://github.com/3b1b/manim.git
synced 2025-08-05 16:49:03 +00:00
Mild reorganization
This commit is contained in:
parent
2d945dc929
commit
691d5b7657
1 changed files with 26 additions and 22 deletions
|
@ -28,7 +28,14 @@ class Animation(object):
|
||||||
digest_config(self, kwargs)
|
digest_config(self, kwargs)
|
||||||
self.mobject = mobject
|
self.mobject = mobject
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
if self.name:
|
||||||
|
return self.name
|
||||||
|
return self.__class__.__name__ + str(self.mobject)
|
||||||
|
|
||||||
def begin(self):
|
def begin(self):
|
||||||
|
# As much initialization as possible, especially any
|
||||||
|
# mobject copying, should live in this method
|
||||||
mobject = self.mobject
|
mobject = self.mobject
|
||||||
# Keep track of where it started
|
# Keep track of where it started
|
||||||
self.starting_mobject = mobject.copy()
|
self.starting_mobject = mobject.copy()
|
||||||
|
@ -49,17 +56,17 @@ class Animation(object):
|
||||||
if self.is_remover():
|
if self.is_remover():
|
||||||
scene.remove(self.mobject)
|
scene.remove(self.mobject)
|
||||||
|
|
||||||
def __str__(self):
|
def get_all_mobjects(self):
|
||||||
if self.name:
|
"""
|
||||||
return self.name
|
Ordering must match the ording of arguments to interpolate_submobject
|
||||||
return self.__class__.__name__ + str(self.mobject)
|
"""
|
||||||
|
return self.mobject, self.starting_mobject
|
||||||
|
|
||||||
def copy(self):
|
def get_all_families_zipped(self):
|
||||||
return deepcopy(self)
|
return list(zip(*map(
|
||||||
|
Mobject.family_members_with_points,
|
||||||
def update_config(self, **kwargs):
|
self.get_all_mobjects()
|
||||||
digest_config(self, kwargs)
|
)))
|
||||||
return self
|
|
||||||
|
|
||||||
def update_mobjects(self, dt):
|
def update_mobjects(self, dt):
|
||||||
"""
|
"""
|
||||||
|
@ -72,6 +79,14 @@ class Animation(object):
|
||||||
for mob in self.get_all_mobjects():
|
for mob in self.get_all_mobjects():
|
||||||
mob.update(dt)
|
mob.update(dt)
|
||||||
|
|
||||||
|
def copy(self):
|
||||||
|
return deepcopy(self)
|
||||||
|
|
||||||
|
def update_config(self, **kwargs):
|
||||||
|
digest_config(self, kwargs)
|
||||||
|
return self
|
||||||
|
|
||||||
|
# Methods for interpolation, the mean of an Animation
|
||||||
def interpolate(self, alpha):
|
def interpolate(self, alpha):
|
||||||
alpha = np.clip(alpha, 0, 1)
|
alpha = np.clip(alpha, 0, 1)
|
||||||
self.interpolate_mobject(self.rate_func(alpha))
|
self.interpolate_mobject(self.rate_func(alpha))
|
||||||
|
@ -106,18 +121,7 @@ class Animation(object):
|
||||||
0, 1,
|
0, 1,
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_all_mobjects(self):
|
# Getters and setters
|
||||||
"""
|
|
||||||
Ordering must match the ording of arguments to interpolate_submobject
|
|
||||||
"""
|
|
||||||
return self.mobject, self.starting_mobject
|
|
||||||
|
|
||||||
def get_all_families_zipped(self):
|
|
||||||
return list(zip(*map(
|
|
||||||
Mobject.family_members_with_points,
|
|
||||||
self.get_all_mobjects()
|
|
||||||
)))
|
|
||||||
|
|
||||||
def set_run_time(self, run_time):
|
def set_run_time(self, run_time):
|
||||||
self.run_time = run_time
|
self.run_time = run_time
|
||||||
return self
|
return self
|
||||||
|
|
Loading…
Add table
Reference in a new issue