- UID
- 2546
- 积分
- 159
- 帖子
- 30
- 主题
- 5
- 论坛币
- 868
- 威望
- 0
- EP值
- 134
- MP值
- 0
- 阅读权限
- 50
- 注册时间
- 2015-5-9
- 在线时间
- 52 小时
- 最后登录
- 2024-10-20
|
本帖最后由 Seekladoom 于 2022-1-28 23:46 编辑
相关链接:
自定义特效编写模板tcaxPy_User函数用法例子
[SAI]034_hyoukaOP2
TCAX 淡入淡出效果的两种写法格式(Main+User).rar
(0 Bytes, 下载次数: 2415)
注:以下两种写法最终生成的ASS字幕文件完全一致,发出来的主要目的有以下几点:
1.方便对比基础字幕文本写法的差异
2.寻找简化TCAX代码写法的方法
main格式- from tcaxPy import *
- def tcaxPy_Init():
- pass
- def tcaxPy_Main(_i, _j, _n, _BT, _ET, _SK, _KT, _X, _Y, _A, _TXT):
- ASS_BUF = [] # 保存ASS特效
- DY = _Y - 13
- ass_main(ASS_BUF, SubL(_BT, _ET, 0),pos(_X,DY)+fad(200,200), _TXT)
-
- return (ASS_BUF,None)
复制代码
user格式
- from tcaxPy import *
- def tcaxPy_Init():
- global resX # horizontal resolution
- global resY # vertical resolution
- global marginX # horizontal margin
- global marginY # vertical margin
- global lineNum # number of lines
- global textNum # textNum[i], number of texts in ith line
- global _BT # _BT[i], start time of a line
- global _ET # _ET[i], end time of a line
- global _TXT # _TXT[i][j], as name implies
- global _L # _L[i], total width of a line
- global _A # _A[i][j], advance of a text, usually larger than width
- global _AD # _AD[i][j], distance between the current text to the first text of the line
- resX = GetVal(val_ResolutionX)
- resY = GetVal(val_ResolutionY)
- marginX = GetVal(val_OffsetX)
- marginY = GetVal(val_OffsetY)
- lineNum = GetVal(val_nLines)
- textNum = GetVal(val_nTexts)
- _BT = GetVal(val_BegTime)
- _ET = GetVal(val_EndTime)
- _TXT = GetVal(val_Text)
- _L = GetVal(val_TextLength)
- _A = GetVal(val_TextAdvance)
- _AD = GetVal(val_TextAdvanceDiff)
- def tcaxPy_User():
- ASS_BUF = []
- file_name = GetVal(val_OutFile) + '.ass'
- ass_header = GetVal(val_AssHeader)
- ASS_FILE = CreateAssFile(file_name, ass_header)
- for i in range(lineNum):
- initPosX = marginX + (resX - _L[i]) / 2 # an 7, 4, 1
- initPosY = marginY # an 7, 8, 9
- for j in range(textNum[i]):
- if _TXT[i][j] == '' or _TXT[i][j] == ' ' or _TXT[i][j] == ' ':
- continue
- # an 2
- DX = initPosX + _AD[i][j] + _A[i][j] / 2
- DY = initPosY + resY - 39
- ass_main(ASS_BUF, SubL(_BT[i], _ET[i],0),pos(DX,DY)+fad(200,200), _TXT[i][j])
- WriteAssFile(ASS_FILE, ASS_BUF) # write the buffer in memory to the file
- Progress(i,j)
- FinAssFile(ASS_FILE)
复制代码 |
|