- UID
- 2
- 积分
- 8682
- 帖子
- 2905
- 主题
- 199
- 论坛币
- 11740
- 威望
- 16
- EP值
- 2349
- MP值
- 15
- 阅读权限
- 200
- 注册时间
- 2011-8-3
- 在线时间
- 2597 小时
- 最后登录
- 2024-8-28
|
说明, 如果要直接执行本脚本, 请升级TCAX到最新版 (1.0.0), 附件为完整工程
说明2, 近期会陆续更新TCAS使用教程...- from tcaxPy import *
- from pixLibs.ImageStone import *
- def tcaxPy_Init():
- global _Fs
- global _FD # 一帧的持续时间, 约40毫秒
- global Font # 首要字体
- global FontOut # 字体边框
- global FontOut2 # 字体边框2
- global FontAll # 加粗字体
- _Fs = GetVal(val_FontSize)
- _FD = 1000 / GetVal(val_FXFPS)
- _FontFileName = GetVal(val_FontFileName)
- _FaceID = GetVal(val_FaceID)
- Font = InitFont(_FontFileName, _FaceID, _Fs, GetVal(val_Spacing), GetVal(val_SpaceScale), 0xFFFFFF, 0, 0)
- FontOut = InitFont(_FontFileName, _FaceID, _Fs, GetVal(val_Spacing), GetVal(val_SpaceScale), 0xFFFFFF, 4, 1)
- FontOut2 = InitFont(_FontFileName, _FaceID, _Fs, GetVal(val_Spacing), GetVal(val_SpaceScale), 0xFFFFFF, 2, 1)
- FontAll = InitFont(_FontFileName, _FaceID, _Fs, GetVal(val_Spacing), GetVal(val_SpaceScale), 0xFFFFFF, 4, 0)
- def tcaxPy_Fin():
- FinFont(Font)
- FinFont(FontOut)
- FinFont(FontOut2)
- FinFont(FontAll)
- # 用户修订版的tcaxPy_Main函数, 保留原始tcaxPy_Main风格是为了减少额外记忆量, 实际上该函数形式可以非常多样化
- def tcaxPy_Main_Fake(_i, _j, _n, _start, _end, _elapk, _k, _x, _y, _a, _txt, param):
- 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坐标
- # 文字主体
- PIX = TextPix(Font, _txt)
- PIX_t = pstGradient(PIX, 4, abs(PIX[0][0]), \
- PIX[1][1] - abs(PIX[0][1]) - PIX[1][1], \
- abs(PIX[0][0]) + PIX[1][0], \
- PIX[1][1] - abs(PIX[0][1]), \
- DecRGB('8080FF'), DecRGB('0000FF'), 0)
- # 边框主体
- PIX = TextPix(FontOut, _txt)
- PIX = PixColorRGB(PIX, DecRGB('000040'))
- PIX_o = pstBlur(PIX, 0, 6)
- # 边框
- PIX = TextPix(FontOut2, _txt)
- PIX = PixColorRGB(PIX, DecRGB('AAAAAA'))
- PIX_b = pstBlur(PIX, 2, 4)
- # 底色
- PIX = TextPix(FontAll, _txt)
- PIX = PixColorRGB(PIX, DecRGB('800080'))
- PIX_s = pstBlur(PIX, 0, 18)
- # 混合
- PIX = CombinePixs(PIX_s, PIX_o)
- PIX = CombinePixs(PIX, PIX_b)
- PIX = CombinePixs(PIX, PIX_t)
- # 增加效果
- PIX = pstBlind(PIX, 0, PIX[1][0], 40, DecRGB('000040'))
- ### 增加到 BIG_PIX 当中, BIG_PIX保存在param的第一个元素处, 关于BIG_PIX用法, 请看专门教程
- BigPixAdd(param[0], PIX, dx, dy, 0)
- # 一些时间的计算
- T0 = 10 * _start - 10 * _FD + 1 * _j * _FD
- T1 = T0 + 4 * _FD
- T2 = 10 * _end + 5 * _FD - 2 * (_n - _j - 1) * _FD
- T3 = T2 + _FD * 4
- # IN 进入方式
- tcas_keyframe(TCAS_BUF, PixBlur(PixColorMul(PIX, 1, 1, 1, 0.2), 10), PIX, T0, T1, dx, dy, 1, 0)
- # MAIN 存在方式
- tcas_main(TCAS_BUF, PIX, T1, T2, dx, dy, 0)
- # OUT 消失方式
- tcas_keyframe(TCAS_BUF, PIX, PixColorMul(PixBlur(PIX, 16), 1, 1, 1, 0), T2, T3, dx, dy, 1, 0)
- # EFT 表现方式
- PIX_0 = PIX
- num = int(ceil(_k * 10 / _FD))
- for i in range(num):
- T_s = 10 * (_start + _elapk) + i * _FD
- T_e = T_s + _FD
- PIX2 = PixResize(PIX_0, PIX_0[1][0] * 1.3, 0)
- dx2 = dx - PIX2[0][0] + PIX_0[0][0] - (PIX2[1][0] - PIX_0[1][0]) / 2
- dy2 = dy - PIX2[0][1] + PIX_0[0][1] - (PIX2[1][1] - PIX_0[1][1]) / 2
- if i % 2 == 0:
- PIX = pstSoftGlow(PIX2, 10, randint(160, 180), randint(140, 160))
- else:
- PIX = pstSoftGlow(PIX2, 10, randint(60, 80), randint(80, 100))
- tcas_main(TCAS_BUF, PIX, T_s, T_e, dx2, dy2, 3)
- ##### 将结果返回给tcax进行处理 #####
- return (ASS_BUF, TCAS_BUF)
- def tcaxPy_User():
- file_name = GetVal(val_OutFile) + '.tcas'
- fx_width = GetVal(val_ResolutionX)
- fx_height = GetVal(val_ResolutionY)
- fx_fps = GetVal(val_FXFPS)
- TCAS_FILE = CreateTcasFile(file_name, fx_width, fx_height, fx_fps)
- # basic metrics
- fontSize = GetVal(val_FontSize)
- marginX = GetVal(val_OffsetX)
- marginY = GetVal(val_OffsetY)
- spacing = GetVal(val_Spacing)
- lineNum = GetVal(val_nLines)
- textNum = GetVal(val_nTexts)
- start = GetVal(val_BegTime)
- end = GetVal(val_EndTime)
- kar = GetVal(val_KarTime)
- elapKar = GetVal(val_KarTimeDiff)
- text = GetVal(val_Text)
- textLength = GetVal(val_TextLength)
- advance = GetVal(val_TextAdvance)
- advDiff = GetVal(val_TextAdvanceDiff)
- # main loop
- for i in range(lineNum):
- initPosX = (fx_width - textLength[i]) / 2 + marginX # if marginX = 0, then it's just on the middle
- initPosY = marginY
- BIG_PIX = InitBigPix()
- for j in range(textNum[i]):
- if text[i][j] == '' or text[i][j] == ' ' or text[i][j] == ' ':
- continue
- posX = initPosX + advDiff[i][j] + advance[i][j] / 2
- posY = initPosY + fontSize / 2
- foo_bar = 0 # 实际上想传什么样的参数, 完全由我们自己决定, 数量也不受限制
- param = [BIG_PIX, foo_bar]
- ASS_BUF, TCAS_BUF = tcaxPy_Main_Fake(i, j, textNum[i], start[i], end[i], elapKar[i][j], kar[i][j], posX, posY, advance[i][j], text[i][j], param)
- WriteTcasFile(TCAS_FILE, TCAS_BUF)
- Progress(i, j)
- PIX_mask = ConvertBigPix(BIG_PIX)
- num = textNum[i] + 6
- PIX_i = ImagePix(abspath('flare3.png'), PIX_mask[1][0], PIX_mask[1][1])
- for ii in range(num):
- TCAS_BUF = []
- PIX = ((PIX_mask[0][0] + PIX_i[1][0] * (-0.5 + (ii + 1) / num), PIX_mask[0][1]), PIX_i[1], PIX_i[2])
- PIX = PixMask(PIX, PIX_mask)
- PIX = PixColorMul(PIX, 1, 1, 1, linearFactor(-0.5 + ii / num))
- tcas_main(TCAS_BUF, PIX, start[i] * 10 - 6 * _FD + ii * _FD, start[i] * 10 - 6 * _FD + (ii + 1) * _FD, 0, 0, 1)
- WriteTcasFile(TCAS_FILE, TCAS_BUF)
- #progress(ii + 1, num)
- PIX_i = ImagePix(abspath('flare1.png'), PIX_mask[1][0], PIX_mask[1][1])
- for ii in range(num):
- TCAS_BUF = []
- PIX = ((PIX_mask[0][0] + PIX_i[1][0] * (-0.5 + (ii + 1) / num), PIX_mask[0][1]), PIX_i[1], PIX_i[2])
- PIX = PixMask(PIX, PIX_mask)
- PIX = PixColorMul(PIX, 1, 1, 1, sqrFactor(-0.5 + ii / num))
- tcas_main(TCAS_BUF, PIX, start[i] * 10 - 6 * _FD + ii * _FD, start[i] * 10 - 6 * _FD + (ii + 1) * _FD, 0, 0, 1)
- WriteTcasFile(TCAS_FILE, TCAS_BUF)
- #progress(ii + 1, num)
- FinTcasFile(TCAS_FILE)
- def sqrFactor(x):
- return -4 * (x - 0.5) * (x + 0.5)
- def linearFactor(x):
- if x < 0:
- return 2 * x + 1
- else:
- return -2 * x + 1
复制代码 |
-
2
查看全部评分
-
|