当前位置: 首页 > 工具软件 > Effector > 使用案例 >

【AutoTags相关】Kara Effector 函数:tag.glitter

谭灿
2023-12-01

看如下内容前请先看此贴:
【Aegisub相关】常用自定义函数AutoTags及其变种的介绍

此函数和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代码贴过去并进行相应修改。

 类似资料: