Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

transitions.py: pep8 and a change to docstring #754

Merged
merged 1 commit into from
Apr 1, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 17 additions & 21 deletions moviepy/video/compositing/transitions.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
"""
Here is the current catalogue. These are meant
to be used with clip.fx. There are available as transfx.crossfadein etc.
if you load them with ``from moviepy.all import *``
if you load them with ``from moviepy.editor import *``
"""

from moviepy.decorators import requires_duration, add_mask_if_none
from .CompositeVideoClip import CompositeVideoClip
from moviepy.video.fx.fadein import fadein
from moviepy.video.fx.fadeout import fadeout


@requires_duration
@add_mask_if_none
def crossfadein(clip, duration):
Expand All @@ -33,8 +34,6 @@ def crossfadeout(clip, duration):
return newclip




def slide_in(clip, duration, side):
""" Makes the clip arrive from one side of the screen.

Expand Down Expand Up @@ -64,14 +63,13 @@ def slide_in(clip, duration, side):
>>> final_clip = concatenate( slided_clips, padding=-1)

"""
w,h = clip.size
pos_dict = {'left' : lambda t: (min(0,w*(t/duration-1)),'center'),
'right' : lambda t: (max(0,w*(1-t/duration)),'center'),
'top' : lambda t: ('center',min(0,h*(t/duration-1))),
'bottom': lambda t: ('center',max(0,h*(1-t/duration)))}

return clip.set_pos( pos_dict[side] )
w, h = clip.size
pos_dict = {'left': lambda t: (min(0, w*(t/duration-1)), 'center'),
'right': lambda t: (max(0, w*(1-t/duration)), 'center'),
'top': lambda t: ('center', min(0, h*(t/duration-1))),
'bottom': lambda t: ('center', max(0, h*(1-t/duration)))}

return clip.set_pos(pos_dict[side])


@requires_duration
Expand Down Expand Up @@ -105,14 +103,14 @@ def slide_out(clip, duration, side):

"""

w,h = clip.size
ts = clip.duration - duration # start time of the effect.
pos_dict = {'left' : lambda t: (min(0,w*(1-(t-ts)/duration)),'center'),
'right' : lambda t: (max(0,w*((t-ts)/duration-1)),'center'),
'top' : lambda t: ('center',min(0,h*(1-(t-ts)/duration))),
'bottom': lambda t: ('center',max(0,h*((t-ts)/duration-1))) }
w, h = clip.size
ts = clip.duration - duration # start time of the effect.
pos_dict = {'left': lambda t: (min(0, w*(-(t-ts)/duration)), 'center'),
'right': lambda t: (max(0, w*((t-ts)/duration)), 'center'),
'top': lambda t: ('center', min(0, h*(-(t-ts)/duration))),
'bottom': lambda t: ('center', max(0, h*((t-ts)/duration)))}

return clip.set_pos( pos_dict[side] )
return clip.set_pos(pos_dict[side])


@requires_duration
Expand All @@ -121,7 +119,5 @@ def make_loopable(clip, cross_duration):
it can be looped indefinitely. ``cross`` is the duration in seconds
of the fade-in. """
d = clip.duration
clip2 = clip.fx(crossfadein, cross_duration).\
set_start(d - cross_duration)
return CompositeVideoClip([ clip, clip2 ]).\
subclip(cross_duration,d)
clip2 = clip.fx(crossfadein, cross_duration).set_start(d - cross_duration)
return CompositeVideoClip([clip, clip2]).subclip(cross_duration, d)