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

 找回密码
 新人加入
查看: 4030|回复: 8

[完整特效] [SAI]033_kyoukaisenjounohorizonIIED2 [复制链接]

Administrator

Shanzhai Pro.

Rank: 7Rank: 7Rank: 7

发表于 2012-8-21 11:03:15 |显示全部楼层
預覽:http://pan.baidu.com/s/1hqqY9CC#dir/path=%2FSaiyakuFX_Preview

都是逐幀特效,TCAS應該封裝 給兩個狀態 中間自動過渡幀才行嘛
這寫得一口老血
  1. from tcaxPy import *

  2. from collections import deque
  3. from extLibs._PythonMagick import *

  4. def tcaxPy_Init():

  5.     global _FontFileName        # 字体文件名
  6.     global _FaceID                # 字体Face序号
  7.     global _Fs                        # 字体大小
  8.     global _TextWidth                # 文字宽度
  9.     global _TextHeight                # 文字高度
  10.     global _TextLength
  11.     global _TextAdvDiff
  12.     global _ResolutionX
  13.     global _ResolutionY
  14.     global _OffsetX
  15.     global _OffsetY
  16.     global _FD                        # 一帧的持续时间, 40毫秒
  17.     global Font                        # 首要字体
  18.     global FontOut                # 字体边框
  19.     global Font2
  20.     global _AD
  21.     global _Advance

  22.     _FontFileName = GetVal(val_FontFileName)
  23.     _FaceID       = GetVal(val_FaceID)
  24.     _Fs           = GetVal(val_FontSize)
  25.     _TextHeight   = GetVal(val_TextHeight)
  26.     _TextWidth    = GetVal(val_TextWidth)
  27.     _TextLength   = GetVal(val_TextLength)
  28.     _TextAdvDiff  = GetVal(val_TextAdvanceDiff)
  29.     _ResolutionX  = GetVal(val_ResolutionX)
  30.     _ResolutionY  = GetVal(val_ResolutionY)
  31.     _OffsetX      = GetVal(val_OffsetX)
  32.     _OffsetY      = GetVal(val_OffsetY)
  33.     _FD           = 1000 / GetVal(val_FXFPS)
  34.     _AD           = GetVal(val_TextAdvanceDiff)
  35.     _Advance      = GetVal(val_TextAdvance)

  36.     Font = InitFont(_FontFileName, _FaceID, _Fs, GetVal(val_Spacing), GetVal(val_SpaceScale), MakeRGB(0, 0, 0), 0, False)
  37.     FontOut = InitFont(_FontFileName, _FaceID, _Fs, GetVal(val_Spacing), GetVal(val_SpaceScale), MakeRGB(0, 0, 0), 1.5, True)
  38.     Font2 = InitFont(_FontFileName, _FaceID, 48, GetVal(val_Spacing), GetVal(val_SpaceScale), MakeRGB(0, 0, 0), 0, False)


  39. def tcaxPy_Fin():

  40.     FinFont(Font)
  41.     FinFont(FontOut)
  42.     FinFont(Font2)

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

  44.     ASS_BUF = []
  45.     TCAS_BUF = []

  46.     dx = _X - int(_A / 2 + 0.5)         # 一个固定操作, 将an5的坐标转换为an7
  47.     dy = _Y - int(_Fs / 2 + 0.5)       # ASS特效默认采用an5坐标, TCAS特效则采用an7坐标

  48.     t3 = _BT*10
  49.     t4 = (_BT+_SK)*10
  50.     t5 = (_BT+_SK+_KT)*10
  51.     t6 = _ET*10
  52.     num = int(10 * _KT / _FD)+1


  53.     d = 0

  54.     if _j >= 1:
  55.         d = _AD[_i][_j] + _Advance[_i][_j] / 2 -_AD[_i][_j-1] -_Advance[_i][_j-1] / 2

  56.     if _i > -1:

  57.         n = int((_BT+_SK)*10/_FD)
  58.         TPIX1 = TextPix(Font, _TXT)
  59.         TPIX = TPIX1
  60.         TPIX1 = PixColorRGB(TPIX1, DecRGB('FFFFFF'))
  61.         texture = ImagePix(abspath('sky.png'))

  62.         TPIX2 = TextPix(Font2, _TXT)
  63.         TPIX2  = PixTexture(TPIX2,texture)
  64.         TPIX2 = PixPos(TPIX2, TPIX1[0][0] + (TPIX1[1][0] - TPIX2[1][0]) / 2, TPIX1[0][1] + (TPIX1[1][1] - TPIX2[1][1]) / 2)

  65.         SHAD = 2

  66.         OPIX = TextPix(FontOut, _TXT)
  67.         OPIX = PixColorRGB(OPIX, DecRGB('000000'))
  68.         SPIX3 = PixPos(TPIX, TPIX[0][0]+SHAD,TPIX[0][1]+SHAD)
  69.         SPIX3 = PixColorRGB(SPIX3, DecRGB('000000'))
  70.         OSPIX = CombinePixs(SPIX3, OPIX)
  71.         TPIX3 = CombinePixs(OSPIX, TPIX1)

  72.         FPIX1 = ImagePix(abspath('flower.png'))
  73.         FPIX2 =   PixResize(FPIX1, _Fs*1.7, _Fs*1.7)
  74.   
  75.         SPIX1 = PixColorRGB(TPIX2, DecRGB('000000'))
  76.         SPIX2 = PixBlur(SPIX1, 1)
  77.         SPIX2 = PixPos(SPIX2, SPIX1[0][0]+1,SPIX1[0][1]+1)
  78.         PIX = CombinePixs(SPIX2, TPIX2)

  79.         tcas_main(TCAS_BUF, TPIX3, t3 , t4, dx, dy, 3)
  80.         tcas_main(TCAS_BUF, TPIX3, t5 , t6, dx, dy, 3)

  81.         img = pmgToImage(FPIX2)
  82.         img.filterType(FilterTypes.QuadraticFilter)
  83.         img.backgroundColor(Color())  

  84.         if  _j == 0:
  85.             global angle
  86.             angle=0
  87.         
  88.         img0 = img
  89.         for i in range(num):
  90.             img = Image(img0)
  91.             img.rotate(angle + 5.5*i)
  92.             FPIX3 = pmgToPix(img)
  93.             FPIX4 = PixPos(FPIX3, TPIX1[0][0] + (TPIX1[1][0] - FPIX3[1][0]) / 2+i*d/num, TPIX1[0][1] + (TPIX1[1][1] - FPIX3[1][1]) / 2)
  94.             tb = _FD*n + _FD * i
  95.             te = tb + _FD
  96.             if _i < 3:
  97.                 tcas_main(TCAS_BUF, FPIX4,tb,te, dx, dy, 0)
  98.             XPIX = PIX

  99.             if i > 3:
  100.                 XPIX = PixResizeF(PIX, PIX[1][0] - (i-3)*(PIX[1][0]-TPIX1[1][0])/(num-3),PIX[1][1] - (i-3)*(PIX[1][1]-TPIX1[1][1])/(num-3) )  #PIX[1][1] - i*(PIX[1][1]-TPIX1[1][1])/num

  101.                 XPIX = BilinearFilter(XPIX, dx, dy)


  102.             tcas_main(TCAS_BUF, XPIX, tb, te, dx, dy, 10)


  103.         angle += num*5.5

  104.     if _i > 3:

  105.         ZPIX = ImagePix(abspath('s.png'))
  106.         ZPIX = PixResize(ZPIX, _Fs*1.7, _Fs*1.7)
  107.         zimg = pmgToImage(ZPIX)
  108.         zimg.filterType(FilterTypes.QuadraticFilter)
  109.         zimg.backgroundColor(Color())
  110.         zimg.rotate(randint(0,90))
  111.         zimg0 = zimg
  112.         zimg1 = zimg
  113.         for i in range(num):
  114.             zimg3 = Image(zimg0)
  115.             zimg4 = Image(zimg1)
  116.             zimg3.rotate( 5.5*i)
  117.             zimg4.rotate( -5.5*i)
  118.             ZPIX3 = pmgToPix(zimg3)
  119.             ZPIX4 = pmgToPix(zimg4)
  120.             ZPIX3 = PixPos(ZPIX3, TPIX1[0][0] + (TPIX1[1][0] - ZPIX3[1][0]) / 2, TPIX1[0][1] + (TPIX1[1][1] - ZPIX3[1][1]) / 2)
  121.             ZPIX4 = PixPos(ZPIX4, TPIX1[0][0] + (TPIX1[1][0] - ZPIX4[1][0]) / 2, TPIX1[0][1] + (TPIX1[1][1] - ZPIX4[1][1]) / 2)
  122.             tb = _FD*n + _FD * i
  123.             te = tb + _FD
  124.             tcas_main(TCAS_BUF, ZPIX3,tb,te, dx, dy, 0)
  125.             tcas_main(TCAS_BUF, ZPIX4,tb,te, dx, dy, 0)

  126.     return (ASS_BUF, TCAS_BUF)   
复制代码
2

查看全部评分

Rank: 5Rank: 5

发表于 2012-8-21 11:08:41 |显示全部楼层
看不懂,东西太多。

Rank: 4

发表于 2012-8-21 11:39:17 |显示全部楼层
楼上+1

Moderator

疯子

Rank: 5Rank: 5

发表于 2012-8-21 20:24:50 |显示全部楼层
有没有视频预览啥的呢,看不到效果,单纯看代码啥的...

Rank: 4

发表于 2012-8-21 20:36:23 |显示全部楼层
渣渣疯子 发表于 2012-8-21 20:24
有没有视频预览啥的呢,看不到效果,单纯看代码啥的...

    群邮件上不是有吗

Moderator

疯子

Rank: 5Rank: 5

发表于 2012-8-22 00:33:11 |显示全部楼层
kk123456 发表于 2012-8-21 20:36
群邮件上不是有吗

我先看了眼论坛,才上QQ的

Rank: 5Rank: 5

发表于 2012-8-22 03:51:22 |显示全部楼层
话说,不少png图片都没有...怎么玩啊

Rank: 4

发表于 2012-11-14 00:04:07 |显示全部楼层
好好学习,天天向上

Rank: 6Rank: 6

发表于 2016-8-3 20:19:41 |显示全部楼层
教练 看不懂好痛苦
您需要登录后才可以回帖 登录 | 新人加入

GitHub|TCAX 主页

GMT+8, 2024-4-19 00:55

Powered by Discuz! X2

© 2001-2011 Comsenz Inc.

回顶部
RealH