mirror of
https://github.com/3b1b/manim.git
synced 2025-08-05 16:49:03 +00:00
Added final_alpha_value parameter to Animation for things like FadeOut
This commit is contained in:
parent
852e840523
commit
35a2ade954
2 changed files with 13 additions and 5 deletions
|
@ -17,6 +17,8 @@ class Animation(object):
|
|||
"name": None,
|
||||
# Does this animation add or remove a mobject form the screen
|
||||
"remover": False,
|
||||
# What to enter into the update function upon completion
|
||||
"final_alpha_value": 1,
|
||||
# If 0, the animation is applied to all submobjects
|
||||
# at the same time
|
||||
# If 1, it is applied to each successively.
|
||||
|
@ -55,7 +57,7 @@ class Animation(object):
|
|||
self.interpolate(0)
|
||||
|
||||
def finish(self):
|
||||
self.interpolate(1)
|
||||
self.interpolate(self.final_alpha_value)
|
||||
self.mobject.cleanup_from_animation()
|
||||
if self.suspend_mobject_updating:
|
||||
self.mobject.resume_updating()
|
||||
|
|
|
@ -14,6 +14,8 @@ class FadeOut(Transform):
|
|||
CONFIG = {
|
||||
"remover": True,
|
||||
"lag_ratio": DEFAULT_FADE_LAG_RATIO,
|
||||
# Put it back in original state when done
|
||||
"final_alpha_value": 0,
|
||||
}
|
||||
|
||||
def __init__(self, mobject, to_vect=ORIGIN, **kwargs):
|
||||
|
@ -26,9 +28,9 @@ class FadeOut(Transform):
|
|||
result.shift(self.to_vect)
|
||||
return result
|
||||
|
||||
def clean_up_from_scene(self, scene=None):
|
||||
super().clean_up_from_scene(scene)
|
||||
self.interpolate(0)
|
||||
# def clean_up_from_scene(self, scene=None):
|
||||
# super().clean_up_from_scene(scene)
|
||||
# self.interpolate(0)
|
||||
|
||||
|
||||
class FadeIn(Transform):
|
||||
|
@ -113,7 +115,9 @@ class VFadeIn(Animation):
|
|||
|
||||
class VFadeOut(VFadeIn):
|
||||
CONFIG = {
|
||||
"remover": True
|
||||
"remover": True,
|
||||
# Put it back in original state when done
|
||||
"final_alpha_value": 0,
|
||||
}
|
||||
|
||||
def interpolate_submobject(self, submob, start, alpha):
|
||||
|
@ -124,4 +128,6 @@ class VFadeInThenOut(VFadeIn):
|
|||
CONFIG = {
|
||||
"rate_func": there_and_back,
|
||||
"remover": True,
|
||||
# Put it back in original state when done
|
||||
"final_alpha_value": 0.5,
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue