- UID
- 2
- 积分
- 8682
- 帖子
- 2905
- 主题
- 199
- 论坛币
- 11740
- 威望
- 16
- EP值
- 2349
- MP值
- 15
- 阅读权限
- 200
- 注册时间
- 2011-8-3
- 在线时间
- 2597 小时
- 最后登录
- 2024-8-28
|
引言: 以下这些约束的意义在于保证该脚本能被作为内置特效脚本正常使用, 其中基本约束是必须遵守的, 它保证脚本能够被正常执行, 高级约束是用来保证不同类型特效之间切换时, 时间及空间上的连贯性, 附加约束则是让内置脚本更具可用性.
参考: 内置特效类型说明, 内置特效效果说明
基本约束
实现接口(或者说定义函数) tcaxPy_Init (可以为空函数), tcaxPy_Fin (可以为空函数), 以及 tcaxPy_Main
高级约束
1. 在IN, MAIN, OUT类型脚本中定义变量 time_gap, time_fac 并赋值为一个小整数, 推荐为1或2. 通常在 tcaxPy_Main 函数之前(外部)声明.
2. 特效的开始及结束时间遵循以下公式, 其中ts表示起始时间, te表示结束时间, _FD为一帧的长度, 由公式_FD = 1000 / GetVal(val_FXFPS)计算而得, 通常在tcaxPy_Init函数中将其声明为全局变量, duration为效果持续的时间, 其它变量均为tcaxPy_Main函数自带的参数, 关于其具体含义可参考tcaxPy 脚本模板详解, 实例教程中有中文解释.
a) IN 歌词的进入方式 (Introduction Effect)
ts = _start + _j * time_fac * _FD / 10 - time_gap * _FD / 10 - duration
te = _start + _j * time_fac * _FD / 10 - time_gap * _FD / 10
b) MAIN 歌词的存在方式 (Existence Effect)
ts = _start + _j * time_fac * _FD / 10 - time_gap * _FD / 10
te = _end - (_n - _j - 1) * time_fac * _FD / 10 + time_gap * _FD / 10
c) EFT 卡拉OK的表现方式 (Highlight Effect)
无严格标准, 以下公式仅作参考:
ts = _start + _elapk
te = _start + _elapk + _k
d) OUT 歌词的消失方式 (Disappearance Effect)
ts = _end - (_n - _j - 1) * time_fac * _FD / 10 + time_gap * _FD / 10
te = _end - (_n - _j - 1) * time_fac * _FD / 10 + time_gap * _FD / 10 + duration
e) EXT 附加效果 (Extra Effect)
无严格标准, 请依需要设置
3. 对于坐标计算, 请使用_x, _y, 保证效果切换处的连续性即可.
附加约束
1. 脚本命名约束:通常我们将内置特效分成6种类型 (参考帖子: http://www.tcax.org/forum.php?mod=viewthread&tid=41), 并统一放置在
TCAX程序根目录\scripts\特效类型, 如 C:\Program Files\tcax\scripts\IN
文件夹下, 脚本文件命名规范为
特效类型_xxx.py, 如 in_001.py
其中x表示0到9的自然数.
在TCC文件中, 对于py脚本文件路径来说, 前面加个 ! (感叹号) 表示从程序根目录下去寻找指定的脚本, 如, 可设置 < py file = !\scripts\IN\in_001.py >, 在接下来的版本中, 可以简单使用 !in_001.py 来代替 !\scripts\IN\in_001.py.
2. 多利用TCC文件提供的常量, 比如颜色, 字体大小, 边框厚度等. 一般我们编写普通特效脚本时, 都习惯直接在脚本中写入常量, 比如 color1('FF0000'), t(0, 300, fs(60)), 等, 因为这些量我们改起来很轻松, 但对于直接使用内置特效脚本的用户来说, 这些量都是透明的(即, 不可见的), 他们比较容易修改的是TCC文件中的值, 所以, 如果我们在写内置特效脚本时, 用 color1(_1C), 其中 _1C = GetVal(val_1C), t(0, 300, fs(_Fs + 20)), 或 t(0, 300, fs(1.5 * _Fs)), 其中 _Fs = GetVal(val_FontSize), 那么该脚本的灵活性(对于脚本用户来讲)就要更高一些. 同样的例子还有很多, 需要编写者在实践中去发现.
脚本实例
以下脚本在结构上相似性是很高的, 对于同一种类型的特效来说更是如此. 通常只需要做少量的修改就能使产生的效果有所变化. 另外, 可以在新版本的TCAX中找到更多的内置特效脚本(全部都是开源的, 存放路径在程序根目录的scripts文件夹下)
in_001.py- ################################################################################
- ### description:
- ### fade in
- from tcaxPy import *
- def tcaxPy_Init():
- global _FD # frame duration, in millisecond
- global _Blur
- _FD = 1000 / GetVal(val_FXFPS)
- _Blur = GetVal(val_Blur)
- def tcaxPy_Fin():
- pass
- time_gap = 1 # you can change this value to 0, or 2 or any other number
- time_fac = 1 # you can change this value to 0, or 2 or any other number
- def tcaxPy_Main(_i, _j, _n, _start, _end, _elapk, _k, _x, _y, _a, _txt):
- ASS_BUF = [] # used for saving ASS FX lines
- TCAS_BUF = [] # used for saving TCAS FX raw data
- duration = 10 * _FD # effect duration, in millisecond
- ts = _start + _j * time_fac * _FD / 10 - time_gap * _FD / 10 - duration / 10 # start time, in semi-second
- te = _start + _j * time_fac * _FD / 10 - time_gap * _FD / 10 # end time, in semi-second
- EFT = pos(_x, _y) + fad(duration, 0) # ASS events
- if _Blur > 0:
- EFT += blur(_Blur)
- ass_main(ASS_BUF, SubL(ts, te), EFT, _txt) # store the effect
- return (ASS_BUF, TCAS_BUF)
复制代码 main_001.py- ################################################################################
- ### description:
- ### normal
- from tcaxPy import *
- def tcaxPy_Init():
- global _FD # frame duration, in millisecond
- global _Blur
- _FD = 1000 / GetVal(val_FXFPS)
- _Blur = GetVal(val_Blur)
- def tcaxPy_Fin():
- pass
- time_gap = 1 # you can change this value to 0, or 2 or any other number
- time_fac = 1 # you can change this value to 0, or 2 or any other number
- def tcaxPy_Main(_i, _j, _n, _start, _end, _elapk, _k, _x, _y, _a, _txt):
- ASS_BUF = [] # used for saving ASS FX lines
- TCAS_BUF = [] # used for saving TCAS FX raw data
- ts = _start + _j * time_fac * _FD / 10 - time_gap * _FD / 10 # start time, in semi-second
- te = _end - (_n - _j - 1) * time_fac * _FD / 10 + time_gap * _FD / 10 # end time, in semi-second
- EFT = pos(_x, _y) # ASS events
- if _Blur > 0:
- EFT += blur(_Blur)
- ass_main(ASS_BUF, SubL(ts, te, 5), EFT, _txt) # store the effect
- return (ASS_BUF, TCAS_BUF)
复制代码 eft_001.py- ################################################################################
- ### description:
- ### normal karaoke
- from tcaxPy import *
- def tcaxPy_Init():
- global _FD # frame duration, in millisecond
- global _Blur
- _FD = 1000 / GetVal(val_FXFPS)
- _Blur = GetVal(val_Blur)
- def tcaxPy_Fin():
- pass
- def tcaxPy_Main(_i, _j, _n, _start, _end, _elapk, _k, _x, _y, _a, _txt):
- ASS_BUF = [] # used for saving ASS FX lines
- TCAS_BUF = [] # used for saving TCAS FX raw data
- ts = _start + _elapk # start time, in semi-second
- te = _start + _elapk + _k # end time, in semi-second
- EFT = pos(_x, _y) + K(_k) # ASS events
- if _Blur > 0:
- EFT += blur(_Blur)
- ass_main(ASS_BUF, SubL(ts, te, 10), EFT, _txt) # store the effect
- return (ASS_BUF, TCAS_BUF)
复制代码 out_001.py- ################################################################################
- ### description:
- ### fade out
- from tcaxPy import *
- def tcaxPy_Init():
- global _FD # frame duration, in millisecond
- global _Blur
- _FD = 1000 / GetVal(val_FXFPS)
- _Blur = GetVal(val_Blur)
- def tcaxPy_Fin():
- pass
- time_gap = 1 # you can change this value to 0, or 2 or any other number
- time_fac = 1 # you can change this value to 0, or 2 or any other number
- def tcaxPy_Main(_i, _j, _n, _start, _end, _elapk, _k, _x, _y, _a, _txt):
- ASS_BUF = [] # used for saving ASS FX lines
- TCAS_BUF = [] # used for saving TCAS FX raw data
- duration = 10 * _FD # effect duration, in millisecond
- ts = _end - (_n - _j - 1) * time_fac * _FD / 10 + time_gap * _FD / 10 # start time, in semi-second
- te = _end - (_n - _j - 1) * time_fac * _FD / 10 + time_gap * _FD / 10 + duration / 10 # end time, in semi-second
- EFT = pos(_x, _y) + fad(0, duration) # ASS events
- if _Blur > 0:
- EFT += blur(_Blur)
- ass_main(ASS_BUF, SubL(ts, te), EFT, _txt) # store the effect
- return (ASS_BUF, TCAS_BUF)
复制代码 ext_001.py- ################################################################################
- ### description:
- ### shining stars
- from tcaxPy import *
- def tcaxPy_Init():
- global _FD # frame duration, in millisecond
- global _Fs
- global _KarTime
- _FD = 1000 / GetVal(val_FXFPS)
- _Fs = GetVal(val_FontSize)
- _KarTime = GetVal(val_KarTime)
- def tcaxPy_Fin():
- pass
- def tcaxPy_Main(_i, _j, _n, _start, _end, _elapk, _k, _x, _y, _a, _txt):
- ASS_BUF = [] # used for saving ASS FX lines
- TCAS_BUF = [] # used for saving TCAS FX raw data
- CLR = ('FFFFFF', 'DDDDDD', '3CCEFF')
- if _j == 0 or _j == _n - 1:
- fac = 2
- else:
- fac = 4
- num = _k * fac
- for i in range(num):
- if 0 < _j and _j < _n - 1:
- rnd = randint(-int(_KarTime[_i][_j - 1] / 2), _k + int(_KarTime[_i][_j + 1] / 2))
- else:
- rnd = randint(0, _k)
- ts = _start + _elapk + rnd
- te = _start + _elapk + rnd + randint(int(2 * _FD / 10), int(4 * _FD / 10))
- POS = pos(_x + randint(-int(_a / 2) + 4, int(_a / 2) - 4), _y + randint(-int(_Fs / 2) + 6, int(_Fs / 2) - 6))
- EFT = fn('Arial') + fs(10) + bord(0) + fsc(randint(40, 80), randint(40, 80)) + color(CLR[randint(0, 2)])
- ass_main(ASS_BUF, SubL(ts, te, 15), POS + EFT, '★')
- return (ASS_BUF, TCAS_BUF)
复制代码 |
|