Added VFadeIn and VFadeOut

This commit is contained in:
Grant Sanderson
2018-05-16 00:04:59 -07:00
parent 8c516675cb
commit bf1fbaba7a

View File

@ -160,6 +160,33 @@ class FadeInFromDown(FadeInAndShiftFromDirection):
"direction": DOWN,
}
class VFadeIn(Animation):
"""
VFadeIn and VFadeOut only work for VMobjects, but they can be applied
to mobjects while they are being animated in some other way (e.g. shifting
then) in a way that does not work with FadeIn and FadeOut
"""
def update_submobject(self, submobject, starting_submobject, alpha):
submobject.set_stroke(
width=interpolate(0, starting_submobject.get_stroke_width(), alpha)
)
submobject.set_fill(
opacity=interpolate(0, starting_submobject.get_fill_opacity(), alpha)
)
class VFadeOut(VFadeIn):
CONFIG = {
"remover": True
}
def update_submobject(self, submobject, starting_submobject, alpha):
VFadeIn.update_submobject(
self, submobject, starting_submobject, 1 - alpha
)
# Growing