- UID
- 2
- 积分
- 8682
- 帖子
- 2905
- 主题
- 199
- 论坛币
- 11741
- 威望
- 16
- EP值
- 2349
- MP值
- 15
- 阅读权限
- 200
- 注册时间
- 2011-8-3
- 在线时间
- 2597 小时
- 最后登录
- 2024-8-28
|
说明: 代码可以写得紧凑点(几个main函数可以合成一个), 之所以分开写是为了提供一个这样的参考----在必要的时候可以分成多个来写.
Accel_World_OP_FX.rar
(5.75 MB, 下载次数: 54359)
- from tcaxPy import *
- from util.magick import *
- def tcaxPy_Init():
- global _Fs
- global _FD # 一帧的持续时间, 约40毫秒
- global Font # 首要字体
- global FontAll # 加粗字体
- global IMG_blast
- global IMG_star
- global IMG_revball
- global IMG_star2
- global IMG_flare
- #global PIX_mask
- _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), 0xFFFFFF, 0, 0)
- FontAll = InitFont(_FontFileName, _FaceID, _Fs, GetVal(val_Spacing), GetVal(val_SpaceScale), 0xFFFFFF, 4, 0)
- # images
- img = Image(abspath('images/cosmic-blast-02.png')) #flare-0005.png'))
- img.resize('100x100000')
- img.backgroundColor('Transparent')
- IMG_blast = img
- img = Image(abspath('images/star-027.png'))
- img.resize('300x100000')
- img.backgroundColor('Transparent')
- IMG_star = img
- img = Image(abspath('images/revolution-ball-04.png'))
- img.resize('200x100000')
- img.backgroundColor('Transparent')
- IMG_revball = img
- img = Image(abspath('images/star-036.png'))
- img.resize('300x100000')
- img.backgroundColor('Transparent')
- IMG_star2 = img
- img = Image(abspath('images/flare-soft-spikey-violet-star.png'))
- img.backgroundColor('Transparent')
- IMG_flare = img
- # img = Image(abspath('images/dmsk0003.jpg')) #flare-0005.png'))
- # img.resize('200x100000')
- # img.crop('200x200+100+100')
- # img.write(abspath('images/mask.png'))
- # Pause()
- # PIX_mask = PixColorMul(addA(r2a(ImagePix(abspath('images/mask.png'))), 40), 1, 1, 1, 1.2)
- # img = Image(abspath('images/backdrop-0016.jpg'))
- # img.crop('800x300+0+200')
- # img.write(abspath('images/a.png'))
- # Pause()
- # img = Image(abspath('images/gradient.png'))
- # img.rotate(90)
- # img.resize('!800x300')
- # img.write(abspath('images/gradient2.png'))
- # Pause()
- # PIX = ImagePix(abspath('images/a.png'))
- # mask = PixColorMul(addA(invertA(ImagePix(abspath('images/gradient2.png'))), -40), 1, 1, 1, 2)
- # PIX = PixMask(PIX, mask)
- # SavePix(abspath('images/b.png'), PIX)
- # Pause()
- # img = Image(abspath('images/purple-spin.png'))
- # img.crop('800x240+0+0')
- # img.write(abspath('images/c.png'))
- # Pause()
- def tcaxPy_Fin():
- FinFont(Font)
- FinFont(FontAll)
- 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
- # part1
- for i in range(3): #3
- initPosX = fx_width - textLength[i] - 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
- posX = initPosX + advDiff[i][j] + advance[i][j] / 2
- posY = initPosY + fontSize / 2
- foo_bar = 0 # 实际上想传什么样的参数, 完全由我们自己决定, 数量也不受限制
- param = [BIG_PIX, foo_bar]
- ASS_BUF, TCAS_BUF = tcaxPy_Main_part1(i, j, textNum[i], start[i], end[i], elapKar[i][j], kar[i][j], posX, posY, advance[i][j], text[i][j], param)
- WriteTcasFile(TCAS_FILE, TCAS_BUF)
- Progress(i, j)
- PIX_mask = ConvertBigPix(BIG_PIX)
- num = textNum[i] + 6
- PIX_i = ImagePix(abspath('images/b.png'), PIX_mask[1][0], PIX_mask[1][1])
- for ii in range(num):
- TCAS_BUF = []
- PIX = PixPos(PIX_i, PIX_mask[0][0] + 1.5 * PIX_i[1][0] * (-0.5 + (ii + 1) / num), PIX_mask[0][1])
- PIX = PixMask(PIX, PIX_mask)
- PIX = PixColorMul(PIX, 1, 1, 1, sqrFactor(-0.5 + ii / num))
- tcas_main(TCAS_BUF, PIX, start[i] * 10 - 6 * _FD + ii * _FD, start[i] * 10 - 6 * _FD + (ii + 1) * _FD, 0, 0, 1)
- WriteTcasFile(TCAS_FILE, TCAS_BUF)
- progress(ii + 1, num)
- # part2
- for i in range(3, 4): # 3, 4
- initPosX = fx_width - textLength[i] - 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
- posX = initPosX + advDiff[i][j] + advance[i][j] / 2
- posY = initPosY + fontSize / 2
- foo_bar = 0 # 实际上想传什么样的参数, 完全由我们自己决定, 数量也不受限制
- param = [BIG_PIX, foo_bar]
- ASS_BUF, TCAS_BUF = tcaxPy_Main_part2(i, j, textNum[i], start[i], end[i], elapKar[i][j], kar[i][j], posX, posY, advance[i][j], text[i][j], param)
- WriteTcasFile(TCAS_FILE, TCAS_BUF)
- Progress(i, j)
- PIX_mask = ConvertBigPix(BIG_PIX)
- num = textNum[i] + 6
- PIX_i = switchRB(ImagePix(abspath('images/transportation-beam-01.png'), PIX_mask[1][0], PIX_mask[1][1]))
- for ii in range(num):
- TCAS_BUF = []
- PIX = PixPos(PIX_i, PIX_mask[0][0] + 1.5 * PIX_i[1][0] * (-0.5 + (ii + 1) / num), PIX_mask[0][1])
- PIX = PixMask(PIX, PIX_mask)
- PIX = PixColorMul(PIX, 1, 1, 1, sqrFactor(-0.5 + ii / num))
- tcas_main(TCAS_BUF, PIX, start[i] * 10 - 6 * _FD + ii * _FD, start[i] * 10 - 6 * _FD + (ii + 1) * _FD, 0, 0, 1)
- WriteTcasFile(TCAS_FILE, TCAS_BUF)
- progress(ii + 1, num)
- # part3
- for i in range(4, 6): # 4, 6
- initPosX = fx_width - textLength[i] - 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
- posX = initPosX + advDiff[i][j] + advance[i][j] / 2
- posY = initPosY + fontSize / 2
- foo_bar = 0 # 实际上想传什么样的参数, 完全由我们自己决定, 数量也不受限制
- param = [BIG_PIX, foo_bar]
- ASS_BUF, TCAS_BUF = tcaxPy_Main_part3(i, j, textNum[i], start[i], end[i], elapKar[i][j], kar[i][j], posX, posY, advance[i][j], text[i][j], param)
- WriteTcasFile(TCAS_FILE, TCAS_BUF)
- Progress(i, j)
- PIX_mask = ConvertBigPix(BIG_PIX)
- num = textNum[i] + 6
- PIX_i = ImagePix(abspath('images/c.png'), PIX_mask[1][0], PIX_mask[1][1])
- for ii in range(num):
- TCAS_BUF = []
- PIX = PixPos(PIX_i, PIX_mask[0][0] + 1.5 * PIX_i[1][0] * (-0.5 + (ii + 1) / num), PIX_mask[0][1])
- PIX = PixMask(PIX, PIX_mask)
- PIX = PixColorMul(PIX, 1, 1, 1, sqrFactor(-0.5 + ii / num))
- tcas_main(TCAS_BUF, PIX, start[i] * 10 - 6 * _FD + ii * _FD, start[i] * 10 - 6 * _FD + (ii + 1) * _FD, 0, 0, 1)
- WriteTcasFile(TCAS_FILE, TCAS_BUF)
- progress(ii + 1, num)
- # part4
- for i in range(6, 7): # 6, 7
- initPosX = fx_width - textLength[i] - 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
- posX = initPosX + advDiff[i][j] + advance[i][j] / 2
- posY = initPosY + fontSize / 2
- foo_bar = 0 # 实际上想传什么样的参数, 完全由我们自己决定, 数量也不受限制
- param = [BIG_PIX, foo_bar]
- ASS_BUF, TCAS_BUF = tcaxPy_Main_part4(i, j, textNum[i], start[i], end[i], elapKar[i][j], kar[i][j], posX, posY, advance[i][j], text[i][j], param)
- WriteTcasFile(TCAS_FILE, TCAS_BUF)
- Progress(i, j)
- PIX_mask = ConvertBigPix(BIG_PIX)
- num = textNum[i] + 6
- PIX_i = ImagePix(abspath('images/star-018.png'), PIX_mask[1][0], PIX_mask[1][1])
- for ii in range(num):
- TCAS_BUF = []
- PIX = PixPos(PIX_i, PIX_mask[0][0] + 1.5 * PIX_i[1][0] * (-0.5 + (ii + 1) / num), PIX_mask[0][1])
- PIX = PixMask(PIX, PIX_mask)
- PIX = PixColorMul(PIX, 1, 1, 1, sqrFactor(-0.5 + ii / num))
- tcas_main(TCAS_BUF, PIX, start[i] * 10 - 6 * _FD + ii * _FD, start[i] * 10 - 6 * _FD + (ii + 1) * _FD, 0, 0, 1)
- WriteTcasFile(TCAS_FILE, TCAS_BUF)
- progress(ii + 1, num)
- # part5
- for i in range(7, 8): # 7, 8
- initPosX = fx_width - textLength[i] - 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
- posX = initPosX + advDiff[i][j] + advance[i][j] / 2
- posY = initPosY + fontSize / 2
- foo_bar = 0 # 实际上想传什么样的参数, 完全由我们自己决定, 数量也不受限制
- param = [BIG_PIX, foo_bar]
- ASS_BUF, TCAS_BUF = tcaxPy_Main_part5(i, j, textNum[i], start[i], end[i], elapKar[i][j], kar[i][j], posX, posY, advance[i][j], text[i][j], param)
- WriteTcasFile(TCAS_FILE, TCAS_BUF)
- Progress(i, j)
- PIX_mask = ConvertBigPix(BIG_PIX)
- num = textNum[i] + 6
- PIX_i = PixResize(PixStrip(ImagePix(abspath('images/explosion-of-colors-001.png'))) , PIX_mask[1][0], PIX_mask[1][1])
- for ii in range(num):
- TCAS_BUF = []
- PIX = PixPos(PIX_i, PIX_mask[0][0] + 1.5 * PIX_i[1][0] * (-0.5 + (ii + 1) / num), PIX_mask[0][1])
- PIX = PixMask(PIX, PIX_mask)
- PIX = PixColorMul(PIX, 1, 1, 1, sqrFactor(-0.5 + ii / num))
- tcas_main(TCAS_BUF, PIX, start[i] * 10 - 6 * _FD + ii * _FD, start[i] * 10 - 6 * _FD + (ii + 1) * _FD, 0, 0, 1)
- WriteTcasFile(TCAS_FILE, TCAS_BUF)
- #progress(ii + 1, num)
- # part6 = part1
- for i in range(8, lineNum): # 8, lineNum
- initPosX = fx_width - textLength[i] - 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
- posX = initPosX + advDiff[i][j] + advance[i][j] / 2
- posY = initPosY + fontSize / 2
- foo_bar = 0 # 实际上想传什么样的参数, 完全由我们自己决定, 数量也不受限制
- param = [BIG_PIX, foo_bar]
- ASS_BUF, TCAS_BUF = tcaxPy_Main_part1(i, j, textNum[i], start[i], end[i], elapKar[i][j], kar[i][j], posX, posY, advance[i][j], text[i][j], param)
- WriteTcasFile(TCAS_FILE, TCAS_BUF)
- Progress(i, j)
- PIX_mask = ConvertBigPix(BIG_PIX)
- num = textNum[i] + 6
- PIX_i = ImagePix(abspath('images/b.png'), PIX_mask[1][0], PIX_mask[1][1])
- for ii in range(num):
- TCAS_BUF = []
- PIX = PixPos(PIX_i, PIX_mask[0][0] + 1.5 * PIX_i[1][0] * (-0.5 + (ii + 1) / num), PIX_mask[0][1])
- PIX = PixMask(PIX, PIX_mask)
- PIX = PixColorMul(PIX, 1, 1, 1, sqrFactor(-0.5 + ii / num))
- tcas_main(TCAS_BUF, PIX, start[i] * 10 - 6 * _FD + ii * _FD, start[i] * 10 - 6 * _FD + (ii + 1) * _FD, 0, 0, 1)
- WriteTcasFile(TCAS_FILE, TCAS_BUF)
- progress(ii + 1, num)
- FinTcasFile(TCAS_FILE)
- def tcaxPy_Main_part1(_i, _j, _n, _start, _end, _elapk, _k, _x, _y, _a, _txt, param):
- 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_t = TextPix(Font, _txt)
- PIX = TextPix(FontAll, _txt)
- PIX_s = PixColorMul(PixBlur(PIX, 20), 1, 1, 1, 0.8)
- PIX = CombinePixs(PIX_s, PIX_t)
- BigPixAdd(param[0], PIX, dx, dy, 0)
- PIX0 = PIX
- # 一些时间的计算
- T0 = 10 * _start - 10 * _FD + 1 * _j * _FD
- T1 = T0 + 4 * _FD
- T2 = 10 * _end + 5 * _FD - 2 * (_n - _j - 1) * _FD
- T3 = T2 + _FD * 4
- # IN 进入方式
- #PIX = PIX0
- img = pmgToImage(a2rgb(PIX))
- img.shade(0, 45, True)
- PIX1 = PixPos(pmgToPix(img), PIX[0][0], PIX[0][1])
- PIX2 = PixColorMul(PixMask(PIX1, PIX), 1, 0, 0, 1)
- tcas_keyframe(TCAS_BUF, PixBlur(PixColorMul(PIX2, 1, 1, 1, 0.2), 10), PIX2, T0, T1, dx, dy, 1, 0)
- # MAIN 存在方式
- #PIX = PIX0
- num = int((10 * (_start + _elapk + min(_k, 80)) - T1) / _FD + 0.5) + 1
- for i in range(num):
- img = pmgToImage(a2rgb(PIX))
- img.shade(i * 10, randint(44, 58), True)
- PIX1 = PixPos(pmgToPix(img), PIX[0][0], PIX[0][1])
- PIX2 = PixColorMul(PixMask(PIX1, PIX), 1, 0.5 * i / num, 0, 1)
- tcas_main(TCAS_BUF, PIX2, T1 + i * _FD, T1 + (i + 1) * _FD, dx, dy, 1)
- # OUT 消失方式
- tcas_keyframe(TCAS_BUF, PIX2, PixColorMul(PixBlur(PIX2, 16), 1, 1, 1, 0), T1 + num * _FD, 10 * (_start + _elapk + min(_k, 80) * 2), dx, dy, 2, 1)
- TK = 10 * (_start + _elapk)
- num = int(10 * min(_k, 80) / _FD + 0.5) + 6
- for i in range(num):
- img = Image(IMG_blast)
- img.rotate(360 * 0.8 * i / num)
- PIX = pmgToPix(img)#PixColorMul(pmgToPix(img), 1, 1, 1, 0.6 + 0.4 * (num - i - 1) / num)
- PIX = PixPos(PIX, PIX_t[0][0] + (PIX_t[1][0] - PIX[1][0]) / 2, PIX_t[0][1] + (PIX_t[1][1] - PIX[1][1]) / 2)
- tcas_main(TCAS_BUF, PIX, TK + i * _FD, TK + (i + 1) * _FD, dx, dy, 0)
- ##### 将结果返回给tcax进行处理 #####
- return (ASS_BUF, TCAS_BUF)
- def tcaxPy_Main_part2(_i, _j, _n, _start, _end, _elapk, _k, _x, _y, _a, _txt, param):
- 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_t = TextPix(Font, _txt)
- PIX = TextPix(FontAll, _txt)
- PIX_s = PixColorMul(PixBlur(PIX, 20), 1, 1, 1, 0.8)
- PIX = CombinePixs(PIX_s, PIX_t)
- BigPixAdd(param[0], PIX, dx, dy, 0)
- PIX0 = PIX
- # 一些时间的计算
- T0 = 10 * _start - 10 * _FD + 1 * _j * _FD
- T1 = T0 + 4 * _FD
- T2 = 10 * _end + 5 * _FD - 2 * (_n - _j - 1) * _FD
- T3 = T2 + _FD * 4
- # IN 进入方式
- #PIX = PIX0
- img = pmgToImage(a2rgb(PIX))
- img.shade(0, 45, True)
- PIX1 = PixPos(pmgToPix(img), PIX[0][0], PIX[0][1])
- PIX2 = PixColorMul(PixMask(PIX1, PIX), 0, 0, 0.7, 1)
- tcas_keyframe(TCAS_BUF, PixBlur(PixColorMul(PIX2, 1, 1, 1, 0.2), 10), PIX2, T0, T1, dx, dy, 1, 0)
- # MAIN 存在方式
- #PIX = PIX0
- num = int((10 * (_start + _elapk + min(_k, 80)) - T1) / _FD + 0.5) + 1
- for i in range(num):
- img = pmgToImage(a2rgb(PIX))
- img.shade(i * 10, randint(44, 58), True)
- PIX1 = PixPos(pmgToPix(img), PIX[0][0], PIX[0][1])
- PIX2 = PixColorMul(PixMask(PIX1, PIX), 0, 0.5 * i / num, 0.7, 1)
- tcas_main(TCAS_BUF, PIX2, T1 + i * _FD, T1 + (i + 1) * _FD, dx, dy, 1)
- # OUT 消失方式
- tcas_keyframe(TCAS_BUF, PIX2, PixColorMul(PixBlur(PIX2, 16), 1, 1, 1, 0), T1 + num * _FD, 10 * (_start + _elapk + min(_k, 80) * 2), dx, dy, 2, 1)
- TK = 10 * (_start + _elapk)
- num = int(10 * min(_k, 80) * 2 / _FD + 0.5) + 6
- for i in range(num):
- img = Image(IMG_star)
- img.rotate(360 * 0.8 * i / num)
- PIX = PixColorMul(pmgToPix(img), 1, 1, 1, linearFactor2(i / num))
- PIX = PixPos(PIX, PIX_t[0][0] + (PIX_t[1][0] - PIX[1][0]) / 2, PIX_t[0][1] + (PIX_t[1][1] - PIX[1][1]) / 2)
- if i / num >= 0.5:
- PIX = PixResize(PIX, PIX[1][0] * linearFactor1(i / num), 0)
- tcas_main(TCAS_BUF, PIX, TK + i * _FD, TK + (i + 1) * _FD, dx, dy, 0)
- ##### 将结果返回给tcax进行处理 #####
- return (ASS_BUF, TCAS_BUF)
- def tcaxPy_Main_part3(_i, _j, _n, _start, _end, _elapk, _k, _x, _y, _a, _txt, param):
- 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_t = TextPix(Font, _txt)
- PIX = TextPix(FontAll, _txt)
- PIX_s = PixColorMul(PixBlur(PIX, 20), 1, 1, 1, 0.8)
- PIX = CombinePixs(PIX_s, PIX_t)
- BigPixAdd(param[0], PIX, dx, dy, 0)
- PIX0 = PIX
- # 一些时间的计算
- T0 = 10 * _start - 10 * _FD + 1 * _j * _FD
- T1 = T0 + 4 * _FD
- T2 = 10 * _end + 5 * _FD - 2 * (_n - _j - 1) * _FD
- T3 = T2 + _FD * 4
- # IN 进入方式
- #PIX = PIX0
- img = pmgToImage(a2rgb(PIX))
- img.shade(0, 45, True)
- PIX1 = PixPos(pmgToPix(img), PIX[0][0], PIX[0][1])
- PIX2 = PixColorMul(PixMask(PIX1, PIX), 248 / 255, 14 / 255, 177 / 255, 1)
- tcas_keyframe(TCAS_BUF, PixBlur(PixColorMul(PIX2, 1, 1, 1, 0.2), 10), PIX2, T0, T1, dx, dy, 1, 0)
- # MAIN 存在方式
- #PIX = PIX0
- num = int((10 * (_start + _elapk + min(_k, 80)) - T1) / _FD + 0.5) + 1
- for i in range(num):
- img = pmgToImage(a2rgb(PIX))
- img.shade(i * 10, randint(44, 58), True)
- PIX1 = PixPos(pmgToPix(img), PIX[0][0], PIX[0][1])
- PIX2 = PixColorMul(PixMask(PIX1, PIX), 248 / 255 + (251 - 248) / 255 * i / num, 14 / 255 + (132 - 14) / 255 * i / num, 177 / 255 + (215 - 177) / 255 * i / num, 1)
- tcas_main(TCAS_BUF, PIX2, T1 + i * _FD, T1 + (i + 1) * _FD, dx, dy, 1)
- # OUT 消失方式
- tcas_keyframe(TCAS_BUF, PIX2, PixColorMul(PixBlur(PIX2, 16), 1, 1, 1, 0), T1 + num * _FD, 10 * (_start + _elapk + min(_k, 80) * 2), dx, dy, 2, 1)
- TK = 10 * (_start + _elapk)
- num = int(10 * min(_k, 80) * 2 / _FD + 0.5) + 6
- for i in range(num):
- img = Image(IMG_revball)
- img.rotate(360 * 0.8 * i / num)
- PIX = PixColorMul(pmgToPix(img), 1, 1, 1, linearFactor2(i / num))
- PIX = PixPos(PIX, PIX_t[0][0] + (PIX_t[1][0] - PIX[1][0]) / 2, PIX_t[0][1] + (PIX_t[1][1] - PIX[1][1]) / 2)
- tcas_main(TCAS_BUF, PIX, TK + i * _FD, TK + (i + 1) * _FD, dx, dy, 0)
- ##### 将结果返回给tcax进行处理 #####
- return (ASS_BUF, TCAS_BUF)
- def tcaxPy_Main_part4(_i, _j, _n, _start, _end, _elapk, _k, _x, _y, _a, _txt, param):
- 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_t = TextPix(Font, _txt)
- PIX = TextPix(FontAll, _txt)
- PIX_s = PixColorMul(PixBlur(PIX, 20), 1, 1, 1, 0.8)
- PIX = CombinePixs(PIX_s, PIX_t)
- BigPixAdd(param[0], PIX, dx, dy, 0)
- PIX0 = PIX
- # 一些时间的计算
- T0 = 10 * _start - 10 * _FD + 1 * _j * _FD
- T1 = T0 + 4 * _FD
- T2 = 10 * _end + 5 * _FD - 2 * (_n - _j - 1) * _FD
- T3 = T2 + _FD * 4
- # IN 进入方式
- #PIX = PIX0
- img = pmgToImage(a2rgb(PIX))
- img.shade(0, 45, True)
- PIX1 = PixPos(pmgToPix(img), PIX[0][0], PIX[0][1])
- PIX2 = PixColorMul(PixMask(PIX1, PIX), 248 / 255, 14 / 255, 177 / 255, 1)
- tcas_keyframe(TCAS_BUF, PixBlur(PixColorMul(PIX2, 1, 1, 1, 0.2), 10), PIX2, T0, T1, dx, dy, 1, 0)
- # MAIN 存在方式
- #PIX = PIX0
- num = int((10 * (_start + _elapk + min(_k, 80)) - T1) / _FD + 0.5) + 1
- for i in range(num):
- img = pmgToImage(a2rgb(PIX))
- img.shade(i * 10, randint(44, 58), True)
- PIX1 = PixPos(pmgToPix(img), PIX[0][0], PIX[0][1])
- PIX2 = PixColorMul(PixMask(PIX1, PIX), 248 / 255 + (251 - 248) / 255 * i / num, 14 / 255 + (132 - 14) / 255 * i / num, 177 / 255 + (215 - 177) / 255 * i / num, 1)
- tcas_main(TCAS_BUF, PIX2, T1 + i * _FD, T1 + (i + 1) * _FD, dx, dy, 1)
- # OUT 消失方式
- tcas_keyframe(TCAS_BUF, PIX2, PixColorMul(PixBlur(PIX2, 16), 1, 1, 1, 0), T1 + num * _FD, 10 * (_start + _elapk + min(_k, 80) * 2), dx, dy, 2, 1)
- TK = 10 * (_start + _elapk)
- num = int(10 * min(_k, 80) * 2 / _FD + 0.5) + 6
- for i in range(num):
- img = Image(IMG_star2)
- img.rotate(360 * 0.8 * i / num)
- PIX = PixColorMul(pmgToPix(img), 1, 1, 1, linearFactor2(i / num))
- PIX = PixPos(PIX, PIX_t[0][0] + (PIX_t[1][0] - PIX[1][0]) / 2, PIX_t[0][1] + (PIX_t[1][1] - PIX[1][1]) / 2)
- tcas_main(TCAS_BUF, PIX, TK + i * _FD, TK + (i + 1) * _FD, dx, dy, 0)
- ##### 将结果返回给tcax进行处理 #####
- return (ASS_BUF, TCAS_BUF)
- def tcaxPy_Main_part5(_i, _j, _n, _start, _end, _elapk, _k, _x, _y, _a, _txt, param):
- 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_t = TextPix(Font, _txt)
- PIX = TextPix(FontAll, _txt)
- PIX_s = PixColorMul(PixBlur(PIX, 20), 1, 1, 1, 0.8)
- PIX = CombinePixs(PIX_s, PIX_t)
- BigPixAdd(param[0], PIX, dx, dy, 0)
- PIX0 = PIX
- # 一些时间的计算
- T0 = 10 * _start - 10 * _FD + 1 * _j * _FD
- T1 = T0 + 4 * _FD
- T2 = 10 * _end + 5 * _FD - 2 * (_n - _j - 1) * _FD
- T3 = T2 + _FD * 4
- # IN 进入方式
- #PIX = PIX0
- img = pmgToImage(a2rgb(PIX))
- img.shade(0, 45, True)
- PIX1 = PixPos(pmgToPix(img), PIX[0][0], PIX[0][1])
- PIX2 = PixColorMul(PixMask(PIX1, PIX), 248 / 255, 14 / 255, 177 / 255, 1)
- tcas_keyframe(TCAS_BUF, PixBlur(PixColorMul(PIX2, 1, 1, 1, 0.2), 10), PIX2, T0, T1, dx, dy, 1, 0)
- # MAIN 存在方式
- #PIX = PIX0
- num = int((10 * (_start + _elapk + min(_k, 80)) - T1) / _FD + 0.5) + 1
- for i in range(num):
- img = pmgToImage(a2rgb(PIX))
- img.shade(i * 10, randint(44, 58), True)
- PIX1 = PixPos(pmgToPix(img), PIX[0][0], PIX[0][1])
- PIX2 = PixColorMul(PixMask(PIX1, PIX), 248 / 255 + (251 - 248) / 255 * i / num, 14 / 255 + (132 - 14) / 255 * i / num, 177 / 255 + (215 - 177) / 255 * i / num, 1)
- tcas_main(TCAS_BUF, PIX2, T1 + i * _FD, T1 + (i + 1) * _FD, dx, dy, 1)
- # OUT 消失方式
- tcas_keyframe(TCAS_BUF, PIX2, PixColorMul(PixBlur(PIX2, 16), 1, 1, 1, 0), T1 + num * _FD, 10 * (_start + _elapk + min(_k, 80) * 2), dx, dy, 2, 1)
- TK = 10 * (_start + _elapk)
- num = int(10 * min(_k, 80) / _FD + 0.5) + 6
- for i in range(num):
- img = Image(IMG_flare)
- img.rotate(360 * 0.8 * i / num)
- PIX = pmgToPix(img)#PixColorMul(pmgToPix(img), 1, 1, 1, 0.6 + 0.4 * (num - i - 1) / num)
- PIX = PixPos(PIX, PIX_t[0][0] + (PIX_t[1][0] - PIX[1][0]) / 2, PIX_t[0][1] + (PIX_t[1][1] - PIX[1][1]) / 2)
- if i / num >= 0.5:
- PIX = PixResize(PIX, PIX[1][0] * linearFactor1(i / num), 0)
- tcas_main(TCAS_BUF, PIX, TK + i * _FD, TK + (i + 1) * _FD, dx, dy, 0)
- ##### 将结果返回给tcax进行处理 #####
- return (ASS_BUF, TCAS_BUF)
- # Utility
- def sqrFactor(x):
- return -4 * (x - 0.5) * (x + 0.5)
- def linearFactor1(x):
- if x < 0.5:
- return 1
- else:
- return 1 - 1 * (x - 0.5)
- def linearFactor2(x):
- if x < 0.5:
- return 1
- else:
- return 1 - 2 * (x - 0.5)
- def r2a(PIX):
- buf = []
- width = PIX[1][0]
- height = PIX[1][1]
- for h in range(height):
- for w in range(width):
- index = 4 * (h * width + w)
- # if PIX[2][index] != PIX[2][index + 1] or PIX[2][index] != PIX[2][index + 2]:
- # print('note1')
- # if PIX[2][index + 3] != 255:
- # print('note2')
- buf.append(0)
- buf.append(0)
- buf.append(0)
- buf.append(PIX[2][index + 0])
- return (PIX[0], PIX[1], tuple(buf))
- def invertA(PIX):
- buf = list(PIX[2])
- width = PIX[1][0]
- height = PIX[1][1]
- for h in range(height):
- for w in range(width):
- index = 4 * (h * width + w) + 3
- buf[index] = 255 - buf[index]
- return (PIX[0], PIX[1], tuple(buf))
- def addA(PIX, step):
- buf = list(PIX[2])
- width = PIX[1][0]
- height = PIX[1][1]
- for h in range(height):
- for w in range(width):
- index = 4 * (h * width + w) + 3
- buf[index] += int(step + 0.5)
- if buf[index] < 0:
- buf[index] = 0
- if buf[index] > 255:
- buf[index] = 255
- return (PIX[0], PIX[1], tuple(buf))
- def a2rgb(PIX):
- buf = list(PIX[2])
- width = PIX[1][0]
- height = PIX[1][1]
- for h in range(height):
- for w in range(width):
- index = 4 * (h * width + w)
- buf[index] = buf[index + 3]
- buf[index + 1] = buf[index + 3]
- buf[index + 2] = buf[index + 3]
- buf[index + 3] = 255
- return (PIX[0], PIX[1], tuple(buf))
- def switchRB(PIX):
- buf = list(PIX[2])
- width = PIX[1][0]
- height = PIX[1][1]
- for h in range(height):
- for w in range(width):
- index = 4 * (h * width + w)
- temp = buf[index]
- buf[index] = buf[index + 2]
- buf[index + 2] = temp
- return (PIX[0], PIX[1], tuple(buf))
复制代码 |
-
1
查看全部评分
-
|