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

 找回密码
 新人加入
查看: 4821|回复: 0

Dragon Ball Op [复制链接]

Rank: 4

发表于 2015-9-12 23:17:14 |显示全部楼层
本帖最后由 ALKOON 于 2015-9-12 23:31 编辑

Hi everyone I just made effect for - Dragon Ball OP- Recently
so I just want to share just a part of my script (Fx_03)=D

link of video : http://www.dailymotion.com/video/x34wgnn_alkoon-dragon-ball-super-op_music

script :
  1. include("karaskel.lua")

  2. script_name = "Dragon Ball "
  3. script_description = "Dragon Ball OP FX_03"
  4. script_version = "1.2"
  5. script_author = "ALKOON"

  6. function Fx_Dragon(subs)
  7.         aegisub.progress.set(0)
  8.     aegisub.set_undo_point(script_name)
  9.         aegisub.progress.task("Getting header data..")
  10.         local meta, styles = karaskel.collect_head(subs)
  11.         aegisub.progress.task("Applying Script")
  12.         local i, ai, maxi, maxai = 1, 1, #subs, #subs
  13.         while i <= maxi do
  14.                 aegisub.progress.task(string.format("Applying effect... (%d/%d)...", ai, maxai))
  15.                 aegisub.progress.set((ai-1)/maxai*100)
  16.                 local l = subs[i]
  17.                 if l.class == "dialogue" and not l.comment  then
  18.                         karaskel.preproc_line(subs, meta, styles, l)
  19.                         do_fx(subs, meta, l)
  20.                         l.comment = true
  21.                         subs[i] = l
  22.                 else
  23.                 i = i + 1
  24.                 end
  25.                 ai = ai + 1

  26.         end
  27.                 aegisub.progress.set(100)
  28.         aegisub.set_undo_point(script_name)
  29. end


  30.     function frames(starts, ends, frame_time)
  31.         if type(starts) ~= "number" or type(ends) ~= "number" or type(frame_time) ~= "number" or frame_time <= 0 then
  32.                 error("number, number and number expected", 2)
  33.         end

  34.         local cur_start_time, i, n = starts, 0, math.ceil((ends - starts) / frame_time)
  35.         local function next_frame()
  36.                 if cur_start_time >= ends then
  37.                         return nil
  38.                 end
  39.                 local return_start_time = cur_start_time
  40.                 local return_end_time = return_start_time + frame_time <= ends and return_start_time + frame_time or ends
  41.                 cur_start_time = return_end_time
  42.                 i = i + 1
  43.                 return return_start_time, return_end_time, i, n
  44.         end
  45.         return next_frame
  46.      end


  47. function do_fx(subs, meta, line)


  48.                  local shape = "{\\p2}m 0 0 l 49 49 l 99 0 l 50 50 l 99 100 l 49 51 l -1 100 l 48 50 l 0 0  "
  49.                  local shape2 = "{\\p2}m 0 0 b 3 -2 7 -2 10 0 b 13 3 13 8 10 10 b 7 13 3 13 0 10 b -3 7 -3 3 0 0   "
  50.                 local px1 =line.left
  51.                 local px2 =line.right

  52.                   local y1, y2 = line.top, line.bottom
  53.                   local x1, x2 = px1, px2

  54.                                     loops = line.width
  55.                   local crclx = 360/loops
  56.                   local radx = (x2-x1) /2
  57.                   local rady = (y2-y1) /2

  58.                   for j=1, loops do

  59.                              local l=table.copy(line)
  60.                              local csx = math.cos((crclx*j)*(math.pi/350))*radx
  61.                              local sny = math.sin((crclx*j)*(math.pi*2/350))*rady
  62.                              local posx, posy  = line.center +csx, line.middle+sny +6
  63.                              local rand =  math.random(-45,45)

  64.                                local xx  = math.cos(math.rad(j*10))*math.random(-10,25)
  65.                                local yy  = math.sin(math.rad(j*10))*math.random(-10,25)

  66.                                local alfa =string.format("alpha&H%02X&",20)
  67.                                local sizft = (j/loops)
  68.                                l.start_time=line.start_time - 100 - ((j/loops)-1)*400
  69.                                l.end_time=line.start_time - ((j/loops)-1)*400 + 300
  70.                                tt = l.end_time - l.start_time
  71.                                fs1 = 80
  72.                                fss = 30
  73.                                tfr = ((400)-1)*sizft

  74.                                local textfx = string.format("{\\an5\\shad0\\fad(0,150)\\bord0\\blur0\\1c&Hffffff&\\3c&HffffffB&\\fscx%d\\fscy%d}",fs1,fs1)
  75.                                l.text= string.format("{\\t(\\1c&HBCE0FE&)\\fr"..tfr.."\\t(\\fscx%d\\fscy%d\\blur6)\\move(%f.01,%f.01,%f.01,%f.01,%d,%d)}",
  76.                                 fss,fss,posx,posy,posx,posy-50, tt-600,tt+600) .. shape
  77.                                 l.text = textfx .. l.text
  78.                                 l.effect = "shape_star"
  79.                                 l.layer = 1
  80.                                  subs.append(l)

  81.                                 fs2 = 60
  82.                                 fs3 = math.random(10,30)

  83.                                local textfx = string.format("{\\an5\\shad0\\fad(0,150)\\bord1\\blur2\\3a&HCC&\\1c&HFFFDE9&\\3c&HD1C963&\\fscx%d\\fscy%d}",fs2,fs2)
  84.                                l.text= string.format("{\\t(\\1c&Hffffff&\\3c&Hffffff&)\\fr"..tfr.."\\t(\\fscx%d\\fscy%d)\\move(%f.01,%f.01,%f.01,%f.01,%d,%d)}",
  85.                 fss,fss,posx,posy-13,posx+xx,posy-13+yy, tt-600,tt+600) .. shape2
  86.                                 l.text = textfx .. l.text
  87.                                 l.effect = "shape_circle"
  88.                                 l.layer = 0
  89.                                subs.append(l)
  90.                   end


  91.         for i = 1, line.kara.n do
  92.         local syl = line.kara[i]
  93.         local x = syl.center + line.left
  94.         local y = line.middle
  95.         local l = table.copy(line)



  96.         pos_enter=0
  97.         text_length=string.len(syl.text_stripped)
  98.         modt=0


  99.         for char in unicode.chars(syl.text_stripped) do
  100.         char_t = aegisub.text_extents(line.styleref,char)

  101.                 local x = line.left + syl.left +char_t/2+pos_enter
  102.                 local y = line.middle


  103.                 local chars = table.copy(syl)
  104.                 chars.text = char

  105.                 start_t=line.start_time+syl.start_time+modt-20
  106.                 end_t=line.start_time+syl.end_time-(syl.duration/3.8)+modt

  107.         if chars.text == "" or chars.text == " " then l.text = "{}" else

  108.                 c1 = "\\1vc(&HECC885&,&HECC885&,&H916814&,&H916814&)"
  109.                 c2 = "\\1vc(&H805E10&,&H805E10&,&HF1E1B8&,&HF1E1B8&)"

  110.                 l.text = string.format("{\\move(%d,%d,%d,%d,0,400)\\fad(150,0)\\fscx30\\fscy30\\t(15,400,\\fscx100\\fscy100)\\an5\\bord1.5\\shad0\\be2"..c1.."}",
  111.                 640, y-syl.height*1.6, x, y).. chars.text
  112.                 l.start_time=line.start_time - 450 + syl.i*50
  113.                 l.end_time= start_t
  114.                                 l.layer = 2
  115.                 l.effect = "Infade_Fx"
  116.                 subs.append(l)

  117.             for start_t, end_t, i, n in frames(line.start_time + syl.start_time+modt-20, end_t, 21.72 ) do
  118.                         l.start_time = start_t
  119.                         l.end_time = end_t
  120.                         l.text = string.format("{\\an5"..c2.."\\be2\\bord1.5\\shad0\\t(\\fscx140\\fscy140)\\pos(%.3f,%.3f)}",x+math.random(-3,3), y+math.random(-3,3) ) .. chars.text
  121.                         l.layer=5
  122.             l.effect = "text_shake"
  123.                         subs.append(l)
  124.                         end

  125.             for start_t, end_t, i, n in frames(line.start_time + syl.start_time+modt-20, end_t, 21.72 ) do
  126.                         l.start_time = start_t
  127.                         l.end_time = end_t
  128.                         l.text = string.format("{\\an5"..c2.."\\fad(%d,%d)\\be1\\1a&HFF&\\bord2\\fscx110\\fscy110\\shad0\\t(\\fscx160\\fscy160)\\pos(%.3f,%.3f)}",
  129.                         math.random(20,40),math.random(30,60),x+math.random(-3,3), y+math.random(-3,3) ) .. chars.text
  130.                         l.layer=5
  131.             l.effect = "text_shake_bord"
  132.                         subs.append(l)
  133.                     end

  134.         end


  135.                 if syl.duration <= 75 then
  136.                         modt=modt+100/(text_length*2)
  137.                 elseif syl.duration <= 100 then
  138.                         modt=modt+250/(text_length*2)
  139.                 elseif syl.duration <= 250 then
  140.                         modt=modt+500/(text_length*2)
  141.                 elseif syl.duration <= 1100 then
  142.                         modt=modt+700/(text_length*2)
  143.                 elseif syl.duration < 2000  then
  144.                         modt=modt+800/(text_length*2)
  145.                 elseif syl.duration >= 3000 then
  146.                         modt=modt+1100/(text_length*2)
  147.                 else
  148.                         modt=modt+1200/(text_length*2)
  149.                 end


  150.                                 modt=modt+syl.duration/10
  151.                                 pos_enter=pos_enter+char_t

  152.                 end
  153.           end
  154. end

  155. aegisub.register_macro(script_name, script_description, Fx_Dragon)
复制代码
1

查看全部评分

您需要登录后才可以回帖 登录 | 新人加入

GitHub|TCAX 主页

GMT+8, 2024-3-29 21:30

Powered by Discuz! X2

© 2001-2011 Comsenz Inc.

回顶部
RealH