forked from Selur/VapoursynthScriptsInHybrid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrekt.py
21 lines (19 loc) · 872 Bytes
/
rekt.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import vapoursynth as vs
from vapoursynth import core
def rekt(src, fix, left=0, top=0, right=0, bottom=0):
'''Creates a rectangular "mask" for a fix to be applied to.'''
if left > 0 or right > 0:
m = core.std.Crop(fix, left=left, right=right)
l = core.std.Crop(src, right=src.width - left) if left > 0 else 0
r = core.std.Crop(src, left=src.width - right) if right > 0 else 0
params = [x for x in [l, m, r] if x != 0]
m = core.std.StackHorizontal(params)
else:
m = fix
if top > 0 or bottom > 0:
t = core.std.Crop(src, bottom=src.height - top) if top > 0 else 0
m = core.std.Crop(m, bottom=bottom, top=top)
b = core.std.Crop(src, top=src.height - bottom) if bottom > 0 else 0
params = [x for x in [t, m, b] if x != 0]
m = core.std.StackVertical(params)
return m