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”)
第一次变化用时>最终变化用时,为递减
最终变化用时>第一次变化用时,为递增
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/44657.html