AutoTags函数用于在持续时间段内循环两个(组)特效标签,如blur数值来回变化,造成闪烁效果。在很多脚本中都很常见。想要使用这个函数,首先需要先在code行声明该函数。
Aegisub里面的模样
function AutoTags(Intervalo,Dato1,Dato2) local RESULTADO="" local SUERTE = 0 local CONTADOR = 0 local ARREGLO = 0 local count = math.ceil(line.duration/Intervalo) ARREGLO = {Dato1,Dato2} for i = 1, count do CONTADOR = i if Dato1 and Dato2 then if CONTADOR%2 ==0 then SUERTE = ARREGLO[1] else SUERTE = ARREGLO[2] end end RESULTADO = RESULTADO .."\\t(" ..(i-1)*Intervalo.. "," ..i*Intervalo.. ",\\" ..SUERTE..")".."" end return RESULTADO end
为了方便理解代码把换行写法贴上,Aegisub实际使用请复制上面没换行的代码,后续部分同理:
function AutoTags(Intervalo,Dato1,Dato2)
local RESULTADO=""
local SUERTE = 0
local CONTADOR = 0
local ARREGLO = 0
local count = math.ceil(line.duration/Intervalo) ARREGLO = {Dato1,Dato2}
for i = 1, count do
CONTADOR = i
if Dato1 and Dato2 then
if CONTADOR%2 ==0 then
SUERTE = ARREGLO[1]
else
SUERTE = ARREGLO[2]
end
end
RESULTADO = RESULTADO .."\\t(" ..(i-1)*Intervalo.. "," ..i*Intervalo.. ",\\" ..SUERTE..")"..""
end
return RESULTADO
end
再在template中调用
原始形式的AutoTags函数用法:
AutoTags(变化用时,“标签1”,“标签2”)(图2)
生成的效果如图3
可观察到,在整个字的持续时间内,生成了blur2->blur0->blur2的往复变化
如果要使用两组标签间的往复变化,注意应额外使用一个\,如AutoTags(500,“blur2\fs50”,“blur0\fs30”).
原始形式的AutoTags介绍到这里。
下面介绍几种由不同需求产生的变种AutoTags]
变种1
function AutoTags1(Intervalo,Dato1,Dato2,Pause) local RESULTADO="" local SUERTE = 0 local CONTADOR = 0 local ARREGLO = 0 local count = math.ceil(line.duration/(Intervalo+Pause)) ARREGLO = {Dato1,Dato2} for i = 1, count do CONTADOR = i if Dato1 and Dato2 then if CONTADOR%2 ==0 then SUERTE = ARREGLO[1] else SUERTE = ARREGLO[2] end end RESULTADO = RESULTADO .."\\t(" ..(i-1)*(Intervalo+Pause).. "," ..i*Intervalo+Pause*(i-1).. ",\\" ..SUERTE..")".."" end return RESULTADO end
换行写法:
function AutoTags1(Intervalo,Dato1,Dato2,Pause)
local RESULTADO=""
local SUERTE = 0
local CONTADOR = 0
local ARREGLO = 0
local count = math.ceil(line.duration/(Intervalo+Pause))
ARREGLO = {Dato1,Dato2}
for i = 1, count do
CONTADOR = i
if Dato1 and Dato2 then
if CONTADOR%2 ==0 then
SUERTE = ARREGLO[1]
else
SUERTE = ARREGLO[2]
end
end
RESULTADO = RESULTADO .."\\t(" ..(i-1)*(Intervalo+Pause).. "," ..i*Intervalo+Pause*(i-1).. ",\\" ..SUERTE..")"..""
end
return RESULTADO
end
用于实现带有暂停时间的往复变化效果
多出的第四个参数Pause为暂停时间(ms)
AutoTags1(变化用时,“标签1”,“标签2”,暂停时间)
变种2
function AutoTags2(Intervalo,Dato1,Dato2,Delay) local RESULTADO="" local SUERTE = 0 local CONTADOR = 0 local ARREGLO = Layer local count = math.ceil(line.duration/Intervalo) ARREGLO = {Dato1,Dato2} for i = 1, count do CONTADOR = i if Dato1 and Dato2 then if CONTADOR%2 ==0 then SUERTE = ARREGLO[1] else SUERTE = ARREGLO[2] end end RESULTADO = RESULTADO .."\\t(" ..(i-1)*Intervalo+Delay.. "," ..i*Intervalo+Delay.. ",\\" ..SUERTE.. ")".."" end return RESULTADO end
换行写法:
function AutoTags2(Intervalo,Dato1,Dato2,Delay)
local RESULTADO=""
local SUERTE = 0
local CONTADOR = 0
local ARREGLO = Layer
local count = math.ceil(line.duration/Intervalo) ARREGLO = {Dato1,Dato2}
for i = 1, count do
CONTADOR = i
if Dato1 and Dato2 then
if CONTADOR%2 ==0 then SUERTE = ARREGLO[1]
else SUERTE = ARREGLO[2]
end
end
RESULTADO = RESULTADO .."\\t(" ..(i-1)*Intervalo+Delay.. "," ..i*Intervalo+Delay.. ",\\" ..SUERTE.. ")"..""
end
return RESULTADO
end
用于实现带有延迟(相对于行开始时间延后)的往复变化效果
例如,需要从行开始1s后才需要变化效果:
AutoTags2(500,“标签1”,“标签2”,1000)
变种3
function AutoTags3(Intervalo1,Intervalo2,Dato1,Dato2) local RESULTADO="" local SUERTE = 0 local CONTADOR = 0 local ARREGLO = 0 local count = 2*math.ceil(line.duration/(Intervalo1+Intervalo2)) local d=math.ceil((Intervalo2-Intervalo1)/count) local t={} ARREGLO = {Dato1,Dato2} for i = 1, count do CONTADOR = i t[1]=0 t[i+1]=t[i]+Intervalo1+(i-1)*d if Dato1 and Dato2 then if CONTADOR%2 ==0 then SUERTE = ARREGLO[1] else SUERTE = ARREGLO[2] end end RESULTADO = RESULTADO .."\\t(" ..t[i].. "," ..t[i+1].. ",\\" ..SUERTE..")".."" end return RESULTADO end
换行写法:
function AutoTags3(Intervalo1,Intervalo2,Dato1,Dato2)
local RESULTADO=""
local SUERTE = 0
local CONTADOR = 0
local ARREGLO = 0
local count = 2*math.ceil(line.duration/(Intervalo1+Intervalo2)) local d=math.ceil((Intervalo2-Intervalo1)/count)
local t={}
ARREGLO = {Dato1,Dato2}
for i = 1, count do
CONTADOR = i
t[1]=0
t[i+1]=t[i]+Intervalo1+(i-1)*d
if Dato1 and Dato2 then
if CONTADOR%2 ==0 then SUERTE = ARREGLO[1]
else SUERTE = ARREGLO[2] end
end
RESULTADO = RESULTADO .."\\t(" ..t[i].. "," ..t[i+1].. ",\\" ..SUERTE..")"..""
end
return RESULTADO
end
等差数列型AutoTags(变化用时递增或递减)
递减效果类似炸弹定时器,越来越急促
递增效果则表示变化速度越来越缓慢
AutoTags3(第一次变化用时,最终变化用时,“标签1”,“标签2”)
第一次变化用时>最终变化用时,为递减
最终变化用时>第一次变化用时,为递增
ASS文件放在附件了
AutoTags.zip
github备份:
AutoTags.rar
暂时就想到这么几种,等比数列,两组时间交替变化也是不错的思路,欢迎大家补充
新年第一帖,祝大家新春快乐