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

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

[完整特效] [youkaze]012_Hyouka_ED [复制链接]

Moderator

youkaze

Rank: 5Rank: 5

跳转到指定楼层
楼主
发表于 2012-6-4 18:52:27 |显示全部楼层 |倒序浏览
本帖最后由 四月一日 君寻 于 2012-6-4 18:55 编辑
  1. from tcaxPy import *
  2. from gdiFont import *  #加入GDIfont模块


  3. def tcaxPy_Init():



  4.     global _FontFileName   
  5.     global _FaceID
  6.     global _Fs
  7.     global _TextWidth
  8.     global _TextHeight
  9.     global _TextLength
  10.     global _TextAdvDiff
  11.     global _ResolutionX
  12.     global _OffsetX
  13.     global _FD


  14.     _FontFileName = GetVal(val_FontFileName)
  15.     _FaceID       = GetVal(val_FaceID)
  16.     _Fs           = GetVal(val_FontSize)
  17.     _TextHeight   = GetVal(val_TextHeight)
  18.     _TextWidth    = GetVal(val_TextWidth)
  19.     _TextLength   = GetVal(val_TextLength)
  20.     _TextAdvDiff  = GetVal(val_TextAdvanceDiff)
  21.     _ResolutionX  = GetVal(val_ResolutionX)
  22.     _OffsetX      = GetVal(val_OffsetX)
  23.     _FD           = 1000 / GetVal(val_FXFPS)



  24.     global GdiFont   #GDIfont
  25.    
  26.     GdiFont = gfInitFont(GetVal(val_FontFaceName), _Fs, GetVal(val_Spacing), GetVal(val_SpaceScale), 0, False)   #GDIfont
  27.    
  28.     global Font
  29.     Font = InitFont(GetVal(val_FontFileName), GetVal(val_FaceID), _Fs, GetVal(val_Spacing), GetVal(val_SpaceScale), 0xFFFFFF, 0, 0)


  30. def tcaxPy_Fin():
  31.     gfFinFont(GdiFont)   #GDIfont
  32.    
  33.     FinFont(Font)



  34. def tcaxPy_Main(_i, _j, _n, _BT, _ET, _SK, _KT, _x, _y, _a, _txt):

  35.     ASS_BUF = []
  36.     if _i > -1 and _i < 2:
  37.         ass_main(ASS_BUF, SubL(_BT,_BT+_SK-10),an(5)+pos(_x,_y)+fad(200,0)+bord(1.5)+blur(1.5)+color3('EC487C'), _txt)
  38.         ass_main(ASS_BUF, SubL(_BT+_SK-10,_BT+_SK+_KT),an(5)+pos(_x,_y)+bord(1.5)+blur(1.5)+alpha1(255)+color3('EC487C')+t(0,100,color3('FFFFFF')+blur(4)+bord(4))+t(300,600,bord(1.5)+blur(1.5)), _txt)
  39.         ass_main(ASS_BUF, SubL(_BT+_SK+_KT,_ET),an(5)+pos(_x,_y)+fad(0,200)+bord(1.5)+blur(1.5)+alpha1(255)+color3('FFFFFF'), _txt)
  40.    
  41.    
  42.         points = gfGetPoints(GdiFont, _txt)  #GDIfont

  43.         PIX = PixFromPoints(points)   #GDIfont
  44.    
  45.         InitPosX = _x - int(_a / 2 + 0.5) + PIX[0][0]        # 第一个像素的X轴坐标
  46.         InitPosY = _y - int(_Fs / 2 + 0.5) + PIX[0][1]        # 第一个像素的Y轴坐标
  47.         for h in range(PIX[1][1]):                                # 开始纵向扫描
  48.             PosY  = InitPosY + h
  49.                                       # 当前像素Y轴坐标
  50.             for w in range(PIX[1][0]):                        # 开始横向扫描
  51.                 PosX = InitPosX + w
  52.                 X = PosX-randint(-50,50)
  53.                 Y = PosY-randint(-50,50)                        # 当前像素X轴坐标
  54.                 idx  = 4 * (h * PIX[1][0] + w)                # 脚标
  55.                 PixR = PIX[2][idx + 0]                        # 当前像素的红色分量
  56.                 PixG = PIX[2][idx + 1]                        # 当前像素的绿色分量
  57.                 PixB = PIX[2][idx + 2]                        # 当前像素的蓝色分量
  58.                 PixA = PIX[2][idx + 3]                        # 当前像素的透明度
  59.                 if PixA != 0:                                # 如果当前像素不为透明则进行如下操作
  60.                     rnd = randint(-20,20)
  61.                     R = randint(0,50)
  62.                     C = randint(-100,100)
  63.                
  64.                     ass_main(ASS_BUF, SubL(_BT+_SK-10,_BT+_SK+_KT+R,1, Pix_Style),an(7)+mov(PosX,PosY,PosX,PosY+30+rnd)+fad(0,300-C)+alpha(255-PixA)+blur(1.5)+shad(0)+bord(0)+color1("FFFFFF"), "{\p4}m -5 -15 l -15 0 l -6 7 l 9 12 l 5 4 l 13 -13 ")
  65.                

  66.         EFT1 = alpha1(0) + alpha3(100) + bord(6) + blur(7)
  67.         num = 60
  68.         points1 = Bezier1(num, _x-7, _y+200+randint(10,50), _x-7, _y)
  69.         points2 = Bezier1(num, _x, _y+200+randint(10,50), _x, _y)
  70.         #points1 = Bezier3(num, _x-200+randint(-100,100), _y+20+randint(10,50), _x, _y, _x-100, _y-20+randint(10,50), _x-50, _y+20+randint(10,50))
  71.         for i in range(num):
  72.             POS1 = pos(points1[i][0], points1[i][1])
  73.             EFT1 = POS1 + EFT1 + color3('91CCFF') + an(7)
  74.             ass_main(ASS_BUF, SubL(_BT+_SK-70+i*1, _BT+_SK-70+(i+1)*1, 1, Pix_Style), EFT1, "{\p1}m 7 0 b 2 0 1 4 1 6 b 1 8 2 12 7 12 b 12 12 13 8 13 6 b 13 4 12 0 7 0 ")
  75.                
  76.             for j in range(num):
  77.                 if randint(0,num) == 0:
  78.                     ass_main(ASS_BUF, SubL(_BT+_SK-65+i*1, _BT+_SK-65+(i+1)*1+20,1), an(7)+blur(0.3)+bord(0.2)+color3("FFFFFF") +color1("FFFFFF")+ mov(points2[i][0]+randint(-5,5), points2[i][1]+randint(-5,5),points2[i][0]+randint(-15,15), points2[i][1]+20)+fad(0,300)+fsc(60,60), "{\p4}m -5 -15 l -15 0 l -6 7 l 9 12 l 5 4 l 13 -13 ")
  79.                
  80.     if _i > 1 and _i < 7:
  81.         
  82.         dx = _x - int(_a / 2 + 0.5)
  83.         dy = _y - int(_Fs / 2 + 0.5)
  84.    
  85.         outline = TextOutlinePoints(Font, _txt, 1.0)
  86.         
  87.         num = len(outline)
  88.         dur = 100
  89.         for i in range(num):
  90.             CIR=RandCir2(_x, _y, 30, 34)
  91.             ts = _BT + dur * i / num
  92.             te = _ET
  93.             x = dx + outline[i][0]
  94.             y = dy + outline[i][1]
  95.             B = randint(-100,100)
  96.             
  97.             ass_main(ASS_BUF, SubL(ts-20, _BT+_SK, 1, Pix_Style), an(7)+pos(x, y) + alpha1(0) + alpha3(150) + bord(1.5) + shad(0) + color3('EC487C') + color1('EC487C') + fad(200, 0) + blur(1.5), PixPt())
  98.             ass_main(ASS_BUF, SubL(_BT+_SK, _BT+_SK+_KT+20, 1, Pix_Style), an(7)+mov(x, y, CIR[0], CIR[1]) + alpha1(0) + alpha3(150) + bord(1.5) + shad(0) + color3('EC487C') + color1('ED00BA') + fad(0, 300) + blur(1.5), PixPt())

  99.    
  100.         #points = gfGetPoints(GdiFont, _txt)  #GDIfont

  101.         #PIX = PixFromPoints(points)   #GDIfont
  102.    
  103.         PIX = TextPix(Font, _txt)
  104.         InitPosX = _x - int(_a / 2 + 0.5) + PIX[0][0]        # 第一个像素的X轴坐标
  105.         InitPosY = _y - int(_Fs / 2 + 0.5) + PIX[0][1]        # 第一个像素的Y轴坐标
  106.         for h in range(PIX[1][1]):                                # 开始纵向扫描
  107.             PosY  = InitPosY + h
  108.                                       # 当前像素Y轴坐标
  109.             for w in range(PIX[1][0]):                        # 开始横向扫描
  110.                 PosX = InitPosX + w
  111.                 X = PosX-randint(-50,50)
  112.                 Y = PosY-randint(-50,50)                        # 当前像素X轴坐标
  113.                 idx  = 4 * (h * PIX[1][0] + w)                # 脚标
  114.                 PixR = PIX[2][idx + 0]                        # 当前像素的红色分量
  115.                 PixG = PIX[2][idx + 1]                        # 当前像素的绿色分量
  116.                 PixB = PIX[2][idx + 2]                        # 当前像素的蓝色分量
  117.                 PixA = PIX[2][idx + 3]                        # 当前像素的透明度
  118.                 if PixA != 0:                                # 如果当前像素不为透明则进行如下操作
  119.                     rnd = randint(-30,30)
  120.                     R = randint(-100,100)
  121.                     H = randint(-10,10)

  122.                     ass_main(ASS_BUF, SubL(int(_BT+_SK+w*(_KT/PIX[1][0]))+H,int(_BT+_SK+150+rnd+w*(_KT/PIX[1][0])),1, Pix_Style),an(7)+mov(PosX,PosY,PosX-20+rnd,PosY)+fad(0,300+R+rnd)+alpha(255-PixA)+shad(0)+bord(1)+blur(1)+org(_x,_y)+color1("FFFFFF")+frx(0)+t(500,0,frx(360)+color3('FFA739')), "{\p5}m -5 -15 l -15 0 l -6 7 l 9 12 l 5 4 l 13 -13 ")
  123.                
  124.                     ass_main(ASS_BUF, SubL(_BT,int(_BT+_SK+w*(_KT/PIX[1][0]))+H,1, Pix_Style),an(7)+pos(PosX,PosY)+shad(0)+bord(0)+alpha(255-PixA)+color1("FFFFFF")+fad(200,0), PixPt())

  125.     if _i > 6:
  126.         ass_main(ASS_BUF, SubL(_BT,_BT+_SK-10),an(5)+pos(_x,_y)+fad(200,0)+bord(1.5)+blur(1.5)+color3('EC487C'), _txt)
  127.         ass_main(ASS_BUF, SubL(_BT+_SK-10,_BT+_SK+_KT),an(5)+pos(_x,_y)+bord(1.5)+blur(1.5)+alpha1(255)+color3('EC487C')+t(0,100,color3('FFFFFF')+blur(4)+bord(4))+t(300,600,bord(1.5)+blur(1.5)), _txt)
  128.         ass_main(ASS_BUF, SubL(_BT+_SK+_KT,_ET),an(5)+pos(_x,_y)+fad(0,200)+bord(1.5)+blur(1.5)+alpha1(255)+color3('FFFFFF'), _txt)
  129.    
  130.    
  131.         points = gfGetPoints(GdiFont, _txt)  #GDIfont

  132.         PIX = PixFromPoints(points)   #GDIfont
  133.    
  134.         InitPosX = _x - int(_a / 2 + 0.5) + PIX[0][0]        # 第一个像素的X轴坐标
  135.         InitPosY = _y - int(_Fs / 2 + 0.5) + PIX[0][1]        # 第一个像素的Y轴坐标
  136.         for h in range(PIX[1][1]):                                # 开始纵向扫描
  137.             PosY  = InitPosY + h
  138.                                       # 当前像素Y轴坐标
  139.             for w in range(PIX[1][0]):                        # 开始横向扫描
  140.                 PosX = InitPosX + w
  141.                 X = PosX-randint(-50,50)
  142.                 Y = PosY-randint(-50,50)                        # 当前像素X轴坐标
  143.                 idx  = 4 * (h * PIX[1][0] + w)                # 脚标
  144.                 PixR = PIX[2][idx + 0]                        # 当前像素的红色分量
  145.                 PixG = PIX[2][idx + 1]                        # 当前像素的绿色分量
  146.                 PixB = PIX[2][idx + 2]                        # 当前像素的蓝色分量
  147.                 PixA = PIX[2][idx + 3]                        # 当前像素的透明度
  148.                 if PixA != 0:                                # 如果当前像素不为透明则进行如下操作
  149.                     rnd = randint(-20,20)
  150.                     R = randint(0,50)
  151.                     C = randint(-100,100)
  152.                
  153.                     ass_main(ASS_BUF, SubL(_BT+_SK-10,_BT+_SK+_KT+R,1, Pix_Style),an(7)+mov(PosX,PosY,PosX,PosY+30+rnd)+fad(0,300-C)+alpha(255-PixA)+blur(1.5)+shad(0)+bord(0)+color1("FFFFFF"), "{\p4}m -5 -15 l -15 0 l -6 7 l 9 12 l 5 4 l 13 -13 ")
  154.                

  155.         EFT1 = alpha1(0) + alpha3(0) + color1('FFFFFF') + bord(1.5) + blur(2.5) + t(0, 100, fscx(1)+fscy(1)) + fad(0, 200)
  156.         num = 100
  157.         
  158.         xs = _x + randint(-100, 100)    # 开始点
  159.         ys = _y + randint(-60, 20)
  160.         xc1 = xs + randint(-50, 50)     # 控制点1
  161.         yc1 = ys + randint(-50, 50)
  162.         xc2 = xc1 + randint(-40, 40)    # 控制点2
  163.         yc2 = yc1 + randint(-40, 40)
  164.         xe = _x     # 结束点
  165.         ye = _y
  166.         
  167.         points1 = Bezier3(num, xs, ys, xe, ye, xc1, yc1, xc2, yc2)   # 3阶贝塞尔曲线, 控制点的生成是重点以及难点
  168.         for i in range(num):
  169.             POS1 = pos(points1[i][0], points1[i][1])
  170.             EFT1 = POS1 + EFT1 + color3('FFA739') + an(7)
  171.             ass_main(ASS_BUF, SubL(_BT+_SK-115+i*1, _BT+_SK-115+(i+1)*1+20, 1, Pix_Style), EFT1, "{\p2}m 7 0 b 2 0 1 4 1 6 b 1 8 2 12 7 12 b 12 12 13 8 13 6 b 13 4 12 0 7 0 ")
  172.                

  173.    
  174.     return (ASS_BUF, None)
复制代码
懒得整理 或许里面有些东西写着了也没起作用……嘛还是习惯从头到尾一直写if……  总之这货挺简单了 没啥特别的东西
感谢哔哔姐上传
下面是预览:
3

查看全部评分

Moderator

youkaze

Rank: 5Rank: 5

沙发
发表于 2012-6-6 18:27:09 |显示全部楼层
kk123456 发表于 2012-6-6 16:13
我想问一下 RandCir2(_x, _y, 30, 34) 这是干啥用的?
总感觉看得晕晕的 ...


def RandCir2(a, b, r1, r2):      # 随机环分布函数 RandomCircle2

你可以在tcax根目录下的tcaxPy.py文件里找到
您需要登录后才可以回帖 登录 | 新人加入

GitHub|TCAX 主页

GMT+8, 2024-5-3 18:33

Powered by Discuz! X2

© 2001-2011 Comsenz Inc.

回顶部
RealH