Skip to content

[crop] Add light curtain to make out selection in dark areas #63

New issue

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

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

Already on GitHub? # to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
12 changes: 7 additions & 5 deletions scripts/crop.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
local opts = {
mode = "hard", -- can be "hard" or "soft". If hard, apply a crop filter, if soft zoom + pan. Or a bonus "delogo" mode
draw_shade = true,
shade_opacity = "77",
shade_opacity = "44",
light_opacity = "CC",
draw_frame = false,
frame_border_width = 2,
frame_border_color = "EEEEEE",
Expand Down Expand Up @@ -111,14 +112,14 @@ function position_to_ensure_ratio(moving, fixed, ratio)
}
end

function draw_shade(ass, unshaded, window)
function draw_shade(ass, unshaded, window, color, opacity)
ass:new_event()
ass:pos(0, 0)
ass:append("{\\an7}")
ass:append("{\\bord0}")
ass:append("{\\shad0}")
ass:append("{\\c&H000000&}")
ass:append("{\\1a&H" .. opts.shade_opacity .. "}")
ass:append("{\\c&H" .. color .. "&}")
ass:append("{\\1a&H" .. opacity .. "}")
ass:append("{\\2a&HFF}")
ass:append("{\\3a&HFF}")
ass:append("{\\4a&HFF}")
Expand Down Expand Up @@ -231,7 +232,8 @@ function draw_crop_zone()
top_left = { x = 0, y = 0 },
bottom_right = { x = dim.w, y = dim.h },
}
draw_shade(ass, frame, window)
if opts.light_opacity:lower() ~= "ff" then draw_shade(ass, frame, window, "FFFFFF", opts.light_opacity) end
if opts.light_opacity:lower() ~= "ff" then draw_shade(ass, frame, window, "000000", opts.shade_opacity) end
Copy link
Owner

@occivink occivink Sep 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the condition should be on shade_opacity. Maybe make that an early return in draw_shade() instead

end
if opts.draw_frame then
draw_frame(ass, frame)
Expand Down