- UID
- 2
- 积分
- 8682
- 帖子
- 2905
- 主题
- 199
- 论坛币
- 11566
- 威望
- 16
- EP值
- 2349
- MP值
- 15
- 阅读权限
- 200
- 注册时间
- 2011-8-3
- 在线时间
- 2597 小时
- 最后登录
- 2024-8-28
![Rank: 7](static/image/common/star_level3.gif) ![Rank: 7](static/image/common/star_level2.gif) ![Rank: 7](static/image/common/star_level1.gif)
|
说明: 修改自 Mirael 发我的Lua脚本.
wobble_text.rar
(2.67 KB, 下载次数: 2996)
- from tcaxPy import *
- from util.cairo import *
- def tcaxPy_Init():
- global _Fs
- global _FD # 一帧的持续时间, 约40毫秒
- global _Spacing # 字体间距
- global Font # 首要字体
- _Fs = GetVal(val_FontSize)
- _FD = 1000 / GetVal(val_FXFPS)
- _FontFileName = GetVal(val_FontFileName)
- _FaceID = GetVal(val_FaceID)
- _Spacing = GetVal(val_Spacing)
- Font = InitFont(_FontFileName, _FaceID, _Fs, _Spacing, GetVal(val_SpaceScale), MakeRGB(255, 255, 255), 0, False)
- # cairo
- global ctx
- fx_width = GetVal(val_ResolutionX)
- fx_height = GetVal(val_ResolutionY)
- surface = ImageSurface(FORMAT_ARGB32, fx_width, fx_height)
- ctx = Context(surface)
- def tcaxPy_Fin():
- FinFont(Font)
- def tcaxPy_Main(_i, _j, _n, _start, _end, _elapk, _k, _x, _y, _a, _txt):
- ASS_BUF = [] # 保存ASS特效
- TCAS_BUF = [] # 保存TCAS特效
- ##### 主要特效编写操作 #####
- ### begin of line scope, do not change the code ###
- lineChanged = IsLineChanged(_i)
- if lineChanged:
- _initX = _x - int((_a + _Spacing) / 2 + 0.5)
- _initY = _y - int(_Fs / 2 + 0.5)
- _length = GetVal(val_TextLength)[_i]
- tcaxPy_Line(_i, _start, _end, _initX, _initY, _length, ASS_BUF, TCAS_BUF)
- ### end of line scope, do not change the code ###
- ##### 将结果返回给tcax进行处理 #####
- return (ASS_BUF, TCAS_BUF)
- def tcaxPy_Line(_i, _start, _end, _initX, _initY, _length, ASS_BUF, TCAS_BUF):
- texts = GetVal(val_Text)[_i]
- num = len(texts)
- frames = int(2000 / _FD + 0.5)
- for i in range(frames):
- ts = _end + i * _FD / 10
- te = _end + (i + 1) * _FD / 10
- frame_pct = i / frames
- text = ''
- for j in range(num):
- if '' == texts[j] or ' ' == texts[j] or ' ' == texts[j]:
- continue
- assDraw = TextOutlineDraw(Font, texts[j], 0, 0)
- AssDraw(ctx, assDraw)
- dx = _initX + GetVal(val_TextAdvanceDiff)[_i][j]
- path_trans(ctx, wobble_filter, (dx, _initX, _length, _Fs, frame_pct))
- text += ToAssDraw(ctx)
- EFT = an(7) + pos(_initX, _initY) + alpha(255 * frame_pct) + blur(3) + bord(1) + color1('FFFFFF') + p(7)
- ass_main(ASS_BUF, SubL(ts, te), EFT, text)
- def wobble_filter(x, y, param):
- char_left, line_left, line_width, line_height, frame_pct = param
- char_x = ceil(x + char_left * 64 - line_left * 64)
- max_diff_x = sin(y / line_height * pi / 10 + frame_pct * pi * 5) * 20 * 64
- max_diff_y = cos(char_x / line_width * pi / 10 + frame_pct * pi * 5) * 20 * 64
- new_x = char_x + floor(max_diff_y * frame_pct)
- new_y = y + floor(max_diff_y * frame_pct)
- return new_x, new_y
复制代码 |
|