TCAX 字幕特效制作工具官方论坛 | ASS | TCAS | Python | Aegisub | Lua
标题:
[J]031_horizon_op特效py脚本
[打印本页]
作者:
milkyjing
时间:
2011-10-13 08:07:26
标题:
[J]031_horizon_op特效py脚本
完整特效工程已与TCAX Beta3 SP2一并发布:
http://www.tcax.org/forum.php?mod=viewthread&tid=131
from tcaxPy import *
from pixLibs.ImageStone.pixStone import *
def tcaxPy_Init():
print('\nInitializing...')
global _FD
global _Fs
global Font
global FontOut
global PIX_tex2
global PIX_tex_li1
global PIX_tex_li2
global PIX_tex_li3
_FD = 1000 / GetVal(val_FXFPS)
_Fs = GetVal(val_FontSize)
_FontFileName = GetVal(val_FontFileName)
_FaceID = GetVal(val_FaceID)
Font = InitFont(_FontFileName, _FaceID, _Fs, GetVal(val_Spacing), GetVal(val_SpaceScale), MakeRGB(0, 0, 0), 0, 0)
FontOut = InitFont(_FontFileName, _FaceID, _Fs, GetVal(val_Spacing), GetVal(val_SpaceScale), MakeRGB(180, 180, 180), 4, 1)
PIX_tex2 = ImagePix(abspath('tex5.png'))
width = 128
height = 128
print('\nPrecaching images step 1 of 3...')
PIX_tex_li1 = []
for i in range(220):
filename = 'tex5\\a{:04d}.png'.format(i + 20)
PIX = ImagePix(abspath(filename))
w = PIX[1][0]
h = PIX[1][1]
marginHori = (w - width) / 2
marginVert = (h - height) / 2
PIX = PixCrop(PIX, marginHori, marginVert, -marginHori, -marginVert)
PIX_tex_li1.append(PIX)
progress(i + 1, 220)
print('\nPrecaching images step 2 of 3...')
PIX_tex_li2 = []
for i in range(220):
filename = 'tex6\\a{:04d}.png'.format(i + 20)
PIX = ImagePix(abspath(filename))
w = PIX[1][0]
h = PIX[1][1]
marginHori = (w - width) / 2
marginVert = (h - height) / 2
PIX = PixCrop(PIX, marginHori, marginVert, -marginHori, -marginVert)
PIX_tex_li2.append(PIX)
progress(i + 1, 220)
print('\nPrecaching images step 3 of 3...')
PIX_tex_li3 = []
for i in range(22):
filename = 'tex1\\img ({0}).png'.format(i + 4)
PIX = ImagePix(abspath(filename))
w = PIX[1][0]
h = PIX[1][1]
marginHori = (w - width) / 2
marginVert = (h - height) / 2
PIX = PixCrop(PIX, marginHori, marginVert, -marginHori, -marginVert)
PIX_tex_li3.append(PIX)
progress(i + 1, 22)
print('\nGenerating...')
def tcaxPy_Fin():
FinFont(Font)
FinFont(FontOut)
def tcaxPy_Main(_i, _j, _n, _start, _end, _elapk, _k, _x, _y, _a, _txt):
ASS_BUF = [] # 保存ASS特效
TCAS_BUF = [] # 保存TCAS特效
##### 主要特效编写操作 #####
dx = _x - int(_a / 2 + 0.5) # 一个固定操作, 将an5的坐标转换为an7
dy = _y - int(_Fs / 2 + 0.5) # ASS特效默认采用an5坐标, TCAS特效则采用an7坐标
ts_0 = _start - _FD * 10 / 10
ts = _start
te = _end
te_0 = te + _FD * 5 / 10
tm = _start + _elapk
if _i < 5:
PIX_tex_li = PIX_tex_li1
elif _i < 9:
PIX_tex_li = PIX_tex_li2
else:
PIX_tex_li = PIX_tex_li3
PIX_t = TextPix(Font, _txt) # 获取文字
PIX_t2 = PixTexture(PIX_t, PIX_tex_li[0]) # 增加纹理
PIX_out = TextPix(FontOut, _txt) # 获取边框
PIX_out = PixTexture(PIX_out, PIX_tex2)
PIX_out = PixColorMul(PIX_out, 1, 1, 1, 0.8) # 增加透明度
PIX_out = PixBlur(PIX_out, 6) # 增加模糊
PIX_ori = CombinePixs(PIX_out, PIX_t2) # 混合文字主体和边框 (边框作底)
center = _n / 2 - 0.5 # center index of 5 texts is 2, center index of 6 is 2.5
x = dx + 50 * (_j - center) / center
y = dy + 10
for i in range(10):
x = x + (dx - x) * (i + 1) / 5
y = y + (dy - y) * (i + 1) / 5
PIX = PixBlur(PIX_ori, 40 - i * 4)
tcas_main(TCAS_BUF, PIX, 10 * ts_0 + _FD * i, 10 * ts_0 + _FD * (i + 1), x, y, 0)
flag = 0
count = len(PIX_tex_li)
index = (_j + randint(0, 6)) % count
num = int(10 * (_end - _start) / _FD)
for i in range(num):
PIX_t2 = PixTexture(PIX_t, PIX_tex_li[index])
PIX = CombinePixs(PIX_out, PIX_t2)
t1 = 10 * ts + _FD * i
t2 = t1 + _FD
tcas_main(TCAS_BUF, PIX, t1, t2, dx, dy, 0)
if 0 == flag:
index += 1
if count == index:
index = count - 1
flag = 1
else:
index -= 1
if -1 == index:
index = 0
flag = 0
t1 = t2
t2 = 10 * _end
if t1 < t2:
tcas_main(TCAS_BUF, PIX, t1, t2, dx, dy, 0)
for i in range(0, 10 * _k, int(2 * _FD)):
PIX = PIX_ori
PIX = PixBlur(PIX, 0)
PIX = pstSoftGlow(PIX, 10, 60, 110)
tcas_main(TCAS_BUF, PIX, 10 * tm + i, 10 * tm + i + _FD, dx, dy, 0) # PixBlur(PIX, 0) 有特殊效果
for i in range(5):
PIX = PixBlur(PIX_ori, (i + 1) * 4)
#PIX = PixColorMul(PIX, 1, 1, 1, 0.5 + 0.5 * (5 - i - 1) / 5)
tcas_main(TCAS_BUF, PIX, 10 * te_0 - _FD * (5 - i), 10 * te_0 - _FD * (5 - i - 1), dx, dy, 0)
##### 将结果返回给tcax进行处理 #####
return (ASS_BUF, TCAS_BUF)
复制代码
预览见此帖:
http://www.tcax.org/forum.php?mod=viewthread&tid=43
文件名为: [J]031_horizon_op.mkv
作者:
milkyjing
时间:
2011-10-16 19:23:27
完整特效工程已与TCAX Beta3 SP2一并发布:
http://www.tcax.org/forum.php?mod=viewthread&tid=131
欢迎光临 TCAX 字幕特效制作工具官方论坛 | ASS | TCAS | Python | Aegisub | Lua (http://tcax.org/)
Powered by Discuz! X2