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

 找回密码
 新人加入
查看: 5361|回复: 6

[完整特效] [lun]013_shinkurodokimeki_v2 [复制链接]

Moderator

疯子

Rank: 5Rank: 5

发表于 2012-9-16 17:36:54 |显示全部楼层
本帖最后由 渣渣疯子 于 2012-9-16 19:36 编辑
  1. from tcaxPy import *
  2. from draw2pix import *


  3. def tcaxPy_Init():
  4.     global _FontFileName          # frame duration, in millisecond
  5.     global _FD                  
  6.     global _Fs
  7.     global _Length
  8.     global _Bd
  9.     global _Br
  10.     global _FaceID
  11.     global _Font
  12.     global _Spacing
  13.     _FontFileName = GetVal(val_FontFileName)
  14.     _FD = 1000 / GetVal(val_FXFPS)
  15.     _Fs = GetVal(val_FontSize)
  16.     _Length = GetVal(val_TextLength)
  17.     _Bd = GetVal(val_Bord)
  18.     _Br = GetVal(val_Blur)
  19.     _FaceID = GetVal(val_FaceID)
  20.     _Spacing = GetVal(val_Spacing)
  21.     _Font = InitFont(_FontFileName, _FaceID, _Fs, GetVal(val_Spacing), GetVal(val_SpaceScale), 0xFFFFFF, 2, 0)
  22.     cairo_init(100, 100)

  23. def fr(x):

  24.     X = randint(-x,x)

  25.     return frx(X)+fry(X)+frz(X)

  26. def tcaxPy_Main(_i, _j, _n, _BT, _ET, _SK, _KT, _X, _Y, _A, _TXT):

  27.     ASS_BUF  = []        # used for saving ASS FX lines

  28. ###########butterfly##############
  29.     butterfly = ["m 21 15 b 20 13 18 10 16 8 b 14 6 11 4 9 3 b 8 2 6 1 4 1 b 3 1 3 1 0 0 b 3 3 3 3 3 4 b 4 5 5 6 5 7 b 6 8 7 10 8 11 b 8 12 9 12 9 13 b 9 14 10 15 10 16 b 11 16 11 17 12 17 b 13 17 13 17 14 17 b 13 18 13 18 12 19 b 12 19 11 20 11 20 b 12 21 13 20 13 20 b 12 21 12 22 12 23 b 12 23 13 23 13 23 b 13 24 12 25 12 26 b 13 26 13 25 14 25 b 13 26 14 29 8 38 b 13 28 14 29 15 27 b 15 28 15 28 15 29 b 16 28 16 26 17 26 b 17 26 18 26 17 27 b 19 24 20 20 22 18 b 22 17 22 17 22 16 m 23 16 b 24 15 25 13 26 12 b 27 10 29 9 30 7 b 32 6 34 4 36 3 b 37 2 39 2 40 1 b 41 1 41 1 46 -1 b 42 2 41 3 41 4 b 40 5 40 6 39 7 b 38 8 38 10 37 11 b 36 12 36 14 35 15 b 34 16 33 16 32 17 b 32 18 33 18 33 19 b 33 19 34 20 34 20 b 33 20 32 20 31 20 b 32 21 33 22 34 23 b 33 23 33 23 32 23 b 33 24 33 25 34 26 b 33 26 33 25 32 25 b 32 26 33 28 38 38 b 33 28 32 27 31 27 b 31 28 31 27 32 29 b 31 28 31 27 30 26 b 30 27 30 27 30 28 b 29 27 29 26 28 25 b 28 26 28 26 28 27 b 28 26 27 26 27 25 b 26 22 25 20 23 18 " , "m 22 13 b 22 14 21 14 21 15 b 19 10 15 7 12 4 b 9 2 5 0 3 0 b 0 0 -1 0 0 2 b 1 4 4 7 4 9 b 6 11 7 12 8 15 b 9 18 11 17 13 17 b 11 18 10 19 10 20 b 10 21 13 21 10 22 b 10 23 8 25 11 25 b 9 26 9 28 10 28 b 11 30 9 33 8 35 b 7 36 7 38 7 39 b 9 38 9 37 9 36 b 10 35 10 32 12 32 b 13 33 13 31 14 31 b 14 32 16 32 15 30 b 18 30 18 27 18 26 b 18 23 21 20 21 17 b 22 18 21 19 21 21 b 21 22 21 23 22 23 m 22 13 b 22 14 23 14 23 15 b 25 11 27 8 31 5 b 35 2 37 1 39 0 b 45 -1 44 1 43 3 b 41 5 40 8 38 10 b 37 12 37 13 36 15 b 36 17 33 17 31 17 b 33 18 33 18 34 19 b 36 22 34 21 34 22 b 36 24 35 24 34 24 b 35 26 36 28 34 28 b 34 31 36 34 37 35 b 38 36 38 38 37 38 b 36 38 35 36 35 35 b 35 34 34 32 33 32 b 32 32 31 33 31 31 b 30 32 29 31 29 30 b 27 30 27 28 26 25 b 26 23 23 20 23 17 b 22 18 23 20 23 21 b 23 23 22 23 22 23 "]
  30.     num = 150
  31.     xs = _X + randint(200,300)
  32.     ys = _Y + randint(-30,60)
  33.     xc1 = _X + randint(100,200)
  34.     yc1 = _Y + randint(-20,40)
  35.     xc2 = _X + randint(0,100)
  36.     yc2 = _Y + randint(-10,20)
  37.     xe = _X - int(_A / 2)
  38.     ye = _Y - int(_Fs / 2)
  39.     points = Bezier3(num, xs, ys, xe, ye, xc1, yc1, xc2, yc2)
  40.     COLOR = ["50FFD9","DEABF3","FFFF00","1300EF","39F53A","F443C3","1F43FA"]
  41.     C1 = COLOR[randint(0,6)]
  42.     PIC = butterfly[randint(0,1)]
  43.     RAN1 = randint(100,130)
  44.     for i in range(num):
  45.         POS = pos(points[i][0], points[i][1])
  46.         ts = _BT-num + (i * 1) + (_j * 10)
  47.         te = _BT-num + ((i+1) * 1) + (_j * 10)
  48.         ass_main(ASS_BUF, SubL(ts,te,2), an(5)+alpha1(150)+fsc(RAN1,RAN1)+bord(1)+color3(C1)+color1(C1)+blur(1.5)+frz(90)+frx(i * randint(1,3))+POS, "{\p3}" + PIC + "{\p0}")
  49.     ts1 = _BT + 1 + (_j * 10)
  50.     te1 = _BT+_SK+_KT
  51.     e = ts1
  52.     while e < te1 - 20:
  53.         ass_main(ASS_BUF, SubL(e,e+30,2), an(5)+pos(_X - int(_A / 2),_Y - int(_Fs / 2))+alpha1(150)+color1(C1)+fsc(RAN1,RAN1)+bord(1)+color3(C1)+blur(1.5)+frz(90)+frx(randint(0,90))+t(frx(randint(0,90))), "{\p3}" + PIC + "{\p0}")
  54.         e = e + 30
  55.     ass_main(ASS_BUF, SubL(_BT-30,_BT+_SK),an(5)+pos(_X,_Y)+color1("FFFFFF")+color3("FFFFFF")+bord(1),_TXT)
  56. ###########fire##################
  57.     fire_str = ('{\p5}m 0 0 b 8 1 9 -28 -2 -41 b 3 -23 -17 0 0 0{\p0}','{\p5}m 1 41 b 20 39 1 13 13 -11 b 5 1 -18 22 1 41{\p0}','{\p4}m 6 39 b 4 29 1 13 27 -37 b -1 -3 -15 34 6 39{\p0}','{\p5}m -3 43 b -9 22 -1 33 16 -47 b 1 3 -17 0 -3 43{\p0}')
  58.     COLOR2 = ("007EFF","3F7EF6","0060FF")
  59.     ts2 = _BT + _SK
  60.     count = int(te1 - ts2)
  61.     step = int(_FD / 10)
  62.     PIX = TextPix(_Font, _TXT)
  63.     points = PixPoints(PIX)
  64.     pt_num = len(points)
  65.     dx = _X - int(_A / 2 + 0.5) + PIX[0][0]
  66.     dy = _Y - int(_Fs / 2 + 0.5) + PIX[0][1]
  67.     for i in range(0, count, step):
  68.         for j in range (3):
  69.             C2 = COLOR2[randint(0,2)]
  70.             pt = points[randint(0, pt_num - 1)]
  71.             t0 = randint(int(ts2), int(te1))
  72.             t1 = t0 + 30
  73.             tmpz = randint(0, 359)
  74.             tmpstr = fire_str[randint(0, 3)]
  75.             x = dx + pt[0]
  76.             y = dy + pt[1]
  77.             ass_main(ASS_BUF, SubL(t0,t1, 10, Pix_Style), an(5)+move(x,y,x,y-25)+alpha1(100) + color1(C2) + alpha3(150) + color3(C2) +bord(3) + blur(3) + frz(tmpz) + t(fsc(120, 120) + bord(1) + fry(361) + frz(-57)) + fad(0, 200), tmpstr)
  78.     ass_main(ASS_BUF, SubL(ts2,te1), an(5)+pos(_X,_Y)+color1("0000FF")+color3("002FFF")+bord(2)+blur(2),_TXT)
  79. ############ash#################
  80.     dx1 = _X - int((_A + _Spacing) / 2 + 0.5)     # 一个固定操作, 将an5的坐标转换为an7
  81.     dy1 = _Y - int(_Fs / 2 + 0.5)                 # ASS特效默认采用an5坐标, TCAS特效则采用an7坐标
  82.     # _txt PIX
  83.     PIX = TextPix(_Font, _TXT)       # Get a PIX object from normal text, PIX can be considered as image
  84.     points = PixPoints(PIX)         # Get points from the PIX object.
  85.     pt_num = len(points)
  86.     dx1 = _X - int((_A + _Spacing) / 2 + 0.5) + PIX[0][0]
  87.     dy1 = _Y - int(_Fs / 2 + 0.5) + PIX[0][1]
  88.     # draw PIX
  89.     PIX_draw = draw2pix(PIC)
  90.     PIX_draw = PixStrip(PIX_draw)    # 裁剪空白边框部分, 可以提升效率等
  91.     points_draw = PixPoints(PIX_draw)
  92.     pt_num_draw = len(points_draw)
  93.     # 因为两个点集的点数可能不同, 所以需要一个合理的映射, 以下算法只是一个简单示例
  94.     num = pt_num_draw
  95.     te2 = _ET
  96.     for h in range(0,num,step):
  97.         indice_text = randint(0, pt_num - 1)
  98.         indice_draw = randint(0, pt_num_draw - 1)
  99.         x = dx1 - int(_A / 2) + points[indice_text][0]
  100.         y = dy1 - int(_Fs / 2) + points[indice_text][1]
  101.         x_fin = _X - int(_A / 2) + points_draw[indice_draw][0]
  102.         y_fin = _Y - int(_A / 2) + points_draw[indice_draw][1]
  103.         DX = _X - int(_A / 2 + 0.5) + points_draw[i][0]
  104.         DY = _Y - int(_Fs / 2 + 0.5) + points_draw[i][1]
  105.         ass_main(ASS_BUF, SubL(te1-20+randint(0,40),te2+randint(-20,20),2),move(DX,DY,DX+randint(-5,40),DY+randint(-30,10))+color1(C1)+color3(C1)+bord(0)+alpha(100), PixPt())
  106.     ass_main(ASS_BUF, SubL(te1,te2),an(5)+pos(_X,_Y)+color1("A09E99")+color3("CCCCCC")+bord(2)+blur(2),_TXT)


  107.     return (ASS_BUF,None)           
复制代码
不管好坏...算是做了个结束,收尾的地方做的不是很好,矢量图散成粒子控制的还是不是很好,定位,时间,不知道为什么调整不好,试了好多种办法,最后还是只能用最简单的随机定位...把手里的最后一个想法勉强实现了。。。好吧...我还是变懒了... draw2pix.py (629 Bytes, 下载次数: 2339) 会用到的附件,放到工程文件夹下面
1

查看全部评分

Rank: 4

发表于 2012-9-16 18:06:56 |显示全部楼层
顶一下,疯子强大

Rank: 4

发表于 2012-9-16 19:32:39 |显示全部楼层
本帖最后由 youkaze 于 2012-9-16 19:36 编辑

draw2pix 你不把这货丢上来么


PS:顺便求个预览

Administrator

TCAX Dev.

Rank: 7Rank: 7Rank: 7

发表于 2013-2-2 20:50:52 |显示全部楼层
這個是我看漏了麼? 對名字沒什麼印象

Rank: 4

发表于 2013-3-9 22:30:57 |显示全部楼层
请问这是什么问题?

Moderator

疯子

Rank: 5Rank: 5

发表于 2013-3-10 00:17:13 |显示全部楼层
渡辺麻友 发表于 2013-3-9 22:30
请问这是什么问题?

文件命名问题。。。是TCC里的名字不对?

Rank: 4

发表于 2013-3-10 11:50:16 |显示全部楼层
渣渣疯子 发表于 2013-3-10 00:17
文件命名问题。。。是TCC里的名字不对?

问题已经解决了,谢谢~O(∩_∩)O~
您需要登录后才可以回帖 登录 | 新人加入

GitHub|TCAX 主页

GMT+8, 2024-7-18 16:55

Powered by Discuz! X2

© 2001-2011 Comsenz Inc.

回顶部
RealH