forked from unanimated/luaegisub
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathblur_cycle.lua
47 lines (41 loc) · 1.36 KB
/
blur_cycle.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
-- Adds blur 0.6, then cycles through 0.8, 1, 1.2, 1.5, 2, 3, 4, 5, 0.4, 0.5, back to 0.6. Feel free to modify the sequence below.
script_name="Blur Cycle"
script_description="Adds blur"
script_author="unanimated"
script_version="1.61"
sequence={"0.6","0.8","1","1.2","1.5","2","3","4","5","6","8","0.4","0.5"} -- you can modify this
function blur(subs,sel,act)
for z, i in ipairs(sel) do
line=subs[i]
text=line.text
tf=""
if text:match("^{\\[^}]-}") then
tags,after=text:match("^({\\[^}]-})(.*)")
if tags:match("\\t") then
for t in tags:gmatch("(\\t%([^%(%)]-%))") do tf=tf..t end
for t in tags:gmatch("(\\t%([^%(%)]-%([^%)]-%)[^%)]-%))","") do tf=tf..t end
tags=tags:gsub("\\t%([^%(%)]+%)","")
:gsub("\\t%([^%(%)]-%([^%)]-%)[^%)]-%)","")
:gsub("{}","")
text=tags..after
end
end
bl=text:match("^{[^}]-\\blur([%d%.]+)")
if bl~=nil then
for b=1,#sequence do
if bl==sequence[b] then bl2=sequence[b+1] end
end
if bl2==nil then bl2="0.6" end
text=text:gsub("^({[^}]-\\blur)[%d%.]+","%1"..bl2)
else
text="{\\blur0.6}" .. text
text=text:gsub("{\\blur0%.6}{\\","{\\blur0.6\\")
end
text=text:gsub("^({\\[^}]-)}","%1"..tf.."}")
line.text=text
subs[i]=line
end
aegisub.set_undo_point(script_name)
return sel
end
aegisub.register_macro(script_name, script_description, blur)