完整工程下载(注意, 请直接用浏览器下载):
游客,本帖隐藏的内容需要积分高于 10 才可浏览,您当前积分为 0 - from tcaxPy import *
- from util.gdiFont import *
- from util.tcCurve import *
- from util.magick import *
- from pixLibs.ImageStone import *
- def tcaxPy_Init():
- global _Fs
- global _FD # 一帧的持续时间, 约40毫秒
- global Font # 首要字体
- global FontOut # 字体边框
- global FontShad # 加粗字体
- global GdiFontThin
- _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.5, False)
- # 辅助变量
- global g_flags
- g_flags = [0, 0]
- def tcaxPy_Fin():
- FinFont(Font)
- FinFont(FontOut)
- FinFont(FontShad)
- gfFinFont(GdiFontThin)
- #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')) # 未增加内部填充
- PIX = PixFromPoints(gfGetPoints(GdiFontThin, _txt))
- PIX = PixColorRGB(PIX, DecRGB('000000'))
- PIX_thin = PixBlur(PIX, 4) # 内部填充
- PIX_t = CombinePixs(PIX_t0, PIX_thin) # 增加了内部填充的主体
- # 边框
- PIX = TextPix(FontOut, _txt)
- PIX = PixColorRGB(PIX, DecRGB('00CC00'))
- PIX_o = PixBlur(PIX, 6)
- # 底色
- PIX = TextPix(FontShad, _txt)
- PIX = PixColorRGB(PIX, DecRGB('880088'))
- PIX_s = PixBlur(PIX, 8)
- # 混合
- PIX = CombinePixs(PIX_s, PIX_o)
- PIX_0 = CombinePixs(PIX, PIX_t0)
- PIX_1 = CombinePixs(PIX, PIX_t)
- # part1
- if _i < 4:
- # 一些时间的计算
- T0 = 10 * _start - 12 * _FD + 2 * _j * _FD
- T1 = T0 + 4 * _FD
- T2 = 10 * _end + 4 * _FD - 2 * (_n - _j - 1) * _FD
- T3 = T2 + 8 * _FD
- # IN 入场方式
- if 0 == g_flags[0]:
- P = ((dx + 300, dy), (dx + 240, dy - 40), (dx + 60, dy - 40), (dx, dy))
- g_flags[0] = 1
- else:
- P = ((dx + 300, dy), (dx + 240, dy + 40), (dx + 60, dy + 40), (dx, dy))
- g_flags[0] = 0
- num = 10
- for i in range(num):
- x, y, a = CubicBezier(P[0], P[1], P[2], P[3], i / num)
- ts0 = T0 + i * _FD
- te0 = ts0 + _FD
- PIX = PixColorMul(PIX_1, 1, 1, 1, (i + 1) / num)
- 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 表现方式
- if _k > 100:
- _k = 100
- num = int(10 * _k / _FD + 0.5)
- for i in range(num):
- ts = te1 + _FD * i
- te = ts + _FD
- PIX = pstBlur(PIX_1, 2, (i + 1) * 4)
- PIX = PixResizeF(PIX, PIX[1][0] + 12 * (i + 1), 0) # * (1 + 0.08 * (i + 1))
- PIX = BilinearFilter(PIX, dx, dy)
- tcas_main(TCAS_BUF, PIX, ts, te, dx, dy, 1)
- if _i == 3:
- # MAIN 存在方式 part2
- ts2 = te
- te2 = T2 + 2 * (_n - _j - 1) * _FD + randint(-(_n - _j - 1), 1) * _FD
- tcas_main(TCAS_BUF, PIX_1, ts2, te2, dx, dy, 0)
- # OUT 出场方式
- num = 8
- for i in range(num):
- ts3 = te2 + i * _FD
- te3 = ts3 + _FD
- PIX = PixBlur(PIX_1, (i + 1) * 6)
- PIX = PixResize(PIX, PIX_1[1][0], PIX[1][1] * (1 + i / num))
- PIX = PixColorMul(PIX, 1, 1, 1, (num - i) / num)
- tcas_main(TCAS_BUF, PIX, ts3, te3, dx, dy, 0)
- # EXT 附加方式
- if _j == _n - 2:
- num = 69
- for i in range(num):
- ts4 = 10 * (_start + _elapk) + i * _FD
- te4 = ts4 + _FD
- img_path = MakePath(2, i + 1, 'images', 'list', 'img', '.png', 'sys')
- PIX = ImagePix(abspath(img_path))
- if i > num - 5:
- PIX = PixColorMul(PIX, 1, 1, 1, (num - i) / 5)
- tcas_main(TCAS_BUF, PIX, ts4, te4, _x - PIX[1][0] / 2, _y - PIX[1][1] / 2, 2)
- else:
- # MAIN 存在方式 part2
- ts2 = te
- te2 = T2
- tcas_main(TCAS_BUF, PIX_1, ts2, te2, dx, dy, 0)
- # OUT 出场方式
- if 0 == g_flags[1]:
- P = ((dx, dy), (dx - 60, dy + 40), (dx - 240, dy + 40), (dx - 300, dy))
- g_flags[1] = 1
- else:
- P = ((dx, dy), (dx - 60, dy - 40), (dx - 240, dy - 40), (dx - 300, dy))
- g_flags[1] = 0
- num = 10
- for i in range(num):
- x, y, a = CubicBezier(P[0], P[1], P[2], P[3], i / num)
- ts3 = te2 + i * _FD
- te3 = ts3 + _FD
- PIX = PixColorMul(PIX_1, 1, 1, 1, (num - i) / num)
- tcas_main(TCAS_BUF, PIX, ts3, te3, x, y, 0)
- # part2
- elif _i < 8:
- # 一些时间的计算
- T0 = 10 * _start - 8 * _FD
- T1 = T0 + 8 * _FD
- T2 = 10 * _end
- T3 = T2 + 8 * _FD
- # IN 入场方式
- ts0 = T0
- te0 = ts0 + 8 * _FD
- tcas_keyframe(TCAS_BUF, PixColorMul(PIX_1, 1, 1, 1, 0), PIX_1, ts0, te0, dx, dy, 1, 1)
- # MAIN 存在方式 part1
- ts1 = te0
- te1 = 10 * (_start + _elapk)
- tcas_main(TCAS_BUF, PIX_1, ts1, te1, dx, dy, 0)
- # EFT 表现方式
- num = int(10 * _k / _FD + 0.5)
- for i in range(num):
- ts = te1 + _FD * i
- te = ts + _FD
- if i % 2 == 0:
- PIX = pstBlur(PIX_1, 2, 24 + 1.2 * (i + 1))
- PIX = PixResizeF(PIX, PIX[1][0] * (1.3 + 0.3 * (i + 1) / num), 0)
- PIX = BilinearFilter(PIX, dx, dy)
- else:
- PIX = PIX_1
- tcas_main(TCAS_BUF, PIX, ts, te, dx, dy, 1)
- # MAIN 存在方式 part2
- ts2 = te
- te2 = T2
- tcas_main(TCAS_BUF, PIX_1, ts2, te2, dx, dy, 0)
- # OUT 出场方式
- ts3 = T2
- te3 = ts3 + 6 * _FD
- tcas_keyframe(TCAS_BUF, PIX_1, PixColorMul(PIX_1, 1, 1, 1, 0), ts3, te3, dx, dy, 1, 0)
- # part3
- elif _i < 12:
- # 一些时间的计算
- T0 = 10 * _start - 8 * _FD + 1 * _j * _FD
- T1 = T0 + 4 * _FD
- T2 = 10 * _end + 4 * _FD - 1 * (_n - _j - 1) * _FD
- T3 = T2 + 8 * _FD
- # IN 入场方式
- if 0 == g_flags[0]:
- P = ((dx, dy + 100), (dx, dy))
- g_flags[0] = 1
- else:
- P = ((dx, dy - 100), (dx, dy))
- g_flags[0] = 0
- num = 6
- for i in range(num):
- x, y, a = LinearBezier(P[0], P[1], i / num)
- ts0 = T0 + i * _FD
- te0 = ts0 + _FD
- PIX = PixColorMul(PIX_1, 1, 1, 1, (i + 1) / num)
- 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 表现方式
- num = int(10 * _k / _FD + 0.5)
- for i in range(num):
- ts = te1 + _FD * i
- te = ts + _FD
- if i % 2 == 0:
- PIX = pstBlur(PIX_1, 2, 24 + 1.2 * (i + 1))
- PIX = PixResizeF(PIX, PIX[1][0] * (1.3 + 0.3 * (i + 1) / num), 0)
- PIX = BilinearFilter(PIX, dx, dy)
- else:
- PIX = PIX_1
- tcas_main(TCAS_BUF, PIX, ts, te, dx, dy, 1)
- if _i == 11:
- # MAIN 存在方式 part2
- ts2 = te
- te2 = T2 - 1 * (_n - _j - 1) * _FD + randint(-(_n - _j - 1), 1) * _FD
- tcas_main(TCAS_BUF, PIX_1, ts2, te2, dx, dy, 0)
- # OUT 出场方式
- num = 8
- for i in range(num):
- ts3 = te2 + i * _FD
- te3 = ts3 + _FD
- PIX = PixBlur(PIX_1, (i + 1) * 6)
- PIX = PixResize(PIX, PIX_1[1][0], PIX[1][1] * (1 + i / num))
- PIX = PixColorMul(PIX, 1, 1, 1, (num - i) / num)
- tcas_main(TCAS_BUF, PIX, ts3, te3, dx, dy, 0)
- else:
- # MAIN 存在方式 part2
- ts2 = te
- te2 = T2
- tcas_main(TCAS_BUF, PIX_1, ts2, te2, dx, dy, 0)
- # OUT 出场方式
- if 0 == g_flags[1]:
- P = ((dx, dy), (dx, dy - 100))
- g_flags[1] = 1
- else:
- P = ((dx, dy), (dx, dy + 100))
- g_flags[1] = 0
- num = 6
- for i in range(num):
- x, y, a = LinearBezier(P[0], P[1], i / num)
- ts3 = te2 + i * _FD
- te3 = ts3 + _FD
- PIX = PixColorMul(PIX_1, 1, 1, 1, (num - i) / num)
- tcas_main(TCAS_BUF, PIX, ts3, te3, x, y, 0)
- # part4
- elif _i < 16:
- # 一些时间的计算
- T0 = 10 * _start - 10 * _FD
- T1 = T0 + 4 * _FD
- T2 = 10 * _end
- T3 = T2 + 8 * _FD
- # IN 入场方式
- IMG = Image(abspath(r'images\radial.jpg'))
- IMG.filterType(FilterTypes.CubicFilter)
- IMG.resize('!{0}x{1}'.format(PIX_1[1][0], PIX_1[1][1]))
- PIX = pmgToPix(IMG)
- PIX = PixColorMul(PIX, 2, 1, 1, 1)
- PIX = PixPos(PIX, PIX_1[0][0], PIX_1[0][1])
- PIX = PixR2A(PIX)
- if _i % 2 == 0:
- mask0 = PixInvertA(PIX)
- else:
- mask0 = PIX
- num = 10
- for i in range(num):
- mask = PixAddA(mask0, 255 * (2 * i - num) / num)
- PIX = PixMask(PIX_1, mask)
- ts0 = T0 + i * _FD
- te0 = ts0 + _FD
- tcas_main(TCAS_BUF, PIX, ts0, te0, dx, dy, 0)
- # MAIN 存在方式 part1
- ts1 = te0
- te1 = 10 * (_start + _elapk)
- tcas_main(TCAS_BUF, PIX_1, ts1, te1, dx, dy, 0)
- # EFT 表现方式
- if _k > 100:
- _k = 100
- num = int(10 * _k / _FD + 0.5)
- for i in range(num):
- ts = te1 + _FD * i
- te = ts + _FD
- PIX = pstBlur(PIX_1, 2, (i + 1) * 4)
- PIX = PixResizeF(PIX, PIX[1][0] + 12 * (i + 1), 0) # * (1 + 0.08 * (i + 1))
- PIX = BilinearFilter(PIX, dx, dy)
- tcas_main(TCAS_BUF, PIX, ts, te, dx, dy, 1)
- # MAIN 存在方式 part2
- ts2 = te
- te2 = T2
- tcas_main(TCAS_BUF, PIX_1, ts2, te2, dx, dy, 0)
- # OUT 出场方式
- num = 10
- for i in range(num):
- mask = PixAddA(mask0, 255 * (num - 2 * i) / num)
- PIX = PixMask(PIX_1, mask)
- ts3 = te2 + i * _FD
- te3 = ts3 + _FD
- tcas_main(TCAS_BUF, PIX, ts3, te3, dx, dy, 0)
- if _i == 13 and _j == _n - 1:
- # EXT 附加方式
- num = 34
- for i in range(num):
- ts4 = 10 * (_start + _elapk) + i * _FD
- te4 = ts4 + _FD
- img_path = MakePath(2, 2 * i + 1, 'images', 'list', 'img', '.png', 'sys')
- PIX = ImagePix(abspath(img_path))
- if i > num - 5:
- PIX = PixColorMul(PIX, 1, 1, 1, (num - i) / 5)
- tcas_main(TCAS_BUF, PIX, ts4, te4, _x - PIX[1][0] / 2, _y - PIX[1][1] / 2, 2)
- # part5
- elif _i < 20:
- # 一些时间的计算
- T0 = 10 * _start - 8 * _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)
- P = []
- pix_num = len(PIX_list)
- for i in range(pix_num):
- center = _n / 2 - 0.5 # center index of 5 texts is 2, center index of 6 is 2.5
- yf = i // (len(xv) + 1)
- if _j < center:
- xf = len(xv) - i % (len(xv) + 1)
- pt0 = (dx + (40 + 2 * xf) * (_j - center) / center, dy + 50 + 2 * yf)
- else:
- xf = i % (len(xv) + 1)
- pt0 = (dx + (40 + 2 * xf) * (_j - center) / center, dy + 50 + 2 * yf)
- pt1 = (dx, dy)
- P.append((pt0, pt1))
- num = 8
- for i in range(num):
- for j in range(pix_num):
- x, y, a = LinearBezier(P[j][0], P[j][1], i / num)
- ts0 = T0 + i * _FD
- te0 = ts0 + _FD
- PIX = PixBlur(PixColorMul(PIX_list[j], 1, 1, 1, (i + 1) / num), num - i)
- 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 表现方式
- num = int(10 * _k / _FD + 0.5)
- for i in range(num):
- ts = te1 + _FD * i
- te = ts + _FD
- if i % 2 == 0:
- PIX = pstBlur(PIX_1, 2, 24 + 1.2 * (i + 1))
- PIX = PixResizeF(PIX, PIX[1][0] * (1.3 + 0.2 * (i + 1) / num), 0)
- PIX = BilinearFilter(PIX, dx, dy)
- else:
- PIX = PIX_1
- tcas_main(TCAS_BUF, PIX, ts, te, dx, dy, 1)
- num += 8
- for i in range(num):
- ts = te1 - 3 * _FD + _FD * i
- te = ts + _FD
- img_path = MakePath(3, 4 * i + 1, 'images', 'list', 'img', '.png', 'sys')
- PIX = ImagePix(abspath(img_path))
- if i > num - 5:
- PIX = PixColorMul(PIX, 1, 1, 1, (num - i) / 5)
- tcas_main(TCAS_BUF, PIX, ts, te, _x - PIX[1][0] / 2 + randint(-1, 1), _y - PIX[1][1] / 2 + randint(-1, 1), 2)
- # MAIN 存在方式 part2
- ts2 = te1
- te2 = T2
- tcas_main(TCAS_BUF, PIX_1, ts2, te2, dx, dy, 0)
- # OUT 出场方式
- P = []
- pix_num = len(PIX_list)
- for i in range(pix_num):
- pt0 = (dx, dy)
- pt1 = (dx + randint(-70, 70), dy + randint(-16, 16))
- P.append((pt0, pt1))
- num = 10
- for i in range(num):
- for j in range(pix_num):
- x, y, a = LinearBezier(P[j][0], P[j][1], i / num)
- ts3 = te2 + i * _FD
- te3 = ts3 + _FD
- PIX = PixBlur(PIX_list[j], 2 * (i + 1))
- if i > 1 and randint(0, 1) == 0:
- PIX = pstSoftGlow(PIX, 10, randint(160, 190), randint(140, 160))
- if i > num - 4:
- PIX = PixColorMul(PIX, 1, 1, 1, (num - i) / 4)
- PIX = BilinearFilter(PIX, x, y)
- tcas_main(TCAS_BUF, PIX, ts3, te3, x, y, 0)
- # part6
- elif _i < 25:
- # 一些时间的计算
- T0 = 10 * _start - 12 * _FD + 2 * _j * _FD
- T1 = T0 + 4 * _FD
- T2 = 10 * _end + 4 * _FD - 2 * (_n - _j - 1) * _FD
- T3 = T2 + 8 * _FD
- # IN 入场方式
- if 0 == g_flags[0]:
- P = ((dx + 300, dy), (dx + 240, dy - 40), (dx + 60, dy - 40), (dx, dy))
- g_flags[0] = 1
- else:
- P = ((dx + 300, dy), (dx + 240, dy + 40), (dx + 60, dy + 40), (dx, dy))
- g_flags[0] = 0
- num = 10
- for i in range(num):
- x, y, a = CubicBezier(P[0], P[1], P[2], P[3], i / num)
- ts0 = T0 + i * _FD
- te0 = ts0 + _FD
- PIX = PixColorMul(PIX_1, 1, 1, 1, (i + 1) / num)
- 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)
- if _i == 24:
- # EFT 表现方式
- num = int(10 * _k / _FD + 0.5)
- for i in range(num):
- ts = te1 + _FD * i
- te = ts + _FD
- if i % 2 == 0:
- PIX = pstBlur(PIX_1, 2, 24 + 1.2 * (i + 1))
- PIX = PixResizeF(PIX, PIX[1][0] * (1.3 + 0.3 * (i + 1) / num), 0)
- PIX = BilinearFilter(PIX, dx, dy)
- else:
- PIX = PIX_1
- tcas_main(TCAS_BUF, PIX, ts, te, dx, dy, 1)
- # MAIN 存在方式 part2
- ts2 = te
- te2 = T2 + 2 * (_n - _j - 1) * _FD + randint(-(_n - _j - 1), 1) * _FD
- tcas_main(TCAS_BUF, PIX_1, ts2, te2, dx, dy, 0)
- # OUT 出场方式
- num = 8
- for i in range(num):
- ts3 = te2 + i * _FD
- te3 = ts3 + _FD
- PIX = PixBlur(PIX_1, (i + 1) * 6)
- PIX = PixResize(PIX, PIX_1[1][0], PIX[1][1] * (1 + i / num))
- PIX = PixColorMul(PIX, 1, 1, 1, (num - i) / num)
- tcas_main(TCAS_BUF, PIX, ts3, te3, dx, dy, 0)
- # EXT 附加方式
- if _j == _n - 1:
- num = 69
- for i in range(num):
- ts4 = 10 * (_start + _elapk) + i * _FD
- te4 = ts4 + _FD
- img_path = MakePath(2, i + 1, 'images', 'list', 'img', '.png', 'sys')
- PIX = ImagePix(abspath(img_path))
- if i > num - 5:
- PIX = PixColorMul(PIX, 1, 1, 1, (num - i) / 5)
- tcas_main(TCAS_BUF, PIX, ts4, te4, _x - PIX[1][0] / 2, _y - PIX[1][1] / 2, 2)
- else:
- # EFT 表现方式
- if _k > 100:
- _k = 100
- num = int(10 * _k / _FD + 0.5)
- for i in range(num):
- ts = te1 + _FD * i
- te = ts + _FD
- PIX = pstBlur(PIX_1, 2, (i + 1) * 4)
- PIX = PixResizeF(PIX, PIX[1][0] + 12 * (i + 1), 0) # * (1 + 0.08 * (i + 1))
- PIX = BilinearFilter(PIX, dx, dy)
- tcas_main(TCAS_BUF, PIX, ts, te, dx, dy, 1)
- # MAIN 存在方式 part2
- ts2 = te
- te2 = T2
- tcas_main(TCAS_BUF, PIX_1, ts2, te2, dx, dy, 0)
- # OUT 出场方式
- if 0 == g_flags[1]:
- P = ((dx, dy), (dx - 60, dy + 40), (dx - 240, dy + 40), (dx - 300, dy))
- g_flags[1] = 1
- else:
- P = ((dx, dy), (dx - 60, dy - 40), (dx - 240, dy - 40), (dx - 300, dy))
- g_flags[1] = 0
- num = 10
- for i in range(num):
- x, y, a = CubicBezier(P[0], P[1], P[2], P[3], i / num)
- ts3 = te2 + i * _FD
- te3 = ts3 + _FD
- PIX = PixColorMul(PIX_1, 1, 1, 1, (num - i) / num)
- 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
复制代码- from tcaxPy import *
- def tcaxPy_Init():
- global _Fs
- global _FD # 一帧的持续时间, 约40毫秒
- _Fs = GetVal(val_FontSize)
- _FD = 1000 / GetVal(val_FXFPS)
- # 图片序列
- global PIX_list
- PIX_list = []
- num = 40
- for i in range(1, num, 2):
- img_path = MakePath(1, i, 'images', 'list', 'img', '.png', 'sys')
- PIX = ImagePix(abspath(img_path))
- PIX_list.append(PIX)
- def tcaxPy_Fin():
- pass
- 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(4, 8):
- initPosX = marginX
- initPosY = marginY
- BIG_PIX = InitBigPix()
- for j in range(textNum[i]):
- if text[i][j] == '' or text[i][j] == ' ' or text[i][j] == ' ':
- continue
- Progress(i, j)
- T0 = 10 * start[i] - 16 * _FD
- num = len(PIX_list)
- for ii in range(num):
- ts3 = T0 + ii * _FD
- te3 = ts3 + _FD
- PIX = PIX_list[ii]
- if ii > num - 5:
- PIX = PixColorMul(PIX, 1, 1, 1, (num - ii) / 5)
- TCAS_BUF = []
- x = int(marginX + fx_width / 2 - PIX[1][0] / 2 + 0.5)
- y = int(marginY + _Fs / 2 - PIX[1][1] / 2 + 0.5) - 6
- tcas_main(TCAS_BUF, PIX, ts3, te3, x, y, 2)
- WriteTcasFile(TCAS_FILE, TCAS_BUF)
- progress(ii + 1, num)
- FinTcasFile(TCAS_FILE)
复制代码 |