TCAX 字幕特效制作工具官方论坛 | ASS | TCAS | Python | Aegisub | Lua
标题:
【AutoTags相关】Kara Effector 函数:tag.glitter
[打印本页]
作者:
Seekladoom
时间:
2021-6-21 08:10:23
标题:
【AutoTags相关】Kara Effector 函数:tag.glitter
本帖最后由 Seekladoom 于 2021-6-27 08:49 编辑
看如下内容前请先看此贴:
常用自定义函数AutoTags及其变种的介绍
http://tcax.org/forum.php?mod=viewthread&tid=1230
此函数和AutoTags有相似之处,都能做闪烁字幕效果,不同点在于AutoTags可以按时间变化增加t标签的数量做均匀地来回闪烁,而tag.glitter最多只生成四个t标签,具体代码如下:
function tag.glitter( DurTotal, ExtraTags_i, ExtraTags_f )
local time_ini, t, t1, t2, t3, t4, Tag_fx = 0, 0, 0, 0, 0, 0, "\\shad0"
local GT_i, GT_f
local time_fin = DurTotal or fx.dur
if type( DurTotal ) == "table" then
time_ini = DurTotal[ 1 ] or 0
time_fin = DurTotal[ 2 ] or fx.dur
elseif type( DurTotal ) == "function" then
time_ini = DurTotal( )[ 1 ] or 0
time_fin = DurTotal( )[ 2 ] or fx.dur
end
effector.print_error( time_ini, "numbertable", "tag.glitter", 1 )
effector.print_error( time_fin, "numbertable", "tag.glitter", 1 )
----------------------------------------------------------------------
if retime_mode then
time_ini, time_fin = retimettag( retime_mode, time_ini, time_fin )
end --september 09th 2017
----------------------------------------------------------------------
local time_tot = time_fin - time_ini
i = 0
while time_tot > t do
t1 = t + Rrd( 1, time_tot / 2, 1, 2 * i )
t2 = t1 + 1
t3 = t2 + frame_dur
t4 = t3 + 2.5 * frame_dur
size1 = Rrd( 1.5 * fx.sizex, 2.5 * fx.sizex, 1, i )
size2 = Rrd( 0.5 * fx.sizex, 1.5 * fx.sizex, 1, -pi * i )
GT_i = ExtraTags_i or ""
if type( ExtraTags_i ) == "function" then
GT_i = ExtraTags_i( i )
end
GT_f = ExtraTags_f or ""
if type( ExtraTags_f ) == "function" then
GT_f = ExtraTags_f( i )
end
---------------------
if t4 > time_tot then
t4 = time_tot
end
-- march 12th 2018 --
Tag_fx = Tag_fx .. format( "\\t(%d,%d,%s\\fscx%d\\fscy%d)\\t(%d,%d,%s\\fscx%d\\fscy%d)",
time_ini + t1, time_ini + t2, GT_i, size1, size1,
time_ini + t3, time_ini + t4, GT_f, size2, size2
)
t = t4
i = i + 1
end
Tag_fx = string.i( Tag_fx )
return Tag_fx
end
复制代码
由于是在Lua文件里面写的,所以tag.glitter加了很多类型判断,而AutoTags的部分逻辑已经由Aegisub自带的Kara-templater.lua实现了,因此省略了很多。
另外AutoTags用于确定t标签的相关循环代码为for循环,而tag.glitter这里是while循环,如果要把tag.glitter改写到AutoTags的话就需要把while代码贴过去并进行相应修改。
欢迎光临 TCAX 字幕特效制作工具官方论坛 | ASS | TCAS | Python | Aegisub | Lua (http://tcax.org/)
Powered by Discuz! X2