mirror of
https://github.com/3b1b/manim.git
synced 2025-08-05 16:49:03 +00:00
Added create_starting_mobject method, and suspend_mobject_updating config variable
This commit is contained in:
parent
10850c5af6
commit
9baae55836
1 changed files with 16 additions and 11 deletions
|
@ -21,6 +21,7 @@ class Animation(object):
|
||||||
# If 0 < lag_ratio < 1, its applied to each
|
# If 0 < lag_ratio < 1, its applied to each
|
||||||
# with lagged start times
|
# with lagged start times
|
||||||
"lag_ratio": 0,
|
"lag_ratio": 0,
|
||||||
|
"suspend_mobject_updating": True,
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, mobject, **kwargs):
|
def __init__(self, mobject, **kwargs):
|
||||||
|
@ -38,26 +39,30 @@ class Animation(object):
|
||||||
# played. As much initialization as possible,
|
# played. As much initialization as possible,
|
||||||
# especially any mobject copying, should live in
|
# especially any mobject copying, should live in
|
||||||
# this method
|
# this method
|
||||||
mobject = self.mobject
|
self.starting_mobject = self.create_starting_mobject()
|
||||||
# Keep track of where it started
|
if self.suspend_mobject_updating:
|
||||||
self.starting_mobject = mobject.copy()
|
|
||||||
# All calls to self.mobject's internal updaters
|
# All calls to self.mobject's internal updaters
|
||||||
# during the animation, either from this Animation
|
# during the animation, either from this Animation
|
||||||
# or from the surrounding scene, should do nothing.
|
# or from the surrounding scene, should do nothing.
|
||||||
# It is, however, okay and desirable to call
|
# It is, however, okay and desirable to call
|
||||||
# the internal updaters of self.starting_mobject,
|
# the internal updaters of self.starting_mobject,
|
||||||
# or any others among self.get_all_mobjects()
|
# or any others among self.get_all_mobjects()
|
||||||
mobject.suspend_updating()
|
self.mobject.suspend_updating()
|
||||||
self.interpolate(0)
|
self.interpolate(0)
|
||||||
|
|
||||||
def finish(self):
|
def finish(self):
|
||||||
self.interpolate(1)
|
self.interpolate(1)
|
||||||
|
if self.suspend_mobject_updating:
|
||||||
self.mobject.resume_updating()
|
self.mobject.resume_updating()
|
||||||
|
|
||||||
def clean_up_from_scene(self, scene):
|
def clean_up_from_scene(self, scene):
|
||||||
if self.is_remover():
|
if self.is_remover():
|
||||||
scene.remove(self.mobject)
|
scene.remove(self.mobject)
|
||||||
|
|
||||||
|
def create_starting_mobject(self):
|
||||||
|
# Keep track of where the mobject starts
|
||||||
|
return self.mobject.copy()
|
||||||
|
|
||||||
def get_all_mobjects(self):
|
def get_all_mobjects(self):
|
||||||
"""
|
"""
|
||||||
Ordering must match the ording of arguments to interpolate_submobject
|
Ordering must match the ording of arguments to interpolate_submobject
|
||||||
|
|
Loading…
Add table
Reference in a new issue