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

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

[完整特效] [J]031_horizon_op特效py脚本 [复制链接]

Administrator

TCAX Dev.

Rank: 7Rank: 7Rank: 7

跳转到指定楼层
楼主
发表于 2011-10-13 08:07:26 |只看该作者 |倒序浏览
完整特效工程已与TCAX Beta3 SP2一并发布:

http://www.tcax.org/forum.php?mod=viewthread&tid=131
  1. from tcaxPy import *
  2. from pixLibs.ImageStone.pixStone import *

  3. def tcaxPy_Init():
  4.     print('\nInitializing...')
  5.     global _FD
  6.     global _Fs
  7.     global Font
  8.     global FontOut
  9.     global PIX_tex2
  10.     global PIX_tex_li1
  11.     global PIX_tex_li2
  12.     global PIX_tex_li3
  13.     _FD = 1000 / GetVal(val_FXFPS)
  14.     _Fs = GetVal(val_FontSize)
  15.     _FontFileName = GetVal(val_FontFileName)
  16.     _FaceID       = GetVal(val_FaceID)
  17.     Font    = InitFont(_FontFileName, _FaceID, _Fs, GetVal(val_Spacing), GetVal(val_SpaceScale), MakeRGB(0, 0, 0), 0, 0)
  18.     FontOut = InitFont(_FontFileName, _FaceID, _Fs, GetVal(val_Spacing), GetVal(val_SpaceScale), MakeRGB(180, 180, 180), 4, 1)
  19.     PIX_tex2 = ImagePix(abspath('tex5.png'))
  20.     width = 128
  21.     height = 128
  22.     print('\nPrecaching images step 1 of 3...')
  23.     PIX_tex_li1 = []
  24.     for i in range(220):
  25.         filename = 'tex5\\a{:04d}.png'.format(i + 20)
  26.         PIX = ImagePix(abspath(filename))
  27.         w = PIX[1][0]
  28.         h = PIX[1][1]
  29.         marginHori = (w - width) / 2
  30.         marginVert = (h - height) / 2
  31.         PIX = PixCrop(PIX, marginHori, marginVert, -marginHori, -marginVert)
  32.         PIX_tex_li1.append(PIX)
  33.         progress(i + 1, 220)
  34.     print('\nPrecaching images step 2 of 3...')
  35.     PIX_tex_li2 = []
  36.     for i in range(220):
  37.         filename = 'tex6\\a{:04d}.png'.format(i + 20)
  38.         PIX = ImagePix(abspath(filename))
  39.         w = PIX[1][0]
  40.         h = PIX[1][1]
  41.         marginHori = (w - width) / 2
  42.         marginVert = (h - height) / 2
  43.         PIX = PixCrop(PIX, marginHori, marginVert, -marginHori, -marginVert)
  44.         PIX_tex_li2.append(PIX)
  45.         progress(i + 1, 220)
  46.     print('\nPrecaching images step 3 of 3...')
  47.     PIX_tex_li3 = []
  48.     for i in range(22):
  49.         filename = 'tex1\\img ({0}).png'.format(i + 4)
  50.         PIX = ImagePix(abspath(filename))
  51.         w = PIX[1][0]
  52.         h = PIX[1][1]
  53.         marginHori = (w - width) / 2
  54.         marginVert = (h - height) / 2
  55.         PIX = PixCrop(PIX, marginHori, marginVert, -marginHori, -marginVert)
  56.         PIX_tex_li3.append(PIX)
  57.         progress(i + 1, 22)
  58.     print('\nGenerating...')

  59. def tcaxPy_Fin():
  60.     FinFont(Font)
  61.     FinFont(FontOut)

  62. def tcaxPy_Main(_i, _j, _n, _start, _end, _elapk, _k, _x, _y, _a, _txt):

  63.     ASS_BUF  = []        # 保存ASS特效
  64.     TCAS_BUF = []        # 保存TCAS特效

  65.     ##### 主要特效编写操作 #####

  66.     dx = _x - int(_a / 2 + 0.5)         # 一个固定操作, 将an5的坐标转换为an7
  67.     dy = _y - int(_Fs / 2 + 0.5)        # ASS特效默认采用an5坐标, TCAS特效则采用an7坐标

  68.     ts_0 = _start - _FD * 10 / 10
  69.     ts = _start
  70.     te = _end
  71.     te_0 = te + _FD * 5 / 10
  72.     tm = _start + _elapk

  73.     if _i < 5:
  74.         PIX_tex_li = PIX_tex_li1
  75.     elif _i < 9:
  76.         PIX_tex_li = PIX_tex_li2
  77.     else:
  78.         PIX_tex_li = PIX_tex_li3

  79.     PIX_t = TextPix(Font, _txt)             # 获取文字
  80.     PIX_t2 = PixTexture(PIX_t, PIX_tex_li[0])      # 增加纹理
  81.     PIX_out = TextPix(FontOut, _txt)        # 获取边框
  82.     PIX_out = PixTexture(PIX_out, PIX_tex2)
  83.     PIX_out = PixColorMul(PIX_out, 1, 1, 1, 0.8)    # 增加透明度
  84.     PIX_out = PixBlur(PIX_out, 6)           # 增加模糊
  85.     PIX_ori = CombinePixs(PIX_out, PIX_t2)   # 混合文字主体和边框 (边框作底)

  86.     center = _n / 2 - 0.5      # center index of 5 texts is 2, center index of 6 is 2.5
  87.     x = dx + 50 * (_j - center) / center
  88.     y = dy + 10
  89.     for i in range(10):
  90.         x = x + (dx - x) * (i + 1) / 5
  91.         y = y + (dy - y) * (i + 1) / 5
  92.         PIX = PixBlur(PIX_ori, 40 - i * 4)
  93.         tcas_main(TCAS_BUF, PIX, 10 * ts_0 + _FD * i, 10 * ts_0 + _FD * (i + 1), x, y, 0)

  94.     flag = 0
  95.     count = len(PIX_tex_li)
  96.     index = (_j + randint(0, 6)) % count
  97.     num = int(10 * (_end - _start) / _FD)
  98.     for i in range(num):
  99.         PIX_t2 = PixTexture(PIX_t, PIX_tex_li[index])
  100.         PIX = CombinePixs(PIX_out, PIX_t2)
  101.         t1 = 10 * ts + _FD * i
  102.         t2 = t1 + _FD
  103.         tcas_main(TCAS_BUF, PIX, t1, t2, dx, dy, 0)
  104.         if 0 == flag:
  105.             index += 1
  106.             if count == index:
  107.                 index = count - 1
  108.                 flag = 1
  109.         else:
  110.             index -= 1
  111.             if -1 == index:
  112.                 index = 0
  113.                 flag = 0
  114.     t1 = t2
  115.     t2 = 10 * _end
  116.     if t1 < t2:
  117.         tcas_main(TCAS_BUF, PIX, t1, t2, dx, dy, 0)

  118.     for i in range(0, 10 * _k, int(2 * _FD)):
  119.         PIX = PIX_ori
  120.         PIX = PixBlur(PIX, 0)
  121.         PIX = pstSoftGlow(PIX, 10, 60, 110)
  122.         tcas_main(TCAS_BUF, PIX, 10 * tm + i, 10 * tm + i + _FD, dx, dy, 0)     # PixBlur(PIX, 0) 有特殊效果

  123.     for i in range(5):
  124.         PIX = PixBlur(PIX_ori, (i + 1) * 4)
  125.         #PIX = PixColorMul(PIX, 1, 1, 1, 0.5 + 0.5 * (5 - i - 1) / 5)
  126.         tcas_main(TCAS_BUF, PIX, 10 * te_0 - _FD * (5 - i), 10 * te_0 - _FD * (5 - i - 1), dx, dy, 0)

  127.     ##### 将结果返回给tcax进行处理 #####

  128.     return (ASS_BUF, TCAS_BUF)
复制代码
预览见此帖: http://www.tcax.org/forum.php?mod=viewthread&tid=43

文件名为: [J]031_horizon_op.mkv


1

查看全部评分

Administrator

TCAX Dev.

Rank: 7Rank: 7Rank: 7

沙发
发表于 2011-10-16 19:23:27 |只看该作者
完整特效工程已与TCAX Beta3 SP2一并发布:

http://www.tcax.org/forum.php?mod=viewthread&tid=131
您需要登录后才可以回帖 登录 | 新人加入

GitHub|TCAX 主页

GMT+8, 2024-11-25 01:11

Powered by Discuz! X2

© 2001-2011 Comsenz Inc.

回顶部
RealH