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

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

[完整特效] [SAI]032_hyoukaOP [复制链接]

Administrator

Shanzhai Pro.

Rank: 7Rank: 7Rank: 7

跳转到指定楼层
楼主
发表于 2012-8-21 11:11:38 |只看该作者 |倒序浏览
預覽:http://pan.baidu.com/s/1hqqY9CC#dir/path=%2FSaiyakuFX_Preview
  1. from tcaxPy import *
  2. from extLibs.XXParticleSystem import *
  3. from util.cairo import *
  4. from util.gdiFont import *


  5. def tcaxPy_Init():

  6.     global _Fs

  7.     global _FD                  # 一帧的持续时间, 约40毫秒

  8.     global _Spacing         # 字体间距

  9.     global Font                 # 首要字体

  10.     global GdiFont

  11.     _Fs = GetVal(val_FontSize)

  12.     _FD = 1000 / GetVal(val_FXFPS)

  13.     _FontFileName = GetVal(val_FontFileName)

  14.     _FaceID = GetVal(val_FaceID)

  15.     _Spacing = GetVal(val_Spacing)

  16.     Font = InitFont(_FontFileName, _FaceID, _Fs, _Spacing, GetVal(val_SpaceScale), MakeRGB(255, 255, 255), 0, False)

  17.     GdiFont = gfInitFont(GetVal(val_FontFaceName), _Fs, GetVal(val_Spacing), GetVal(val_SpaceScale), 0, False)   #GDIfont
  18.    
  19.     # cairo

  20.     global ctx

  21.     fx_width = GetVal(val_ResolutionX)

  22.     fx_height = GetVal(val_ResolutionY)

  23.     surface = ImageSurface(FORMAT_ARGB32, fx_width, fx_height)

  24.     ctx = Context(surface)



  25. def tcaxPy_Fin():
  26.     FinFont(Font)
  27.     gfFinFont(GdiFont)   #GDIfont

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

  29.     ASS_BUF  = []                # 保存ASS特效
  30.     TCAS_BUF = []                # 保存TCAS特效

  31.     if _i < 8:
  32.         if _i < 2 or _i == 7:
  33.             C1 = "FF0000"
  34.         else:
  35.             C1 = "3CFFF8"

  36.         size = 100
  37.         n = 40
  38.         x = 40
  39.         for i in range(0,_KT,n):
  40.             rand1 = randint(-20,20)
  41.             rand2 = randint(-20,20)
  42.             for j in range(2):
  43.                 ass_main(ASS_BUF,SubL(_BT+_SK-5+i+j*x,_BT+_SK+100+i+j*x),an(7)+pos(_X+0.5*randint(-1,1)+rand1,_Y+0.5*randint(-1,1)-rand2)+xshad(1)+be(1)+bord(2.5)+color3("D4FEFC")+alpha1(250)+color1(C1)+fscx(0)+fscy(0)+t(fsc(size,size))+fad(100,1000),"{\p2}m 59 0 b 59 -79 -59 -79 -59 0 -59 79 59 79 59 0{\p0}")
  44.                 ass_main(ASS_BUF,SubL(_BT+_SK-3+i+j*x,_BT+_SK+102+i+j*x),an(7)+pos(_X+0.5*randint(-1,1)-rand2,_Y+0.5*randint(-1,1)+rand1)+yshad(1)+be(1)+bord(2.5)+color3("D4FEFC")+alpha1(250)+color1(C1)+fscx(0)+fscy(0)+t(fsc(size,size))+fad(100,1000),"{\p2}m 59 0 b 59 -79 -59 -79 -59 0 -59 79 59 79 59 0{\p0}")

  45.         dx = _X - int(_A / 2 + 0.5)
  46.         dy = _Y - int(_Fs / 2 + 0.5)

  47.         frames = int(1500 / _FD + 0.5)
  48.         randx = randint(50,80)
  49.         randy = randint(-50,50)
  50.         for i in range(frames):

  51.             ts = _BT+_SK-5 + i * _FD / 10

  52.             te = _BT+_SK-5 + (i + 1) * _FD / 10

  53.             frame_pct = i / frames

  54.             outline = gfGetOutline(GdiFont, _TXT, dx, dy)

  55.             AssDraw(ctx, outline)

  56.             path_trans(ctx, wave_filter,(_X,_Y,frame_pct))

  57.             text = ToAssDraw(ctx)

  58.             EFT = an(7) + pos(0,0) + alpha1(255 * frame_pct)+alpha3(155 * frame_pct+100) +bord(1.5)+ p(4)

  59.             ass_main(ASS_BUF, SubL(ts, te), EFT, text)

  60.         outline = gfGetOutline(GdiFont, _TXT, dx, dy)

  61.         ass_main(ASS_BUF, SubL(_BT+_j*5, _BT+_SK-5),an(7) + pos(0,0)+fad(150,0)+bord(1.5)+p(4), outline)

  62.     else:
  63.         dx = _X - int(_A / 2 + 0.5)
  64.         dy = _Y - int(_Fs / 2 + 0.5)

  65.         frames = int(1000 / _FD + 0.5)
  66.         randx = randint(50,80)
  67.         randy = randint(30,80)
  68.         rx = randint(-90,90)
  69.         ry = randint(-90,90)
  70.         rz = randint(0,180)

  71.         POS = Bezier3(frames,0 , 0 , -randx, -randy,-randint(0,int(randx/2)), randint(-50,50),-randint(int(randx/2),randx), randint(-50,50))

  72.         for i in range(frames):

  73.             ts = _BT+_SK-5 + i * _FD / 10

  74.             te = _BT+_SK-5 + (i + 1) * _FD / 10

  75.             frame_pct = i / frames

  76.             outline = gfGetOutline(GdiFont, _TXT, dx, dy)

  77.             AssDraw(ctx, outline)

  78.             path_trans(ctx, flag_filter, (dx+POS[i][0]*frame_pct, dx, randx/2.5, _Fs, frame_pct))

  79.             text = ToAssDraw(ctx)

  80.             EFT = an(7) + pos(POS[i][0]*frame_pct,POS[i][1]*frame_pct)+ alpha1(255 * frame_pct)+alpha3(155 * frame_pct+100) +bord(1.5)+ p(4)

  81.             ass_main(ASS_BUF, SubL(ts, te), EFT, text)

  82.         outline = gfGetOutline(GdiFont, _TXT, dx, dy)

  83.         ass_main(ASS_BUF, SubL(_BT+_j*5, _BT+_SK-5),an(7) + pos(0,0)+fad(150,0)+bord(1.5)+p(4), outline)

  84.     return (ASS_BUF,None)



  85. def wave_filter(x, y, param):

  86.     dx, dy, frame_pct = param

  87.     d = sqrt((x-dx*8)**2+(y-dy*8)**2)

  88.     if d==0:
  89.         max_diff_x = sin(  pi / 10 + frame_pct * pi * 5) * 3 * 8
  90.         max_diff_y = cos(  pi / 10 + frame_pct * pi * 5) * 3 * 8
  91.     else:
  92.         max_diff_x = sin( (y-dy)/d * pi / 10 + frame_pct * pi * 5) * 3 * 8
  93.         max_diff_y = cos( (x-dx)/d * pi / 10 + frame_pct * pi * 5) * 3 * 8        

  94.     new_x = x + floor(frame_pct * max_diff_x)

  95.     new_y = y + floor(frame_pct * max_diff_y)

  96.     return new_x, new_y

  97. def flag_filter(x, y, param):

  98.     char_left, line_left, line_width, line_height, frame_pct = param

  99.     char_x = ceil(x + char_left * 8 - line_left * 8)

  100.     max_diff_x = sin(y / line_height * pi / 10 + frame_pct * pi * 5) * 20 * 8

  101.     max_diff_y = sin(char_x / line_width * pi / 10 + frame_pct * pi * 5) * 20 * 8

  102.     new_x = char_x + floor(max_diff_y * frame_pct)

  103.     new_y = y + floor(max_diff_y * frame_pct)

  104.     return new_x, new_y
复制代码
1

查看全部评分

Rank: 4

沙发
发表于 2012-8-21 12:49:24 |只看该作者
    完全看不懂

Rank: 4

板凳
发表于 2012-8-22 22:30:58 |只看该作者
登陆看看

Administrator

TCAX Dev.

Rank: 7Rank: 7Rank: 7

地板
发表于 2012-8-24 18:04:17 |只看该作者
灾厄仔久违的代码必须顶

Rank: 4

5#
发表于 2022-1-16 03:47:34 |只看该作者
冰菓OP1 简化拆分.rar (348.12 KB, 下载次数: 2292)
您需要登录后才可以回帖 登录 | 新人加入

GitHub|TCAX 主页

GMT+8, 2024-11-22 02:07

Powered by Discuz! X2

© 2001-2011 Comsenz Inc.

回顶部
RealH