- UID
- 2
- 积分
- 8682
- 帖子
- 2905
- 主题
- 199
- 论坛币
- 11740
- 威望
- 16
- EP值
- 2349
- MP值
- 15
- 阅读权限
- 200
- 注册时间
- 2011-8-3
- 在线时间
- 2597 小时
- 最后登录
- 2024-8-28
|
完整工程下载(注意, 请直接用浏览器下载):
游客,本帖隐藏的内容需要积分高于 10 才可浏览,您当前积分为 0 - from tcaxPy import *
- from util.gdiFont import *
- from util.tcCurve import *
- from util.cairo import *
- from pixLibs.ImageStone import *
- def tcaxPy_Init():
- global _Fs
- global _FD # 一帧的持续时间, 约40毫秒
- global Font # 首要字体
- global FontOut # 字体边框
- global FontShad # 加粗字体
- global GdiFontThin
- global GdiFontThin2
- _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), MakeRGB(0, 0, 0), 0, False)
- FontOut = InitFont(_FontFileName, _FaceID, _Fs, GetVal(val_Spacing), GetVal(val_SpaceScale), MakeRGB(0, 0, 0), 2, True)
- FontShad = InitFont(_FontFileName, _FaceID, _Fs, GetVal(val_Spacing), GetVal(val_SpaceScale), MakeRGB(0, 0, 0), 4, False)
- GdiFontThin = gfInitFont(GetVal(val_FontFaceName), _Fs, GetVal(val_Spacing), GetVal(val_SpaceScale), -3, False)
- GdiFontThin2 = gfInitFont(GetVal(val_FontFaceName), _Fs, GetVal(val_Spacing), GetVal(val_SpaceScale), -2, False)
- # cairo
- global surface
- global ctx
- fx_width = GetVal(val_ResolutionX)
- fx_height = GetVal(val_ResolutionY)
- width = fx_width
- height = fx_height
- surface = ImageSurface(FORMAT_ARGB32, width, height)
- ctx = Context(surface)
- def tcaxPy_Fin():
- FinFont(Font)
- FinFont(FontOut)
- FinFont(FontShad)
- gfFinFont(GdiFontThin)
- gfFinFont(GdiFontThin2)
- #sys.exit() # 自动关闭执行窗口 auto close the window
- def tcaxPy_Main(_i, _j, _n, _start, _end, _elapk, _k, _x, _y, _a, _txt):
- ASS_BUF = [] # 保存ASS特效
- TCAS_BUF = [] # 保存TCAS特效
- ##### 主要特效编写操作 ####
- dx = _x - int((_a + GetVal(val_Spacing)) / 2 + 0.5) # 一个固定操作, 将an5的坐标转换为an7
- dy = _y - int(_Fs / 2 + 0.5) # ASS特效默认采用an5坐标, TCAS特效则采用an7坐标
- # 文字主体
- PIX = TextPix(Font, _txt)
- PIX_t0 = PixColorRGB(PIX, DecRGB('FFFFFF')) # 未增加内部填充
- if _txt == '/' or _txt == '「' or _txt == '」':
- PIX = PixFromPoints(gfGetPoints(GdiFontThin2, _txt))
- PIX = PixColorRGB(PIX, DecRGB('002200'))
- PIX_thin = PixBlur(PIX, 2) # 内部填充
- PIX_t = CombinePixs(PIX_t0, PIX_thin) # 增加了内部填充的主体
- else:
- PIX = PixFromPoints(gfGetPoints(GdiFontThin, _txt))
- PIX = PixColorRGB(PIX, DecRGB('002200'))
- PIX_thin = PixBlur(PIX, 4) # 内部填充
- PIX_t = CombinePixs(PIX_t0, PIX_thin) # 增加了内部填充的主体
- # 边框
- PIX = TextPix(FontOut, _txt)
- PIX = PixColorRGB(PIX, DecRGB('FFFFFF'))
- PIX_o = PixBlur(PIX, 6)
- # 底色
- PIX = TextPix(FontShad, _txt)
- PIX = PixColorRGB(PIX, DecRGB('0042CA'))
- PIX_s = PixBlur(PIX, 8)
- # 混合
- PIX = CombinePixs(PIX_s, PIX_o)
- PIX_0 = CombinePixs(PIX, PIX_t0)
- PIX_1 = CombinePixs(PIX, PIX_t)
- # 一些时间的计算
- T0 = 10 * _start - 12 * _FD + 1 * _j * _FD
- T1 = T0 + 4 * _FD
- T2 = 10 * _end + 4 * _FD - 1 * (_n - _j - 1) * _FD
- T3 = T2 + 8 * _FD
- # IN 入场方式
- xv = [w for w in range(6, PIX_1[1][0], 6)]
- yv = [h for h in range(6, PIX_1[1][1], 6)]
- PIX_list = PixSubClips(PIX_1, xv, yv)
- pix_num = len(PIX_list)
- P = []
- pix_num = len(PIX_list)
- for i in range(pix_num):
- if i % 2 == 0:
- pt0 = (dx + 10, dy - 5)
- pt1 = (dx, dy)
- else:
- pt0 = (dx + 10, dy + 5)
- pt1 = (dx, dy)
- P.append((pt0, pt1))
- num = 10
- for i in range(num):
- for j in range(pix_num):
- ts0 = T0 + i * _FD
- te0 = ts0 + _FD
- x, y, a = LinearBezier(P[j][0], P[j][1], (i + 1) / num)
- PIX = PixResizeF(PIX_list[j], PIX_list[j][1][0] * (i + 1) / num, 0)
- if num - i - 1 > 0:
- PIX = PixBlur(PIX, 2 * (num - i - 1))
- PIX = BilinearFilter(PIX, x, y)
- tcas_main(TCAS_BUF, PIX, ts0, te0, x, y, 0)
- # MAIN 存在方式 part1
- ts1 = te0
- te1 = 10 * (_start + _elapk)
- tcas_main(TCAS_BUF, PIX_1, ts1, te1, dx, dy, 0)
- # EFT 表现方式 MAIN 存在方式 part2
- ts2 = te1
- te2 = T2
- PIX = pstSoftGlow(PIX_1, 10, 100, 120)
- tcas_keyframe(TCAS_BUF, PIX, PIX_1, ts2, te2, dx, dy, 1, 0)
- # EXT 附加效果
- points = PixPoints(PIX_thin)
- pt_num = len(points)
- dx0 = dx + PIX_thin[0][0]
- dy0 = dy + PIX_thin[0][1]
- num = int((te2 - te1) / _FD + 0.5)
- for i in range(num): # 逐帧绘制
- ts = te1 + _FD * i
- te = ts + _FD
- for j in range(pt_num):
- ctx.save()
- y = dy0 + points[j][1]
- if y < _y:
- ag = (y - _y - 5) / PIX_thin[1][1] * pi / 4
- else:
- ag = (y - _y + 5) / PIX_thin[1][1] * pi / 4
- ctx.translate(dx0 + points[j][0], dy0 + points[j][1])
- ctx.scale(1/8, 1/8)
- AssDraw(ctx, DrawLight2(160))
- path_trans(ctx, ca_frz, -ag)
- path_trans(ctx, ca_fry, pi * i / num)
- ctx.set_source_rgba(0xFF/0xFF, 0x88/0xFF, 0x68/0xFF, 0x0A/0xFF)
- ctx.fill()
- AssDraw(ctx, DrawLight3(40))
- path_trans(ctx, ca_frz, -ag)
- path_trans(ctx, ca_fry, pi * i / num)
- ctx.set_source_rgba(1, 1, 1, 0.2)
- ctx.fill()
- ctx.restore()
- PIX = surface.get_pix() # 获取图案
- surface_clear(ctx) # 清空画布
- PIX = PixStrip(PIX) # 裁剪空白边框提升后续操作效率
- PIX = PixBlur(PIX, 1) # 模糊效果
- if i > num - 5:
- PIX = PixColorMul(PIX, 1, 1, 1, (num - i) / 5)
- tcas_main(TCAS_BUF, PIX, ts, te, 0, 0, 1)
- progress(i + 1, num)
- # OUT 出场方式
- P = []
- pix_num = len(PIX_list)
- for i in range(pix_num):
- if i % 2 == 0:
- pt0 = (dx, dy)
- pt1 = (dx - 10, dy + 5)
- else:
- pt0 = (dx, dy)
- pt1 = (dx - 10, dy - 5)
- P.append((pt0, pt1))
- num = 10
- for i in range(num):
- for j in range(pix_num):
- ts3 = te2 + i * _FD
- te3 = ts3 + _FD
- x, y, a = LinearBezier(P[j][0], P[j][1], i / num)
- PIX = PixResizeF(PIX_list[j], PIX_list[j][1][0] * (num - i) / num, 0)
- if i > 0:
- PIX = PixBlur(PIX, 2 * i)
- PIX = BilinearFilter(PIX, x, y)
- tcas_main(TCAS_BUF, PIX, ts3, te3, x, y, 0)
- ##### 将结果返回给tcax进行处理 #####
- return (ASS_BUF, TCAS_BUF)
- # 辅助函数
- def PixSubClips(PIX, xv, yv):
- PIX_list = []
- xv = list(xv)
- yv = list(yv)
- xv.append(PIX[1][0])
- yv.append(PIX[1][1])
- xv.sort()
- yv.sort()
- xn = len(xv)
- yn = len(yv)
- y_off = 0
- for j in range(yn):
- x_off = 0
- for i in range(xn):
- PIX_sub_pos = (PIX[0][0] + x_off, PIX[0][1] + y_off)
- PIX_sub_res = (xv[i] - x_off, yv[j] - y_off)
- PIX_sub_rgba = []
- for h in range(PIX_sub_res[1]):
- for w in range(PIX_sub_res[0]):
- idx = 4 * ((h + y_off) * PIX[1][0] + w + x_off)
- PIX_sub_rgba.append(PIX[2][idx])
- PIX_sub_rgba.append(PIX[2][idx + 1])
- PIX_sub_rgba.append(PIX[2][idx + 2])
- PIX_sub_rgba.append(PIX[2][idx + 3])
- PIX_list.append((PIX_sub_pos, PIX_sub_res, tuple(PIX_sub_rgba)))
- x_off = xv[i]
- y_off = yv[j]
- return PIX_list
- def DrawLight2(l):
- return 'm 0 0 l -{length} 0 0 8 c'.format(length = int(l * 8))
- def DrawLight3(l):
- return 'm 0 0 l -{length} 0 0 4 c'.format(length = int(l * 8))
复制代码 |
-
2
查看全部评分
-
|