Skip to content

Commit c6810ac

Browse files
Sneakpeakcssdexeonify
authored andcommitted
crop: Add light curtain to make out selection in dark areas
Previously, it was impossible to see the crop selection over dark backgrounds. Remedy it by adding another bright shade. The default `shade_opacity` has been updated to keep a similar brightness before the change. Also fixes the `opts.shade_opacity` condition as reviewed by the script author. Ref: Sneakpeakcss/mpv-scripts@b617d20 occivink/mpv-scripts#63
1 parent 375af23 commit c6810ac

2 files changed

Lines changed: 13 additions & 6 deletions

File tree

script-opts/crop.conf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ draw_frame=yes
1313
frame_border_width=1
1414
frame_border_color=EEEEEE
1515
# hexadecimal: 00 is opaque, FF is transparent
16-
shade_opacity=77
16+
shade_opacity=44
17+
light_opacity=CC
1718
mouse_support=yes
1819
disable_window_dragging=yes
1920

scripts/crop.lua

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
local opts = {
22
mode = "hard", -- can be "hard" or "soft". If hard, use video-crop, if soft use zoom + pan. Or a bonus "delogo" mode
33
draw_shade = true,
4-
shade_opacity = "77",
4+
shade_opacity = "44",
5+
light_opacity = "CC",
56
draw_frame = false,
67
frame_border_width = 2,
78
frame_border_color = "EEEEEE",
@@ -119,14 +120,14 @@ function video_norm_to_screen(point, dim)
119120
}
120121
end
121122

122-
function draw_shade(ass, unshaded, window)
123+
function draw_shade(ass, unshaded, window, color, opacity)
123124
ass:new_event()
124125
ass:pos(0, 0)
125126
ass:append("{\\an7}")
126127
ass:append("{\\bord0}")
127128
ass:append("{\\shad0}")
128-
ass:append("{\\c&H000000&}")
129-
ass:append("{\\1a&H" .. opts.shade_opacity .. "}")
129+
ass:append("{\\c&H" .. color .. "&}")
130+
ass:append("{\\1a&H" .. opacity .. "}")
130131
ass:append("{\\2a&HFF}")
131132
ass:append("{\\3a&HFF}")
132133
ass:append("{\\4a&HFF}")
@@ -232,7 +233,12 @@ function draw_crop_zone()
232233
top_left = { x = 0, y = 0 },
233234
bottom_right = { x = dim.w, y = dim.h },
234235
}
235-
draw_shade(ass, frame, window)
236+
if opts.light_opacity:lower() ~= "ff" then
237+
draw_shade(ass, frame, window, "FFFFFF", opts.light_opacity)
238+
end
239+
if opts.shade_opacity:lower() ~= "ff" then
240+
draw_shade(ass, frame, window, "000000", opts.shade_opacity)
241+
end
236242
end
237243
if opts.draw_frame then
238244
draw_frame(ass, frame)

0 commit comments

Comments
 (0)