正则替换
选出每句话
正则表达式: ctrl+h 调出搜索替换的框框,勾选使用正则表达式,搜索内容写入^ 替换内容写入你要添加的内容,注意\要转意,比如你要添加 {\blur1} 就要写入 {\\blur1}
选出每个字
(?=.)
Karaoke Template
简单记录一些 Karaoke Template 的编写语法。
格式
文本行特效写打 Karaoke(可多行),代码行改注释,特效中加指定类型。选中所有行,运行脚本。
Template 行特效类型
template pre-line
直接在句子前面加上代码。
template line
对整句(line)进行代码操作。
将文本中的 {\k__} 替代为 template line 中的内容(文字或代码),例如:
Comment: 0,0:00:00.00,0:00:00.00,CN_UP,,0,0,0,template line, 测试 Comment: 0,0:00:00.00,0:00:05.00,CN_UP,,0,0,0,karaoke,{\k1}a{\k1}b{\k1}c{\k1}d Dialogue: 0,0:00:00.00,0:00:05.00,CN_UP,,0,0,0,fx, 测试 a 测试 b 测试 c 测试 d
template syl
对音节(syllable),即每个被 {\k__} 划分的字符,进行代码操作,并将字符以单行的形式显示。
需要注意的是,在第一个 {\k__} 前,会默认存在一个字符(即使是空)。
Comment: 0,0:00:00.00,0:00:00.00,CN_UP,,0,0,0,template syl, 测试 Comment: 0,0:00:00.00,0:00:05.00,CN_UP,,0,0,0,karaoke,{\k1}a{\k1}b{\k1}c{\k1}d Dialogue: 0,0:00:00.00,0:00:05.00,CN_UP,,0,0,0,fx, 测试 Dialogue: 0,0:00:00.00,0:00:05.00,CN_UP,,0,0,0,fx, 测试 a Dialogue: 0,0:00:00.00,0:00:05.00,CN_UP,,0,0,0,fx, 测试 b Dialogue: 0,0:00:00.00,0:00:05.00,CN_UP,,0,0,0,fx, 测试 c Dialogue: 0,0:00:00.00,0:00:05.00,CN_UP,,0,0,0,fx, 测试 d
template syl char
对每个字符(character)进行操作。syl 可写可不写,因为 tempate 默认是对音节进行操作的。
Comment: 0,0:00:00.00,0:00:00.00,CN_UP,,0,0,0,template syl char,{\pos($sx,$sy)} Comment: 0,0:00:00.00,0:00:05.00,CN_UP,,0,0,0,karaoke,{\k100}one{\k100}two Dialogue: 0,0:00:00.00,0:00:05.00,CN_UP,,0,0,0,fx,{\pos(588,360)}o Dialogue: 0,0:00:00.00,0:00:05.00,CN_UP,,0,0,0,fx,{\pos(609,360)}n Dialogue: 0,0:00:00.00,0:00:05.00,CN_UP,,0,0,0,fx,{\pos(631,360)}e Dialogue: 0,0:00:00.00,0:00:05.00,CN_UP,,0,0,0,fx,{\pos(648,360)}t Dialogue: 0,0:00:00.00,0:00:05.00,CN_UP,,0,0,0,fx,{\pos(667,360)}w Dialogue: 0,0:00:00.00,0:00:05.00,CN_UP,,0,0,0,fx,{\pos(692,360)}o
可以看到,以上代码把单个字符进行了分行,并指定到了对应的绝对位置。
template syl noblank
使生成代码时删去空行。
template syl notext
使生成代码时,所有文字被删除,但时间依然保留。
template syl noblank
使生成代码时删去空行。
template syl noblank notext
使生成代码时,只剩下有文字的,且被替换成了空行。
template syl keeptags
正常执行 template 时,形如 {\an} 的标签会被自动删除。为了保留标签,可以打上 keeptags。
template syl loop 5
正常执行 template 时,代码只会被执行一次。为了多次执行,可以打上 loop+数字。
相关的内联变量:!j!
例如
Comment: 0,0:00:00.00,0:00:00.00,CN_UP,,0,0,0,template line loop 5,!j! | !maxj! | !j*100! Comment: 0,0:00:00.00,0:00:05.00,CN_UP,,0,0,0,karaoke,{\k100}one{\k100}two{\k100}{\fs50}three{\k100}four Dialogue: 0,0:00:00.00,0:00:05.00,CN_UP,,0,0,0,fx,1 | 5 | 100 one1 | 5 | 100 two1 | 5 | 100 three1 | 5 | 100 four Dialogue: 0,0:00:00.00,0:00:05.00,CN_UP,,0,0,0,fx,2 | 5 | 200 one2 | 5 | 200 two2 | 5 | 200 three2 | 5 | 200 four Dialogue: 0,0:00:00.00,0:00:05.00,CN_UP,,0,0,0,fx,3 | 5 | 300 one3 | 5 | 300 two3 | 5 | 300 three3 | 5 | 300 four Dialogue: 0,0:00:00.00,0:00:05.00,CN_UP,,0,0,0,fx,4 | 5 | 400 one4 | 5 | 400 two4 | 5 | 400 three4 | 5 | 400 four Dialogue: 0,0:00:00.00,0:00:05.00,CN_UP,,0,0,0,fx,5 | 5 | 500 one5 | 5 | 500 two5 | 5 | 500 three5 | 5 | 500 four
此处 j 代表循环此处,min 和 max 都是 j 在运行中的最大和最小值。
template syl fx hk
正常执行 template 时,每一个音节都会被执行。为了只执行选定的音节,可以打上 fx+标记;并在音节前加入相同的标记 “-标记”。这时会对标记之后的音节执行操作。
Comment: 0,0:00:00.00,0:00:00.00,CN_UP,,0,0,0,template syl fx hk,aaa Comment: 0,0:00:00.00,0:00:05.00,CN_UP,,0,0,0,karaoke,{\k100}one{\k100}two{\k100\-hk}three{\k100}four Dialogue: 0,0:00:00.00,0:00:05.00,CN_UP,,0,0,0,fx,aaathree Dialogue: 0,0:00:00.00,0:00:05.00,CN_UP,,0,0,0,fx,aaafour
为了只执行选定范围的音节,可以在结束音节后添加一个无关标签表示结束。
Comment: 0,0:00:00.00,0:00:00.00,CN_UP,,0,0,0,template syl fx hk,aaa Comment: 0,0:00:00.00,0:00:05.00,CN_UP,,0,0,0,karaoke,{\k100}one{\k100\-hk}two{\k100}three{\k100\-mc}four Dialogue: 0,0:00:00.00,0:00:05.00,CN_UP,,0,0,0,fx,aaatwo Dialogue: 0,0:00:00.00,0:00:05.00,CN_UP,,0,0,0,fx,aaathree
实际上,每个音节的原始标记都是空的。与 fx 相关的内联函数为!syl.inline_fx!,用于获取指定音节的标签名
Comment: 0,0:00:00.00,0:00:00.00,CN_UP,,0,0,0,template syl,!syl.inline_fx! Comment: 0,0:00:00.00,0:00:05.00,CN_UP,,0,0,0,karaoke,{\k100}one{\k100\-hk}two{\k100}three{\k100\-mc}four Dialogue: 0,0:00:00.00,0:00:05.00,CN_UP,,0,0,0,fx, Dialogue: 0,0:00:00.00,0:00:05.00,CN_UP,,0,0,0,fx,one Dialogue: 0,0:00:00.00,0:00:05.00,CN_UP,,0,0,0,fx,hktwo Dialogue: 0,0:00:00.00,0:00:05.00,CN_UP,,0,0,0,fx,hkthree Dialogue: 0,0:00:00.00,0:00:05.00,CN_UP,,0,0,0,fx,mcfour
code syl
在 code 语句中可以加入 lua 语句。
用! !来表示代码块。
模板
clip – 由左至右消失
{\pos($sx, $sy)\clip($sleft, $stop, $sright, $sbottom)\t($sstart, !$sstart+$sdur!, 1, \clip($sright, $stop, $sright, $sbottom))}
iclip – 由左至右显现
{\pos($sx, $sy)\iclip($sleft, $stop, $sright, $sbottom)\t($sstart, !$sstart+$sdur!, 1, \iclip($sright, $stop, $sright, $sbottom))}
内联变量
自适应变量 Automatic variants
时间类 $start $end $mid
行或音节的开始时间、结束时间、中点时间,行是绝对时间,音节是相对行的时间(通用,自动进行判断)
以下代码可以实现单词逐一 fade 出现:
Comment: 0,0:00:00.00,0:00:00.00,CN_UP,,0,0,0,template line,{\alpha&HFF\t($start,$end,\alpha&H00)} Comment: 0,0:00:00.00,0:00:05.00,CN_UP,,0,0,0,karaoke,{\k100}one{\k100}two{\k100}three{\k100}four Dialogue: 0,0:00:00.00,0:00:05.00,CN_UP,,0,0,0,fx,{\alpha&HFF\t(0,1000,\alpha&H00)}one{\alpha&HFF\t(1000,2000,\alpha&H00)}two{\alpha&HFF\t(2000,3000,\alpha&H00)}three{\alpha&HFF\t(3000,4000,\alpha&H00)}fourr
位置类 $lleft $lright $ltop $lbottom
例如,表示一句话的完整 clip 范围
\clip($lleft,$ltop,$lright,$lbottom)
$sx $xy
以上代码可以同样用 template syl 与 $sx $sy 来实现。$sx 与 $sy 是音节在默认对齐方式下的绝对位置 (x,y),配合\pos 和\move 使用。
Comment: 0,0:00:00.00,0:00:00.00,CN_UP,,0,0,0,template syl,{\alpha&HFF\t($start,$end,\alpha&H00)\pos($sx,$sy)} Comment: 0,0:00:00.00,0:00:05.00,CN_UP,,0,0,0,karaoke,{\k100}one{\k100}two{\k100}three{\k100}four Dialogue: 0,0:00:00.00,0:00:05.00,CN_UP,,0,0,0,fx,{\alpha&HFF\t(0,0,\alpha&H00)\pos(452,23)} Dialogue: 0,0:00:00.00,0:00:05.00,CN_UP,,0,0,0,fx,{\alpha&HFF\t(0,1000,\alpha&H00)\pos(495,23)}one Dialogue: 0,0:00:00.00,0:00:05.00,CN_UP,,0,0,0,fx,{\alpha&HFF\t(1000,2000,\alpha&H00)\pos(579,23)}two Dialogue: 0,0:00:00.00,0:00:05.00,CN_UP,,0,0,0,fx,{\alpha&HFF\t(2000,3000,\alpha&H00)\pos(679,23)}three Dialogue: 0,0:00:00.00,0:00:05.00,CN_UP,,0,0,0,fx,{\alpha&HFF\t(3000,4000,\alpha&H00)\pos(783,23)}four
$lx $ly
对\pos 代码使用的 x,y 坐标(当对齐方式未被重写时)
$lcenter $lmiddle
句子/音节(s)默认中心位置
例如:获得单个字/音节逐个变大的 K 效果
\an5\pos($scenter,$smiddle)\1a&HFF&\t($start,$end,\bord13\3a&HFF&)[\php] <h3>Lua 语法</h3> 更多 Lua 语法相关请转到单独文章:<a href="https://ihkk.net/luaforaegisub/" target="_blank" rel="noopener noreferrer">Lua For Aegisub</a> <h4> 计算</h4> 用! 和! 来表示 lua 语句和运算。 例如: 行结束时间 行结束时间 $lend 又可以写作 !$lstart+$ldur!
数值运算
Comment: 0,0:00:00.00,0:00:00.00,CN_UP,,0,0,0,template syl,!100+99! Comment: 0,0:00:00.00,0:00:05.00,CN_UP,,0,0,0,karaoke, 文字 Dialogue: 0,0:00:00.00,0:00:05.00,CN_UP,,0,0,0,fx,199 Dialogue: 0,0:00:00.00,0:00:05.00,CN_UP,,0,0,0,fx,199 文字
文字
用 ” ” 来表示 string,用 .. 来连接字符串。
Comment: 0,0:00:00.00,0:00:00.00,CN_UP,,0,0,0,template syl,!"AB".."CD"! Comment: 0,0:00:00.00,0:00:05.00,CN_UP,,0,0,0,karaoke, 文字 Dialogue: 0,0:00:00.00,0:00:05.00,CN_UP,,0,0,0,fx,ABCD Dialogue: 0,0:00:00.00,0:00:05.00,CN_UP,,0,0,0,fx,ABCD 文字
生成随机数
!(math.random(10,80))! 表示生成一个 10~80 之间的随机数
颜色函数
_G.ass_color()
这是一个用来设定转换颜色的函数,ass 表示颜色的格式,_G.ass_color(42,220,187) 即表示 HBBDC2A 色
例如,生成随机颜色
{\1c!_G.ass_color(math.random(255),math.random(255),math.random(255))!}