Aegisub特效随记:Autotags 和 colorTag
本文发布于 438 天前。

关于lua中的and语句,请参考Aegisub特效随机:Lua中的And和Or

AutoTags 原始函数代码

function AutoTags(Intervalo,Dato1,Dato2) --Intervalo为时间间隔,Dato1/2为变化的内容
    local RESULTADO=""  --初始化 RESULTADO为输出结果
    local SUERTE = 0 --初始化局部输出存储器
    local CONTADOR = 0 --初始化计数器
    local ARREGLO = 0 --初始化表,用于存储前后变换的两个标签
    local count = math.ceil(line.duration/Intervalo) --总的变换次数
    ARREGLO = {Dato1,Dato2} --把两个变换的状态写入ARREGLO表,方便奇偶调用
    for i = 1, count do --核心循环
        CONTADOR = i --重复计数器数值
        if Dato1 and Dato2 then --拒绝Data1和Data2为空时的无效变换?

            if  CONTADOR%2 ==0 then --从默认变成Data1,再变成Data2
                SUERTE = ARREGLO[1] --将标签写入临时的输出
            else
                SUERTE = ARREGLO[2]
            end

        end
        RESULTADO = RESULTADO .."\\t(" ..(i-1)*Intervalo.. "," ..i*Intervalo.. ",\\" ..SUERTE..")".."" --从0开始输出并叠加变换
    end
    return RESULTADO --返回最终结果
end

AutoTags 无换行代码

可以直接复制进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

函数使用说明

Comment: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,code once,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
Comment: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,template line,{!AutoTags(100,'fs50','fs20')!}
Comment: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,karaoke,test

如上,在使用函数时,传入值的Dato1和Dato2应当为字符串,固用' '框起来。
函数返回值无{},固应当在template行中写类似{AutoTags(Timeinterval,'fs50','fs20'}

因为是写在代码当中,所以如果要有多个变化同时发生,需要用\来写后续的特效标签。例如{AutoTags(Timeinterval,'fs50\\frz90','fs20\\frz0'}
[1]

变种[2]

AutoTags1 (with pause):停顿

可以让每个变换之间有时间间隔/停顿。

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

image.png

AutoTags2 (with Delay):延迟

可以让变换有不同的开始时间。可以配合$si等使用。

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

image.png

AutoTags3 (Different Intervals):不同的时间间隔过渡

AutoTags3(第一次变化用时,最终变化用时,”标签1″,”标签2″)
即,每个\t变换的时间,会从Interval1逐渐过渡到Interval2

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

image.png

自用流水灯效果函数:colorTag

在制作「派对浪客诸葛孔明」的OP特效时,遇到了需要彩色流水灯效果的需求。

因为AutoTags(好像)不支持多个状态循环的变化,于是重写了一个用于生成循环变色效果的代码。

colors = {"&H003202C7", "&H0015CCD7", "&H0092321E", "&H0004C026", "&H0096C121", 
    "&H009C8CCC", "&H00AB4EB8"
}
colorNum = 7 -- 总的颜色数,即colors表的元素数
function colorTag(sylNum, timeDuration, timeGap)
    currentStart = 0
    currentEnd = 0 + timeGap
    currentColorNum = sylNum % 7 + 1 -- 当前选定的颜色
    colorResult = "" -- 输出结果
    colorResult = colorResult .. "\\3c"..colors[currentColorNum] -- 添加初状态
    while timeDuration - currentEnd > -timeGap do
        currentColorNum = (currentColorNum + 1) % 7 + 1
        colorResult = colorResult .. "\\t(" .. tostring(currentStart) .. "," .. tostring(currentEnd) ..",\\3c" .. colors[currentColorNum] .. ")"
        currentStart = currentStart + timeGap
        currentEnd = currentEnd + timeGap
    end
    return colorResult
end
colorTag(5, 2000, 120)
>>> \3c&H009C8CCC\t(0,120,\3c&H003202C7)\t(120,240,\3c&H0092321E)\t(240,360,\3c&H0096C121)\t(360,480,\3c&H00AB4EB8)\t(480,600,\3c&H0015CCD7)\t(600,720,\3c&H0004C026)\t(720,840,\3c&H009C8CCC)\t(840,960,\3c&H003202C7)\t(960,1080,\3c&H0092321E)\t(1080,1200,\3c&H0096C121)\t(1200,1320,\3c&H00AB4EB8)\t(1320,1440,\3c&H0015CCD7)\t(1440,1560,\3c&H0004C026)\t(1560,1680,\3c&H009C8CCC)\t(1680,1800,\3c&H003202C7)\t(1800,1920,\3c&H0092321E)\t(1920,2040,\3c&H0096C121)

函数说明:sylNum为当前音节的序数,配合计数器使用,用于产生颜色错位。timeDuration为当前行的时间长度。timeGap为渐变间隔时间。

应用举例(syl)

Comment: 0,0:00:15.07,0:00:17.07,Default,计数器,0,0,0,code line,ci=0
Comment: 0,0:00:15.07,0:00:17.07,Default,计数器,0,0,0,code once,function countc() ci=ci+1 return ""end
Comment: 0,0:00:00.00,0:00:05.00,Default,colorTag,0,0,0,code once,colors = {       "&H003202C7", "&H0015CCD7", "&H0092321E", "&H0004C026", "&H0096C121", "&H009C8CCC", "&H00AB4EB8"   }   colorNum = 7   function colorTag(sylNum, timeDuration, timeGap)       currentStart = 0       currentEnd = 0 + timeGap       currentColorNum = sylNum % 7 + 1       colorResult = ""       colorResult = colorResult .. "\\3c"..colors[currentColorNum]       while timeDuration - currentEnd > -timeGap do           currentColorNum = (currentColorNum + 1) % 7 + 1           colorResult = colorResult .. "\\t(" .. tostring(currentStart) .. "," .. tostring(currentEnd) ..",\\3c" .. colors[currentColorNum] .. ")"           currentStart = currentStart + timeGap           currentEnd = currentEnd + timeGap       end       return colorResult   end
Comment: 0,0:00:05.00,0:00:05.00,Default,,0,0,0,template syl,!countc()!{\pos(x,y)\bord3\blur2!colorTag(ci, line.duration, 100)!}
Comment: 0,0:00:05.00,0:00:07.00,Default,,0,0,0,karaoke,{\k13}知{\k13}道{\k13}答{\k13}案{\k13}的{\k13}明{\k13}天{\k13}还{\k13}有{\k13}什{\k13}么{\k13}期{\k13}待{\k13}的{\k13}意{\k13}义

应用举例(line)

如果希望结果只有一行显示(而不是每个syl各一行),只要把修饰语改为template line,并调整(删除)定位标签。

Comment: 0,0:00:15.07,0:00:17.07,Default,计数器,0,0,0,code line,ci=0
Comment: 0,0:00:15.07,0:00:17.07,Default,计数器,0,0,0,code once,function countc() ci=ci+1 return ""end
Comment: 0,0:00:00.00,0:00:05.00,Default,colorTag,0,0,0,code once,colors = {       "&H003202C7", "&H0015CCD7", "&H0092321E", "&H0004C026", "&H0096C121", "&H009C8CCC", "&H00AB4EB8"   }   colorNum = 7   function colorTag(sylNum, timeDuration, timeGap)       currentStart = 0       currentEnd = 0 + timeGap       currentColorNum = sylNum % 7 + 1       colorResult = ""       colorResult = colorResult .. "\\3c"..colors[currentColorNum]       while timeDuration - currentEnd > -timeGap do           currentColorNum = (currentColorNum + 1) % 7 + 1           colorResult = colorResult .. "\\t(" .. tostring(currentStart) .. "," .. tostring(currentEnd) ..",\\3c" .. colors[currentColorNum] .. ")"           currentStart = currentStart + timeGap           currentEnd = currentEnd + timeGap       end       return colorResult   end
Comment: 0,0:00:05.00,0:00:05.00,Default,,0,0,0,template line,!countc()!{\bord3\blur2!colorTag(ci, line.duration, 1000)!}
Comment: 0,0:00:05.00,0:00:07.00,Default,,0,0,0,karaoke,{\k13}知{\k13}道{\k13}答{\k13}案{\k13}的{\k13}明{\k13}天{\k13}还{\k13}有{\k13}什{\k13}么{\k13}期{\k13}待{\k13}的{\k13}意{\k13}义
Dialogue: 0,0:00:05.00,0:00:07.00,Default,,0,0,0,fx,{\bord3\blur2\3c&H0015CCD7\t(0,1000,\3c&H0004C026)\t(1000,2000,\3c&H009C8CCC)}知{\bord3\blur2\3c&H0092321E\t(0,1000,\3c&H0096C121)\t(1000,2000,\3c&H00AB4EB8)}道{\bord3\blur2\3c&H0004C026\t(0,1000,\3c&H009C8CCC)\t(1000,2000,\3c&H003202C7)}答{\bord3\blur2\3c&H0096C121\t(0,1000,\3c&H00AB4EB8)\t(1000,2000,\3c&H0015CCD7)}案{\bord3\blur2\3c&H009C8CCC\t(0,1000,\3c&H003202C7)\t(1000,2000,\3c&H0092321E)}的{\bord3\blur2\3c&H00AB4EB8\t(0,1000,\3c&H0015CCD7)\t(1000,2000,\3c&H0004C026)}明{\bord3\blur2\3c&H003202C7\t(0,1000,\3c&H0092321E)\t(1000,2000,\3c&H0096C121)}天{\bord3\blur2\3c&H0015CCD7\t(0,1000,\3c&H0004C026)\t(1000,2000,\3c&H009C8CCC)}还{\bord3\blur2\3c&H0092321E\t(0,1000,\3c&H0096C121)\t(1000,2000,\3c&H00AB4EB8)}有{\bord3\blur2\3c&H0004C026\t(0,1000,\3c&H009C8CCC)\t(1000,2000,\3c&H003202C7)}什{\bord3\blur2\3c&H0096C121\t(0,1000,\3c&H00AB4EB8)\t(1000,2000,\3c&H0015CCD7)}么{\bord3\blur2\3c&H009C8CCC\t(0,1000,\3c&H003202C7)\t(1000,2000,\3c&H0092321E)}期{\bord3\blur2\3c&H00AB4EB8\t(0,1000,\3c&H0015CCD7)\t(1000,2000,\3c&H0004C026)}待{\bord3\blur2\3c&H003202C7\t(0,1000,\3c&H0092321E)\t(1000,2000,\3c&H0096C121)}的{\bord3\blur2\3c&H0015CCD7\t(0,1000,\3c&H0004C026)\t(1000,2000,\3c&H009C8CCC)}意{\bord3\blur2\3c&H0092321E\t(0,1000,\3c&H0096C121)\t(1000,2000,\3c&H00AB4EB8)}义

参考

  1. ^https://bilibili.com/BV1c441197e9
  2. ^http://www.tcax.org/forum.php?mod=viewthread&tid=1230
标题:Aegisub特效随记:Autotags 和 colorTag
作者:IKK
除转载和特殊声明外,所有文章采用 CC BY-NC-SA 4.0协议
暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇