Skip to content

Commit 710c6df

Browse files
authored
Fix slide out (#795)
1 parent 21267dd commit 710c6df

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

moviepy/video/compositing/transitions.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ def slide_in(clip, duration, side):
5959
6060
>>> from moviepy.editor import *
6161
>>> clips = [... make a list of clips]
62-
>>> slided_clips = [clip.fx( transfx.slide_in, 1, 'left')
62+
>>> slided_clips = [CompositeVideoClip([
63+
clip.fx(transfx.slide_in, duration=1, side='left')])
6364
for clip in clips]
6465
>>> final_clip = concatenate( slided_clips, padding=-1)
6566
@@ -98,18 +99,19 @@ def slide_out(clip, duration, side):
9899
99100
>>> from moviepy.editor import *
100101
>>> clips = [... make a list of clips]
101-
>>> slided_clips = [clip.fx( transfx.slide_out, 1, 'bottom')
102+
>>> slided_clips = [CompositeVideoClip([
103+
clip.fx(transfx.slide_out, duration=1, side='left')])
102104
for clip in clips]
103105
>>> final_clip = concatenate( slided_clips, padding=-1)
104106
105107
"""
106108

107-
w, h = clip.size
108-
ts = clip.duration - duration # start time of the effect.
109-
pos_dict = {'left': lambda t: (min(0, w*(1-(t-ts)/duration)), 'center'),
110-
'right': lambda t: (max(0, w*((t-ts)/duration-1)), 'center'),
111-
'top': lambda t: ('center', min(0, h*(1-(t-ts)/duration))),
112-
'bottom': lambda t: ('center', max(0, h*((t-ts)/duration-1)))}
109+
w,h = clip.size
110+
ts = clip.duration - duration # start time of the effect.
111+
pos_dict = {'left' : lambda t: (min(0,w*(-(t-ts)/duration)),'center'),
112+
'right' : lambda t: (max(0,w*((t-ts)/duration)),'center'),
113+
'top' : lambda t: ('center',min(0,h*(-(t-ts)/duration))),
114+
'bottom': lambda t: ('center',max(0,h*((t-ts)/duration))) }
113115

114116
return clip.set_position(pos_dict[side])
115117

0 commit comments

Comments
 (0)