TCAX 字幕特效制作工具官方论坛 | ASS | TCAS | Python | Aegisub | Lua

 找回密码
 新人加入
查看: 2789|回复: 0
打印 上一主题 下一主题

【AutoTags相关】Kara Effector 函数:tag.glitter [复制链接]

Rank: 4

跳转到指定楼层
楼主
发表于 2021-6-21 08:10:23 |只看该作者 |倒序浏览
本帖最后由 Seekladoom 于 2021-6-27 08:49 编辑

看如下内容前请先看此贴:
常用自定义函数AutoTags及其变种的介绍
http://tcax.org/forum.php?mod=viewthread&tid=1230

此函数和AutoTags有相似之处,都能做闪烁字幕效果,不同点在于AutoTags可以按时间变化增加t标签的数量做均匀地来回闪烁,而tag.glitter最多只生成四个t标签,具体代码如下:
  1. function tag.glitter( DurTotal, ExtraTags_i, ExtraTags_f )
  2.                 local time_ini, t, t1, t2, t3, t4, Tag_fx = 0, 0, 0, 0, 0, 0, "\\shad0"
  3.                 local GT_i, GT_f
  4.                 local time_fin = DurTotal or fx.dur
  5.                 if type( DurTotal ) == "table" then
  6.                         time_ini = DurTotal[ 1 ] or 0
  7.                         time_fin = DurTotal[ 2 ] or fx.dur
  8.                 elseif type( DurTotal ) == "function" then
  9.                         time_ini = DurTotal( )[ 1 ] or 0
  10.                         time_fin = DurTotal( )[ 2 ] or fx.dur
  11.                 end
  12.                 effector.print_error( time_ini, "numbertable", "tag.glitter", 1 )
  13.                 effector.print_error( time_fin, "numbertable", "tag.glitter", 1 )
  14.                 ----------------------------------------------------------------------
  15.                 if retime_mode then
  16.                         time_ini, time_fin = retimettag( retime_mode, time_ini, time_fin )
  17.                 end --september 09th 2017
  18.                 ----------------------------------------------------------------------
  19.                 local time_tot = time_fin - time_ini
  20.                 i = 0
  21.                 while time_tot > t do
  22.                         t1 = t + Rrd( 1, time_tot / 2, 1, 2 * i )
  23.                         t2 = t1 + 1
  24.                         t3 = t2 + frame_dur
  25.                         t4 = t3 + 2.5 * frame_dur
  26.                         size1 = Rrd( 1.5 * fx.sizex, 2.5 * fx.sizex, 1, i )
  27.                         size2 = Rrd( 0.5 * fx.sizex, 1.5 * fx.sizex, 1, -pi * i )
  28.                         GT_i = ExtraTags_i or ""
  29.                         if type( ExtraTags_i ) == "function" then
  30.                                 GT_i = ExtraTags_i( i )
  31.                         end
  32.                         GT_f = ExtraTags_f or ""
  33.                         if type( ExtraTags_f ) == "function" then
  34.                                 GT_f = ExtraTags_f( i )
  35.                         end
  36.                         ---------------------
  37.                         if t4 > time_tot then
  38.                                 t4 = time_tot
  39.                         end
  40.                         -- march 12th 2018 --
  41.                         Tag_fx = Tag_fx .. format( "\\t(%d,%d,%s\\fscx%d\\fscy%d)\\t(%d,%d,%s\\fscx%d\\fscy%d)",
  42.                                 time_ini + t1, time_ini + t2, GT_i, size1, size1,
  43.                                 time_ini + t3, time_ini + t4, GT_f, size2, size2
  44.                         )
  45.                         t = t4
  46.                         i = i + 1
  47.                 end
  48.                 Tag_fx = string.i( Tag_fx )
  49.                 return Tag_fx
  50.         end
复制代码
由于是在Lua文件里面写的,所以tag.glitter加了很多类型判断,而AutoTags的部分逻辑已经由Aegisub自带的Kara-templater.lua实现了,因此省略了很多。

另外AutoTags用于确定t标签的相关循环代码为for循环,而tag.glitter这里是while循环,如果要把tag.glitter改写到AutoTags的话就需要把while代码贴过去并进行相应修改。
您需要登录后才可以回帖 登录 | 新人加入

GitHub|TCAX 主页

GMT+8, 2024-4-26 16:11

Powered by Discuz! X2

© 2001-2011 Comsenz Inc.

回顶部
RealH