Skip to content

Commit

Permalink
some pep8 and a change to docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
tburrows13 committed Apr 1, 2018
1 parent b852236 commit bd11c55
Showing 1 changed file with 17 additions and 21 deletions.
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)

0 comments on commit bd11c55

Please sign in to comment.