- UID
- 2443
- 积分
- 1311
- 帖子
- 78
- 主题
- 21
- 论坛币
- 909
- 威望
- 8
- EP值
- 449
- MP值
- 0
- 阅读权限
- 100
- 注册时间
- 2015-3-7
- 在线时间
- 121 小时
- 最后登录
- 2018-7-21
|
本帖最后由 面麻 于 2016-3-7 22:56 编辑
迟迟没有网络发上来;
一共4个效果,有用到 tcAudio 和粒子;第4个效果有待揣摩。
另外,粒子数据结构的构造可以用 tcaxLib.pyd 中的函数 PixPoints(pix),
但是我没有尝试,你可以自己替换相应部分进行测试。
tcAudio 所用到的音频以及整个效果的预览,在下面的百度网盘中:
http://pan.baidu.com/s/1jGXN1Ds 密码: uhw9
整个工程在下面的附件中:
bokumachi_op_jp.zip
(218.4 KB, 下载次数: 2711)
代码还是有点复杂,所以贴出来:- from tcaxPy import *
- from util.tcAudio import *
- def tcaxPy_User():
- pass
- def tcaxPy_Fin():
- tcAudioFin()
- FinFont(userfont)
- def Spectrum(fft): # convert fft data to graph
- SPECWIDTH = 368
- SPECHEIGHT = 127
- BANDS = 6
- bars = []
- b0 = 0
- for x in range(BANDS):
- peak = 0 # peak of a certain bar
- b1 = pow(2, x * 10.0 / (BANDS - 1))
- if b1 > 1023:
- b1 = 1023
- if b1 <= b0:
- b1 = b0 + 1 # make sure it uses at least 1 FFT bin
- while b0 < b1:
- if peak < fft[1 + b0]:
- peak = fft[1 + b0]
- b0 += 1
- y = sqrt(peak) * 5 * SPECHEIGHT
- bars.append(y)
- return bars
- def drawsquarelistdown():
- outdraw = 'm -1440 -4 l 1440 -4 l 1440 5 l -1440 5 l -1440 -4'
- squarelistdraw = ''
- lx = -1440
- lr = lx + 4
- while lr <= 1440:
- temp = 'm {0} -3 l {1} -3 l {1} 1 l {0} 1 l {0} -3 '.format(lx, lr)
- squarelistdraw += temp
- lx += 6
- lr += 6
- return squarelistdraw
- def drawsquarelistup():
- outdraw = 'm -1440 -4 l 1440 -4 l 1440 5 l -1440 5 l -1440 -4'
- squarelistdraw = ''
- lx = -1440
- lr = lx + 4
- while lr <= 1440:
- temp = 'm {0} 0 l {1} 0 l {1} 4 l {0} 4 l {0} 0 '.format(lx, lr)
- squarelistdraw += temp
- lx += 6
- lr += 6
- return squarelistdraw
- def tcaxPy_Init():
- tcAudioInit()
- global channel
- global freq
- global framedurms
- global fontsize
- global userfont
- fontsize = GetVal(val_FontSize)
- channel = tcAudioOpen("[Ohys-Raws] Boku dake ga Inai Machi - 03 (CX 1280x720 x264 AAC)_track2.aac")
- freq = tcAudioGetFreq(channel)
- framedurms = 1000 / GetVal(val_FXFPS)
- fontfile = GetVal(val_FontFileName)
- faceid = GetVal(val_FaceID)
- spacing = GetVal(val_Spacing)
- spacescale = GetVal(val_SpaceScale)
- userfont = InitFont(fontfile, faceid, fontsize, spacing, spacescale, MakeRGB(255, 255, 255), 0, 0)
- def tcaxPy_Main(_i, _j, _n, _start, _end, _elapk, _k, _x, _y, _a, _txt):
- ASS_BUF = [] # used for saving ASS FX lines
- TCAS_BUF = [] # used for saving TCAS FX raw data
- #############################
- # TODO: write your codes here #
- if _i == 0:
- ts = _start
- te = ts + framedurms / 10
- while te <= _end + framedurms / 10:
- tcAudioSetPos(channel, tcAudioSec2Bytes(channel, ts / 100))
- fft = tcAudioGetFFT(channel, 2048)
- bars = Spectrum(fft)
- #tcaxLog(bars)
- EFT = pos(randint(1, 1279), _y) + blur(1) + alpha1(255)
- if bars[1] > 40:
- param = pow(bars[1] / 40, 2.5)
- EFT += bord(param) + blur(param)
- ass_main(ASS_BUF, SubL(ts, te, 0, 'TCMS'), EFT, '.')
- ts += framedurms / 10
- te += framedurms / 10
- if 1 <= _i <= 8:
- # NextLineBT = GetVal(val_BegTime)[_i + 1]
- # NextLineET = GetVal(val_EndTime)[_i + 1]
- initPosX = (GetVal(val_ResolutionX) - GetVal(val_TextLength)[_i]) / 2 + GetVal(val_OffsetX) # an 8, 5, 2
- linerightedge = initPosX + GetVal(val_TextAdvanceDiff)[_i][_n - 1] + GetVal(val_TextAdvance)[_i][_n - 1] / 2
- lineleftedge = initPosX + GetVal(val_TextAdvanceDiff)[_i][0] + GetVal(val_TextAdvance)[_i][0] / 2
- EFT = pos(_x, _y) + fad(500, 0) + b(1)
- if _txt == '。':
- EFT += (alpha1(255) + alpha3(255))
- ass_main(ASS_BUF, SubL(_start, _end, 1, 'TCMS'), EFT, _txt)
- # EFT = fad(500, 0) + pos(_x, _y - fontsize / 2 - 6) + an(7)
- # ass_main(ASS_BUF, SubL(ts + 10, te, 1, 'TCMS'), EFT + color3('000000'), '{\p1}m -22 -4 l 22 -4 l 22 4 l -22 4 l -22 -4 {\p0}')
- # ass_main(ASS_BUF, SubL(ts + 10, te, 2, 'TCMS'), EFT + color1('FFFFFF') + bord(0), '{\p1}m -22 -2 l -14 -2 l -14 3 l -22 3 l -22 -2 m -10 -2 l -2 -2 l -2 3 l -10 3 l -10 -2 m 2 -2 l 10 -2 l 10 3 l 2 3 l 2 -2 m 14 -2 l 22 -2 l 22 3 l 14 3 l 14 -2 {\p0}')
- # EFT = fad(500, 0) + pos(_x, _y + fontsize / 2 + 6) + an(7)
- # ass_main(ASS_BUF, SubL(ts + 10, te, 1, 'TCMS'), EFT + color3('000000'), '{\p1}m -22 -4 l 22 -4 l 22 4 l -22 4 l -22 -4 {\p0}')
- # ass_main(ASS_BUF, SubL(ts + 10, te, 2, 'TCMS'), EFT + color1('FFFFFF') + bord(0), '{\p1}m -22 -2 l -14 -2 l -14 3 l -22 3 l -22 -2 m -10 -2 l -2 -2 l -2 3 l -10 3 l -10 -2 m 2 -2 l 10 -2 l 10 3 l 2 3 l 2 -2 m 14 -2 l 22 -2 l 22 3 l 14 3 l 14 -2 {\p0}')
- EFT = pos(_x + _a / 2 + 2, _y) + an(7) + fad(500, 0) + bord(0)
- ass_main(ASS_BUF, SubL(_start, _end, 0, 'TCMS'), EFT, '{\p1}m -0.8 -25 l 0.8 -25 l 0.8 25 l -0.8 25 l -0.8 -25 {\p0}')
- backsquaredraw = 'm -{0} -{1} l {2} -{1} l {2} {1} l -{0} {1} l -{0} {1}'.format(_a / 2 + 4, fontsize / 2, _a / 2)
- ts = _start + _elapk
- te = _end
- EFT = color1('998884') + bord(0) + alpha(255) + t(0, _k * 10, alpha(0)) + pos(_x, _y) + an(7)
- ass_main(ASS_BUF, SubL(ts, te, 0, 'TCMS'), EFT, '{\p1}'+backsquaredraw+'{\p0}')
- if _j == 0:
- EFT = pos(_x - _a / 2 - 4, _y) + an(7) + fad(500, 0) + bord(0)
- ass_main(ASS_BUF, SubL(_start, _end, 0, 'TCMS'), EFT, '{\p1}m -0.8 -25 l 0.8 -25 l 0.8 25 l -0.8 25 l -0.8 -25 {\p0}')
- EFT = move(-360, _y - fontsize / 2 - 6, 200, _y - fontsize / 2 - 6) + an(7) + bord(0)
- EFT += clip(lineleftedge - _a / 2 - 5, _y - fontsize / 2 - 6 - 10, linerightedge + _a / 2 + 5, _y - fontsize / 2 - 6 + 15)
- ass_main(ASS_BUF, SubL(_start, _end, 1, 'TCMS'), EFT, '{\p1}m -1440 -4 l 1440 -4 l 1440 5 l -1440 5 l -1440 -4 {\p0}')
- EFT = move(-360, _y - fontsize / 2 - 6, 200, _y - fontsize / 2 - 6) + an(7) + bord(0) + color1('FFFFFF')
- EFT += clip(lineleftedge - _a / 2 - 5, _y - fontsize / 2 - 6 - 10, linerightedge + _a / 2 + 5, _y - fontsize / 2 - 6 + 15)
- ass_main(ASS_BUF, SubL(_start, _end, 2, 'TCMS'), EFT, '{\p1}'+drawsquarelistup()+'{\p0}')
- EFT = move(-360, _y + fontsize / 2 + 6, 200, _y + fontsize / 2 + 6) + an(7) + bord(0)
- EFT += clip(lineleftedge - _a / 2 - 5, _y + fontsize / 2 + 6 - 10, linerightedge + _a / 2 + 5, _y + fontsize / 2 + 6 + 15)
- ass_main(ASS_BUF, SubL(_start, _end, 1, 'TCMS'), EFT, '{\p1}m -1440 -4 l 1440 -4 l 1440 5 l -1440 5 l -1440 -4 {\p0}')
- EFT = move(-360, _y + fontsize / 2 + 6, 200, _y + fontsize / 2 + 6) + an(7) + bord(0) + color1('FFFFFF')
- EFT += clip(lineleftedge - _a / 2 - 5, _y + fontsize / 2 + 6 - 10, linerightedge + _a / 2 + 5, _y + fontsize / 2 + 6 + 15)
- ass_main(ASS_BUF, SubL(_start, _end, 2, 'TCMS'), EFT, '{\p1}'+drawsquarelistdown()+'{\p0}')
- if 9 <= _i <= 12:
- if IsLineChanged(_i):
- global ALinePix
- global num
- ALinePix = []
- num = []
- ATextPix = []
- count = 0
- pixel = TextPix(userfont, _txt)
- initPosX = _x - int(_a / 2 + 0.5) + pixel[0][0] # 00, initX, a float, offset of the PIX in the horizontal direction
- initPosY = _y - int(fontsize / 2 + 0.5) + pixel[0][1] # 01, initY, a float, offset of the PIX in the vertical direction
- for h in range(pixel[1][1]): # 11, height, an integer, height of the PIX
- posY = initPosY + h
- for w in range(pixel[1][0]): # 10, width, an integer, width of the PIX
- posX = initPosX + w
- idx = 4 * (h * pixel[1][0] + w)
- pixA = pixel[2][idx + 3]
- if pixA != 0:
- ATextPix.append((posX, posY, pixA))
- count += 1
- num.append(count)
- ALinePix.append(ATextPix)
- if _j == _n-1:
- i = 0
- while i < len(ALinePix)-1:
- # localrnd = 0
- if num[i] < num[i+1]:
- if num[i+1] / num[i] <= 1.6:
- temp = ALinePix[i]
- for k in range(num[i+1]-num[i]):
- param = int(RandomGauss(0, num[i]-1, 6))
- temp.append(ALinePix[i][param])
- else:
- count = 0
- for k in range(num[i+1]-num[i]):
- temp = ALinePix[i]
- temp.append(ALinePix[i][count%num[i]])
- count += 1
- for j in range(num[i+1]):
- # rnd = randint(0, 40)
- # localrnd = rnd
- EFT = move(temp[j][0], temp[j][1], ALinePix[i+1][j][0], ALinePix[i+1][j][1], 0, GetVal(val_KarTime)[_i][i] * 10) + alpha(255 - temp[j][2]) + bord(randint(0, 1)) + blur(randint(1, 3))
- ts = _start + GetVal(val_KarTimeDiff)[_i][i]
- ass_main(ASS_BUF, SubL(ts, ts + GetVal(val_KarTime)[_i][i], Layer=1, Style='TCPS'), EFT, '{\p5}m -5 -15 l -15 0 l -6 7 l 9 12 l 5 4 l 13 -13 ')
- # if i == 0:
- # EFT = pos(temp[j][0], temp[j][1]) + alpha(255 - temp[j][2]) + bord(randint(0, 1)) + blur(randint(1, 3))
- # ass_main(ASS_BUF, SubL(ts + rnd, _end, Layer=0, Style='TCPS'), EFT, DrawPoint())
- else:
- if num[i] / num[i+1] <= 1.6:
- temp = ALinePix[i+1]
- for k in range(num[i]-num[i+1]):
- param = int(RandomGauss(0, num[i+1]-1, 6))
- temp.append(ALinePix[i+1][param])
- else:
- count = 0
- for k in range(num[i]-num[i+1]):
- temp = ALinePix[i+1]
- temp.append(ALinePix[i+1][count%num[i+1]])
- count += 1
- for j in range(num[i]):
- # if localrnd == 0:
- # rnd = randint(0, 40)
- # else:
- # rnd = localrnd
- EFT = move(ALinePix[i][j][0], ALinePix[i][j][1], temp[j][0], temp[j][1], 0, GetVal(val_KarTime)[_i][i] * 10) + alpha(255 - ALinePix[i][j][2]) + bord(randint(0, 1)) + blur(randint(1, 3))
- ts = _start + GetVal(val_KarTimeDiff)[_i][i]
- ass_main(ASS_BUF, SubL(ts, ts + GetVal(val_KarTime)[_i][i], Layer=1, Style='TCPS'), EFT, '{\p4}m -5 -15 l -15 0 l -6 7 l 9 12 l 5 4 l 13 -13 ')
- # if i == 0:
- # EFT = pos(ALinePix[i][j][0], ALinePix[i][j][1]) + alpha(255 - temp[j][2]) + bord(randint(0, 1)) + blur(randint(1, 3))
- # ass_main(ASS_BUF, SubL(ts + rnd, _end, Layer=0, Style='TCPS'), EFT, DrawPoint())
- i += 1
- ts = _start + GetVal(val_KarTimeDiff)[_i][i]
- for j in range(num[i]):
- EFT = pos(ALinePix[i][j][0], ALinePix[i][j][1]) + alpha(255 - ALinePix[i][j][2]) + bord(randint(0, 1)) + blur(randint(1, 3))
- ass_main(ASS_BUF, SubL(ts, _end, Layer=1, Style='TCPS'), EFT, '{\p4}m -5 -15 l -15 0 l -6 7 l 9 12 l 5 4 l 13 -13 ')
- ass_main(ASS_BUF, SubL(_start, _end, 0, 'TCMS'), pos(_x, _y) + alpha1(255) + bord(3) + blur(2) + color3('000000') + b(1), _txt)
-
- if 13 <= _i <= 14:
- ts = _start
- te = ts + framedurms / 10
- if _i == 13:
- color = 'C2530F'
- else:
- color = 'H847BC6'
- if IsLineChanged(_i):
- global key
- key = randint(0, 3)
- while te <= _end + framedurms / 10:
- tcAudioSetPos(channel, tcAudioSec2Bytes(channel, ts / 100))
- fft = tcAudioGetFFT(channel, 2048)
- bars = Spectrum(fft)
- #tcaxLog(bars)
- EFT = pos(_x, _y) + blur(2) + color1('FFFFFF') + b(1) + color3('000000')
- if bars[1] > 70:
- EFT += alpha1(HexToDec('80'))
- else:
- EFT += alpha1(HexToDec('44'))
- ass_main(ASS_BUF, SubL(ts, te, 1, 'TCMS'), EFT, _txt)
- #ass_main(ASS_BUF, SubL(ts, te, 0, 'TCMS'), pos(_x + RandomDouble(-0.5, 1), _y + RandomDouble(-0.5, 1)) + blur(1) + color3(color[randint(0, 5)]) + alpha1(255) + b(1), _txt)
- ts += framedurms / 10
- te += framedurms / 10
- ts = _start + _elapk
- te = _end
- EFT = pos(_x, _y) + alpha(255) + t(0, _k * 10, alpha(0)) + color1(color) + b(1) + color3('000000') + blur(2)
- ass_main(ASS_BUF, SubL(ts, te, 0, 'TCMS'), EFT, _txt)
- if 15 <= _i <= 18:
- EFT = blur(1) + color1('FFFFFF') + b(1) + pos(_x, _y)
- if _i == 18:
- endextra = randint(20, 70) - 50
- ass_main(ASS_BUF, SubL(_start, _end - endextra, 1, 'TCMS'), EFT, _txt)
- for k in range(3):
- #size = randint(500, 2500)
- EFT = bord(0) + color1('FFFFFF') + b(1) + t(alpha1(255)+blur(randint(25, 35))+fs(randint(95, 105)))
- EFT += move(_x, _y, _x + randint(-30, 30), _y + randint(-40, 40))
- ass_main(ASS_BUF, SubL(_end - endextra, _end - endextra + 40, 1, 'TCMS'), EFT, _txt)
- else:
- endextra = 0
- ass_main(ASS_BUF, SubL(_start, _end, 1, 'TCMS'), EFT, _txt)
- color = ('305F67', 'EF8D2C', '2216B1', '4BE029', '090735', 'FF69FA')
- ts = _start
- te = ts + framedurms / 5
- if _i != 16:
- while te <= _end - endextra + framedurms / 10:
- EFT = pos(_x + randint(-2, 3), _y + randint(-2, 3)) + blur(1) + color3(color[randint(0, 5)]) + b(1)
- ass_main(ASS_BUF, SubL(ts, te, 0, 'TCMS'), EFT, _txt)
- ts += framedurms / 10
- te += framedurms / 10
- #ass_main(ASS_BUF, SubL(_start, _end), pos(_x, _y) + K(_elapk) + K(_k), _txt)
- #############################
- return (ASS_BUF, TCAS_BUF)
复制代码 |
-
2
查看全部评分
-
|