- UID
- 2
- 积分
- 8682
- 帖子
- 2905
- 主题
- 199
- 论坛币
- 11741
- 威望
- 16
- EP值
- 2349
- MP值
- 15
- 阅读权限
- 200
- 注册时间
- 2011-8-3
- 在线时间
- 2597 小时
- 最后登录
- 2024-8-28
|
说明: 该特效算是一个最简单的TCAS粒子特效示例, 可以利用最新版(1.1.9 SP1)中新增的tcas_parse函数来提高预览效率, 只需做如下改动, 去掉67和81行的注释, 将第80行的TCAS_BUF改成buf, 即可. (做此改动后, 需要升级到1.1.9 SP1才可以执行)
Gundam_Seed_OP2.rar
(1.88 MB, 下载次数: 3761)
- from tcaxPy import *
- from util.magick import *
- def tcaxPy_Init():
- global _Fs
- global _FD # 一帧的持续时间, 约40毫秒
- global Font # 首要字体
- global FontAll # 加粗字体
- global PIX_img
- _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)
- PIX_img = PixPos(PixBlur(PixStrip(ImagePix(abspath('flare1.png'), 8, 8)), 1), 0, 0)
- def tcaxPy_Fin():
- FinFont(Font)
- FinFont(FontAll)
- # 用户修订版的tcaxPy_Main函数, 保留原始tcaxPy_Main风格是为了减少额外记忆量, 实际上该函数形式可以非常多样化
- def tcaxPy_Main_Fake(_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) - T1) / _FD + 0.5) + 1
- for i in range(num):
- img = pmgToImage(a2rgb(PIX))
- img.shade(i * 10, randint(44, 56), True)
- PIX1 = PixPos(pmgToPix(img), PIX[0][0], PIX[0][1])
- PIX2 = PixColorMul(PixMask(PIX1, PIX), 1, i / num, 0, 1)
- tcas_main(TCAS_BUF, PIX2, T1 + i * _FD, T1 + (i + 1) * _FD, dx, dy, 0)
- # OUT 消失方式
- #tcas_keyframe(TCAS_BUF, PIX2, PixColorMul(PixBlur(PIX2, 16), 1, 1, 1, 0), T1 + num * _FD, 10 * (_start + _elapk + _k * 2), dx, dy, 2, 0)
- #PIX = PIX0
- dx2 = dx + PIX_t[0][0] - int(PIX_img[1][0] / 2 + 0.5)
- dy2 = dy + PIX_t[0][1] - int(PIX_img[1][1] / 2 + 0.5)
- inix = dx2 - randint(15, 30)
- tab_posx = (inix + randint(-40, 40), inix + randint(-130, 130), inix + randint(-130, 130), inix + randint(-40, 40))
- tab_posy = (dy2 + _Fs + randint(-15, 20), _y + randint(-100, 100), _y + randint(-110, 110), dy2 + randint(-15, 20))
- maxi = int(tab_posy[0] - tab_posy[3]) + 90
- pos_cur = Bezier3(maxi, tab_posx[0] + randint(-15, 15), tab_posy[0], tab_posx[3] + randint(-15, 15), tab_posy[3], tab_posx[1] + randint(-20, 20), tab_posy[1], tab_posx[2] + randint(-20, 20), tab_posy[2])
- #buf = []
- points = PixPoints(PIX_t)
- pt_num = len(points)
- for ii in range(pt_num//12):
- i = randint(0, pt_num - 1)
- w = points[i][0]
- h = points[i][1]
- idx = 4 * (h * PIX_t[1][0] + w)
- x = dx2 + points[i][0]
- y = dy2 + points[i][1]
- indice = randint(0, maxi - 1)
- x_fin = pos_cur[indice][0] + randint(-5, 5)
- y_fin = pos_cur[indice][1] + randint(-5, 5)
- bezier2Move(TCAS_BUF, 10 * (_start + _elapk), 10 * (_start + _elapk + randint(0, _k * 2 + 120)), x, y, x_fin, y_fin)
- #TCAS_BUF.extend(tcas_parse(buf, 1280, 720, 23.976, 3))
- ##### 将结果返回给tcax进行处理 #####
- return (ASS_BUF, TCAS_BUF)
- 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(lineNum):
- 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
- 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_Fake(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('flare1.png'), PIX_mask[1][0], PIX_mask[1][1])
- for ii in range(num):
- TCAS_BUF = []
- PIX = PixPos(PIX_i, PIX_mask[0][0] + 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 sqrFactor(x):
- return -4 * (x - 0.5) * (x + 0.5)
- def linearFactor(x):
- if x < 0:
- return 2 * x + 1
- else:
- return -2 * x + 1
- 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 bezier2Move(TCAS_BUF, ts, te, xs, ys, xe, ye):
- xc = (xs + xe) // 2 + RandSign() * randint(20, 50)
- yc = (ys + ye) // 2 + RandSign() * randint(10, 30)
- num = int((te - ts) / _FD + 0.5) + 2
- pos_cur = Bezier2(num, xs, ys, xe, ye, xc, yc)
- for i in range(num):
- rt = random()
- PIX = PixColorMul(PixColorShift(PIX_img, 200, 0, 0, 0), 0.5 + rt, random(), 1 - rt, 0.5 + 0.5 * (num - i) / num)
- tcas_keyframe(TCAS_BUF, PIX, PixColorMul(PIX, 1, 1, 1, 0), ts + i * _FD, ts + (i + randint(4, 12)) * _FD, pos_cur[i][0], pos_cur[i][1], 1, 0)
复制代码 |
-
1
查看全部评分
-
|