TCAX 字幕特效制作工具官方论坛 | ASS | TCAS | Python | Aegisub | Lua

 找回密码
 新人加入
查看: 7262|回复: 11
打印 上一主题 下一主题

[完整特效] [jiji]007_sen_no_kiseki_theme_song [复制链接]

Rank: 5Rank: 5

跳转到指定楼层
楼主
发表于 2013-12-26 07:01:48 |只看该作者 |倒序浏览
本帖最后由 jijidata 于 2013-12-26 07:06 编辑

日文
  1. from tcaxPy import *
  2. from s import *
  3. from gdiFont import *  #加入GDIfont模块
  4. from util.tcCurve import *
  5. import math
  6. import random

  7. def tcaxPy_Init():
  8.     global _FontFileName
  9.     global _FaceID
  10.     global _Fs
  11.     global _TextWidth
  12.     global _TextHeight
  13.     global _TextLength
  14.     global _TextAdvDiff
  15.     global _ResolutionX
  16.     global _FD
  17.     global _TextInitX
  18.     global _Ascender        # 字体上行高度
  19.     global _Descender        # 字体下行高度 通常为负数
  20.     global _H
  21.     global _3C
  22.     global _KarTime         
  23.     _KarTime = GetVal(val_KarTime)# 第i句卡拉OK歌词的第j个字符的Karaoke时间 = !$start!
  24.     _H = GetVal(val_FontSize)
  25.     _3C = GetVal(val_3C)
  26.     _FontFileName = GetVal(val_FontFileName)
  27.     _FaceID       = GetVal(val_FaceID)
  28.     _Fs           = GetVal(val_FontSize)
  29.     _Ascender = GetVal(val_Ascender) #字体上行高度
  30.     _TextHeight   = GetVal(val_TextHeight)# 第i句卡拉OK歌词的j个字符的高度
  31.     _TextWidth    = GetVal(val_TextWidth)# 第i句卡拉OK歌词的j个字符的宽度
  32.     _TextLength   = GetVal(val_TextLength)# 第i句卡拉OK歌词的文字总长度
  33.     _TextAdvDiff  = GetVal(val_TextAdvanceDiff)# 从初始位置到第i句卡拉OK歌词的j个字符的水平步距
  34.     _TextInitX  = GetVal(val_TextInitX)
  35.     _ResolutionX  = GetVal(val_ResolutionX)
  36.     _FD           = 1000 / GetVal(val_FXFPS)
  37.     global GdiFont   #GDIfont
  38.     GdiFont = gfInitFont(GetVal(val_FontFaceName), _Fs, GetVal(val_Spacing), GetVal(val_SpaceScale), 0, False)   #GDIfont
  39.     global Font
  40.     Font = InitFont(GetVal(val_FontFileName), GetVal(val_FaceID), _Fs, GetVal(val_Spacing), GetVal(val_SpaceScale), 0xFFFFFF, 0, 0)



  41. def p(y):#绘图缩放代码
  42.     if y == int(y):
  43.         Y = str(int(y))
  44.     else:
  45.         Y = str(format(y, '.2f'))
  46.     return '\\p{0}'.format(Y)
  47.    
  48. def frxyz(x):
  49.     X1 = randint(-x,x)
  50.     X2 = randint(-x,x)
  51.     X3 = randint(-x,x)
  52.     return frx(X1)+fry(X2)+frz(X3)

  53.    


  54. def tcaxPy_Main(_i, _j, _n, _BT, _ET, _SK, _KT, _X, _Y, _A, _TXT):
  55.     ASS_BUF = []                # 用于保存ASS特效
  56.     _7X = _X - int(_A / 2 + 0.5)              #每个字的上X坐标= !$left!
  57.     _7Y = _Y - int(_H / 2 + 0.5)              #每个字的上Y坐标=!$top!
  58.     _bottom = _Y + int(_H / 2 + 0.5)              #每个字的下Y坐标





  59.     if _i > -1 and _i < 4 :
  60.         shape = ["m 30 23 b 24 23 24 33 30 33 b 36 33 37 23 30 23 m 35 27 l 61 28 l 35 29 m 26 27 l 0 28 l 26 29 m 29 23 l 30 0 l 31 23 m 29 33 l 30 57 l 31 33 ","m 6 0 b 12 0 12 7 6 7 b 0 7 0 0 6 0 ","m 15 0 l 10 7 l 0 9 l 9 13 l 5 23 l 15 17 l 25 23 l 21 13 l 31 9 l 20 7 l 15 0 "]
  61.         ass_main(ASS_BUF,SubL(_BT-10+_j*3,_BT+_SK,1),an(5)+blur(4)+fsc(0,0)+move(_X+30,_Y,_X,_Y,0,400)+alpha(255)+t(0,400,alpha(0)+fsc(100,100)) ,_TXT)#入场效果
  62.         ass_main(ASS_BUF,SubL(_BT+_SK,_BT+_SK+_KT,1),an(5)+blur(4)+pos(_X,_Y)+t(0,_KT*5,fsc(120,120))+t(_KT*5,_KT*10,fsc(100,100))+t(0,_KT*1,rnd(20))+t(_KT*1,_KT*2,rnd(0))+t(_KT*2,_KT*3,rnd(5))+t(_KT*3,_KT*4,rnd(20))+t(_KT*4,_KT*5,rnd(0))+t(_KT*5,_KT*6,rnd(15))+t(_KT*6,_KT*7,rnd(2))+t(_KT*7,_KT*8,rnd(16))+t(_KT*8,_KT*9,rnd(0))+t(_KT*9,_KT*10,rnd(10)) ,_TXT)#表现方式
  63.         dur = _ET-(_BT+_SK+_KT)
  64.         ass_main(ASS_BUF,SubL(_BT+_SK+_KT,_ET,1),an(5)+blur(4)+pos(_X,_Y)+t(0,dur*1,rnd(20))+t(dur*1,dur*2,rnd(0))+t(dur*2,dur*3,rnd(5))+t(dur*3,dur*4,rnd(20))+t(dur*4,dur*5,rnd(0))+t(dur*5,dur*6,rnd(15))+t(dur*6,dur*7,rnd(2))+t(dur*7,dur*8,rnd(16))+t(dur*8,dur*9,rnd(0))+t(dur*9,dur*10,rnd(10)) ,_TXT)
  65.         ass_main(ASS_BUF,SubL(_ET,_ET+_j*10,1),an(5)+blur(4)+move(_X,_Y,_X+40,_Y+5)+t(fsc(50,50)+bord(0)+blur(20)+fad(0,700))+t(0,_j*10*2,rnd(20))+t(_j*10*2,_j*10*4,rnd(0))+t(_j*10*4,_j*10*6,rnd(10))+t(_j*10*6,_j*10*8,rnd(20))+t(_j*10*8,_j*10*10,rnd(1)) ,_TXT)
  66.         for j in range(math.ceil(_KT)):
  67.             J = [math.ceil(_KT)]
  68.             step1 = _KT*10*(j-1)/(max(J)*10-1)
  69.             XC1= _7X+_A*(j+1)/max(J)                      #X的实际坐标,从每个字的左边移动到右边(这是spacing为0的情况下,spacing不为0需修改代码,嗯~我偷懒了)
  70.             _SY = _Y - int(_H / 2 + 0.5)*(-1)**_j          #Y坐标初始坐标,依次为每个字的上顶点,下顶点,
  71.             _CY = (-1)**_j*_H*(j+1)/max(J)                 #Y坐标的控制参数,含义为依次加上字符的高度,减去字符的高度
  72.             YC1= _SY+_CY                                       #Y坐标的实际坐标,由以上初始坐标加上控制参数生成
  73.             XC2= XC1-_A*0.1*randint(10,40)
  74.             YC2= YC1+random.uniform(-0.4*_A,0.4*_A)
  75.             CurveMove = move(XC1,YC1,XC2,YC2)
  76.             ass_main(ASS_BUF,SubL(_BT+_SK+step1,_BT+_SK+_KT+step1+70,2),an(5)+blur(4)+bord(0.5)+vc1("00FFFF","00FFFF","FFFFFF","FFFFFF")+fad(0,300)+t(frxyz(720))+CurveMove+p(1)+fsc(randint(20,40),randint(20,40)),shape[randint(0,2)])

  77.     if _i > 3 and _i < 8 :
  78.         ass_main(ASS_BUF,SubL(_BT-10+_j*3,_BT+_SK,1),an(5)+blur(4)+move(_X+130,_Y,_X,_Y,0,400)+alpha(255)+t(0,400,alpha(0)) ,_TXT)
  79.         ass_main(ASS_BUF,SubL(_BT+_SK,_BT+_SK+_KT,1),an(5)+pos(_X,_Y)+t(0,_KT*4,0.5,fsc(135,135)+frz(randint(-20,20)))+bord(3)+blur(8)+alpha(0)+t(_KT*4,_KT*10,frz(0)+fsc(100,100)) ,_TXT)
  80.         ass_main(ASS_BUF,SubL(_BT+_SK+_KT,_ET,1),an(5)+blur(4)+pos(_X,_Y),_TXT)
  81.         ass_main(ASS_BUF,SubL(_ET,_ET+50,1),an(5)+blur(4)+pos(_X,_Y)+t(frz(500)+fsc(0,0)+alpha(255)) ,_TXT)
  82.         for j in range(0,3):
  83.             EFT2=alt(_ET,_ET+randint(400,600), t = randint(20,80) , FX1 =alpha(0), FX2 = alpha(255), offset = 0, a1 = None,a2 = None)
  84.             ass_main(ASS_BUF,SubL(_ET,_ET+randint(400,600)),an(5)+fad(0,randint(100,700))+blur(6)+fsc(randint(5,50),randint(5,50))+moves4(_X,_Y,_X+randint(-70,100),_Y+randint(-80,-50),_X+randint(-80,50),_Y+randint(-40,80),_X+randint(-70,50),_Y+randint(-60,60))+EFT2,"{\p1}m 21 16 b 17 16 17 23 21 23 b 25 23 26 16 21 16 m 24 19 l 43 20 l 24 20 m 18 19 l 0 20 l 18 20 m 20 16 l 21 0 l 22 16 m 20 23 l 21 40 l 22 23")
  85.         colour = ["&HE4ACFF&","&HDC76FF&","&HFFFFFF&"]
  86.         for k in range(2):# 曲线数
  87.             posX1 = _X+randint(-_A,-_A/2)
  88.             posX2 =_X+randint(-_A/3,_A)
  89.             PP  = [(posX1, _Y),(posX1, _Y),(posX1, _Y),(_X+randint(-_A*2,_A*2), _Y+randint(-50,50)), (_X+randint(-_A*1.5,_A*1.5), _Y+randint(-90,50)),(posX2 ,_Y),(posX2,_Y),(posX2 ,_Y)]
  90.             ucb = UCBSpline(PP)     #使用ucb
  91.             L = ucb.length()       # 曲线总长度
  92.             STEP_N = _KT*3       # 取样点数
  93.             step_size = 1 / STEP_N
  94.             print('控制点: {0}    曲线总长度: {1:.02f}    所取点数: {2}'.format(len(PP), L, STEP_N))
  95.             t1 = 0
  96.             POS = []
  97.             for w in range(int(STEP_N/2)):
  98.                 POS.append(UniformCubicBSpline(PP,w * step_size))
  99.                 particle = RandPolygon(12/5, 12/8, 4)
  100.                 BT2=_BT+_SK-20+w*1
  101.                 ET2=_BT+_SK-20+70+(w+1)*1
  102.                 ass_main(ASS_BUF, SubL(BT2, ET2,11), an(5)+t(frxyz(720))+bord(1)+shad(0)+blur(2)+ move(POS[w][0], POS[w][1],POS[w][0]+randint(-15,15), POS[w][1]+randint(-15,15)) +fad(100,200)+color3(colour[randint(0,2)]), particle ) #曲线
  103.                
  104.     if _i > 7 and _i < 11 :
  105.         pcolor2 = ["&HF2CCFF&","&HF3BFFF&","&HFF6BF4&","&HD49DFF&","&HBE7FFF&"]
  106.         size1 = randint(30,50)
  107.         size2 = randint(10,40)
  108.         ass_main(ASS_BUF,SubL(_BT-50+randint(-20,40),_BT+_SK,1),an(5)+blur(4)+fsc(0,0)+pos(_X,_Y)+t(0,400,randint(5,15)*0.1,frz(720)+fsc(100,100)+fad(300,0)) ,_TXT)
  109.         ass_main(ASS_BUF,SubL(_BT+_SK,_BT+_SK+_KT,1),an(5)+pos(_X,_Y)+t(0,_KT*4,0.7,fsc(150,150)+frz(randint(-20,20))+bord(2)+blur(8))+t(_KT*4,_KT*10,10/7,fsc(100,100)+frz(0)+blur(2)+bord(1)) ,_TXT)
  110.         step1 = _ET+80-(_BT+_SK+_KT)
  111.         ass_main(ASS_BUF,SubL(_BT+_SK+_KT,_ET+80,1),an(5)+pos(_X,_Y)+color3("00FFF1")+color1("FFFFFF")+alpha(255)+t(0,200,alpha(0)+bord(0)+blur(1)+be(1))+t(step1*4+randint(-100,200),step1*4+randint(100,400),fsc(randint(50,250),randint(50,250))+blur(8)+be(8)+alpha(255)) ,_TXT)
  112.         for j in range(5):
  113.             ass_main(ASS_BUF,SubL(_BT-30+j*1.5,_BT+_SK+_KT*2+j*0.5,1),an(5)+fad(300,300)+move(_X+randint(-10,10),_7Y+randint(-30,0),_X+randint(-15,15),_bottom+randint(-10,10))+blur(j*1)+bord(0.5)+alpha(255)+alpha1(128)+alpha3(128)+color1("FFFFFF")+color3(pcolor2[randint(0,4)])+fsc(size1,size1)+t(_KarTime[_i][_j]-210+j*50,_KarTime[_i][_j]-250+_KT*10+1000,fr(randint(0,90)*(-1)**randint(1,2)))+t(_KarTime[_i][_j],_KarTime[_i][_j]+1,color1("FFFFFF")+alpha1(0)+alpha3(0)+bord(1))+t(_KarTime[_i][_j]+1,_KarTime[_i][_j]+_KT+300,color1("FFFFFF")+alpha1(128)+alpha3(128)+bord(1)+fsc(size1+50,size1+60)) ,"{\p1}m 20 0 l 20 0 l 20 40 m 20 40 b 22 40 22 43 20 43 b 18 43 18 40 20 40 m 20 0 b 18 0 18 -3 20 -3 b 22 -3 22 0 20 0 m 0 20 l 40 20 m 40 20 b 40 18 43 18 43 20 b 43 22 40 22 40 20 m 0 20 b 0 18 -3 18 -3 20 b -3 22 0 22 0 20")
  114.         for k in range(2):
  115.             ass_main(ASS_BUF,SubL(_BT-30+k*1.5,_BT+_SK+_KT*2+k*0.5,1),an(5)+fad(300,300)+move(_X+randint(-30,30),_Y+randint(-30,0),_X+randint(-15,15),_Y+randint(-10,10))+blur(k*1)+bord(0.5)+alpha(255)+alpha1(128)+alpha3(128)+color1("FFFFFF")+color3(pcolor2[randint(0,4)])+fsc(size2,size2)+t(_KarTime[_i][_j]-210+j*50,_KarTime[_i][_j]-250+_KT*10+1000,fr(randint(0,90)*(-1)**randint(1,2)))+t(_KarTime[_i][_j],_KarTime[_i][_j]+1,color1("FFFFFF")+alpha1(0)+alpha3(0)+bord(0.5))+t(_KarTime[_i][_j]+1,_KarTime[_i][_j]+_KT+300,color1("FFFFFF")+alpha1(128)+alpha3(128)+bord(1)+fsc(size1+50,size1+60)) ,"{\p1}m 20 0 l 20 0 l 20 40 m 20 40 b 22 40 22 43 20 43 b 18 43 18 40 20 40 m 20 0 b 18 0 18 -3 20 -3 b 22 -3 22 0 20 0 m 0 20 l 40 20 m 40 20 b 40 18 43 18 43 20 b 43 22 40 22 40 20 m 0 20 b 0 18 -3 18 -3 20 b -3 22 0 22 0 20")
  116.         for l in range(5):
  117.             ass_main(ASS_BUF,SubL(_BT-30+j*1.5,_BT+_SK+_KT*2+j*0.5,1),an(5)+fad(300,300)+move(_X+randint(-10,10),_bottom+randint(0,30),_X+randint(-20,10),_7Y+randint(-20,-10))+blur(l*1)+bord(0.5)+alpha(255)+alpha1(128)+alpha3(128)+color1("FFFFFF")+color3(pcolor2[randint(0,4)])+fsc(size1,size1)+t(_KarTime[_i][_j]-210+j*50,_KarTime[_i][_j]-250+_KT*10+1000,fr(randint(0,90)*(-1)**randint(1,2)))+t(_KarTime[_i][_j],_KarTime[_i][_j]+1,color1("FFFFFF")+alpha1(0)+alpha3(0)+bord(1))+t(_KarTime[_i][_j]+1,_KarTime[_i][_j]+_KT+600,color1("FFFFFF")+alpha1(128)+alpha3(128)+bord(1)+fsc(size1+50,size1+60)) ,"{\p1}m 20 0 l 20 0 l 20 40 m 20 40 b 22 40 22 43 20 43 b 18 43 18 40 20 40 m 20 0 b 18 0 18 -3 20 -3 b 22 -3 22 0 20 0 m 0 20 l 40 20 m 40 20 b 40 18 43 18 43 20 b 43 22 40 22 40 20 m 0 20 b 0 18 -3 18 -3 20 b -3 22 0 22 0 20")
  118.             
  119.     if _i > 10 and _i < 17 :
  120.         ass_main(ASS_BUF,SubL(_BT-50+randint(-20,40),_BT+_SK,1),an(5)+blur(8)+be(8)+bord(0)+fsc(200,200)+pos(_X,_Y)+alpha(255)+t(0,500,randint(5,15)*0.1,fsc(100,100)+blur(0)+be(0)+alpha(0)) ,_TXT)
  121.         ass_main(ASS_BUF,SubL(_BT+_SK,_BT+_SK+_KT,1),an(2)+pos(_X,_bottom)+color3("FFFFFF")+t(0,_KT*10/4.5,0.65,fscy(120)+bord(2)+blur(7))+t(_KT*10/2.5,_KT*10,1.35,fscy(100)+blur(2)+bord(1)) ,_TXT)
  122.         ass_main(ASS_BUF,SubL(_BT+_SK+_KT,_ET,1),an(5)+blur(2)+bord(1)+pos(_X,_Y) ,_TXT)
  123.         ass_main(ASS_BUF,SubL(_ET,_ET+_n*2.5,1),an(5)+blur(2)+bord(1)+pos(_X,_Y)+t(0,100,0.5,fsc(80,80)+bord(1.3)+blur(2)+color3("FFFFFF"))+t(100,_n*25,0.5,fsc(130,130)+alpha(255)+bord(1)+blur(0)) ,_TXT)
  124.         for j in range(10):
  125.             ass_main(ASS_BUF,SubL(_BT+_SK+j,_BT+_SK+_KT+j*5+randint(25,75),2),an(5)+fad(20,50)+color1("FFFFFF")+color3("DC76FF")+bord(randint(1,15)*0.1)+blur(randint(5,20)*0.1)+fsc(randint(3,8),randint(3,8))+move(_X+randint(-5,5),_Y+randint(-50,-10),_X+randint(-50,50),_Y+randint(-5,25)) ,"{\p1}m 0 -2 l -3 1 l -1 3 l 1 3 l 3 1 l 0 -2")
  126.             ass_main(ASS_BUF,SubL(_BT+_SK+j,_BT+_SK+_KT+j*5+randint(25,75),2),an(5)+fad(20,50)+color1("FFFFFF")+color3("DC76FF")+bord(randint(1,15)*0.1)+blur(randint(5,20)*0.1)+fsc(randint(3,8),randint(3,8))+move(_X+randint(-5,5),_7Y+randint(-50,-10),_X+randint(-50,50),_7Y+randint(-15,15)) ,"{\p1}m 0 -2 l -3 1 l -1 3 l 1 3 l 3 1 l 0 -2")
  127.             ass_main(ASS_BUF,SubL(_BT+_SK+j,_BT+_SK+_KT+j*5+randint(25,75),2),an(5)+fad(20,50)+color1("FFFFFF")+color3("DC76FF")+bord(randint(1,15)*0.1)+blur(randint(5,20)*0.1)+fsc(randint(3,8),randint(3,8))+move(_X+randint(-5,5),_bottom+randint(-5,5),_X+randint(-50,50),_bottom+randint(-5,100)) ,"{\p1}m 0 -2 l -3 1 l -1 3 l 1 3 l 3 1 l 0 -2")
  128.         for k in range(3):
  129.             EFT = alt(_BT+_SK+k,_BT+_SK+_KT+k*5+randint(25,75), t = randint(60,100) , FX1 = alpha(255)+fsc(randint(5,10),randint(5,10)), FX2 = alpha(0)+fsc(randint(10,20),randint(10,20)), offset = 0, a1 = None,a2 = None)
  130.             ass_main(ASS_BUF,SubL(_BT+_SK+k,_BT+_SK+_KT+k*5+randint(25,75),2),an(5)+fad(20,50)+color1("FFFFFF")+color3("DC76FF")+bord(0.4)+blur(4)+fsc(5,5)+move(_X+randint(-5,5),_Y+randint(-5,5),_X+randint(-40,40),_Y+randint(-5,85))+EFT ,"{\p1}m 46 54 l 1 56 l 46 57 b 46 58 47 60 47 60 b 42 66 37 72 32 77 b 38 72 43 67 49 62 b 49 63 51 64 52 64 b 53 79 53 93 54 107 b 54 93 55 79 56 64 b 56 65 58 63 59 62 l 76 78 l 60 61 b 61 60 61 57 61 57 l 106 56 l 61 54 b 61 54 60 51 60 51 l 75 35 l 59 49 b 58 48 57 47 55 47 l 54 1 l 52 47 b 50 47 49 48 49 49 l 32 34 l 47 51 b 47 52 46 53 46 54")
  131.             ass_main(ASS_BUF,SubL(_BT+_SK+k,_BT+_SK+_KT+k*5+randint(25,75),2),an(5)+fad(20,50)+color1("FFFFFF")+color3("DC76FF")+bord(0.4)+blur(4)+fsc(5,5)+move(_X+randint(-5,5),_Y+randint(-5,5),_X+randint(-40,40),_Y+randint(-105,5))+EFT ,"{\p1}m 46 54 l 1 56 l 46 57 b 46 58 47 60 47 60 b 42 66 37 72 32 77 b 38 72 43 67 49 62 b 49 63 51 64 52 64 b 53 79 53 93 54 107 b 54 93 55 79 56 64 b 56 65 58 63 59 62 l 76 78 l 60 61 b 61 60 61 57 61 57 l 106 56 l 61 54 b 61 54 60 51 60 51 l 75 35 l 59 49 b 58 48 57 47 55 47 l 54 1 l 52 47 b 50 47 49 48 49 49 l 32 34 l 47 51 b 47 52 46 53 46 54")
  132.             ass_main(ASS_BUF,SubL(_BT+_SK+k,_BT+_SK+_KT+k*5+randint(25,75),2),an(5)+fad(20,50)+color1("FFFFFF")+color3("DC76FF")+bord(0.5)+blur(4)+fsc(5,5)+move(_X+randint(-5,5),_Y+randint(-5,5),_X+randint(-40,40),_Y+randint(-5,85))+EFT ,"{\p1}m 46 54 l 1 56 l 46 57 b 46 58 47 60 47 60 b 42 66 37 72 32 77 b 38 72 43 67 49 62 b 49 63 51 64 52 64 b 53 79 53 93 54 107 b 54 93 55 79 56 64 b 56 65 58 63 59 62 l 76 78 l 60 61 b 61 60 61 57 61 57 l 106 56 l 61 54 b 61 54 60 51 60 51 l 75 35 l 59 49 b 58 48 57 47 55 47 l 54 1 l 52 47 b 50 47 49 48 49 49 l 32 34 l 47 51 b 47 52 46 53 46 54")
  133.    
  134.     if _i > 16 :
  135.         ass_main(ASS_BUF,SubL(_BT-40+_j*2,_BT+_SK,1),an(5)+b(1)+pos(_X,_Y)+fad(200,0)+fsc(0,0)+t(0,200,fsc(220,220))+t(200,330,fsc(80,80))+t(330,520,fsc(140,140))+t(520,610,fsc(150,150))+t(610,710,fsc(120,120))+t(710,820,fsc(100,100))+rndy(20)+t(rndy(0))+blur(6) ,_TXT)
  136.         BT=_BT+_SK
  137.         ET=_BT+_SK+_KT
  138.         color33 = ["&HE4ACFF&","&H965B0A&","&H468613&","&HBC4E6C&","&H3A3BC4&","&H24D4D7&","&HF417B5&"]
  139.         EFT1 = alt(BT,ET, t = 40 , FX1 =frz(-1), FX2 = frz(1), offset = 0, a1 = None,a2 = None)
  140.         EFT2 = alt(BT,ET, t = 40 , FX1 =frz(-1)+color3("FFFFFF"), FX2 = frz(1)+color3("FF9F3D"), offset = 0, a1 = None ,a2 = None )
  141.         ass_main(ASS_BUF,SubL(_BT+_SK,_BT+_SK+_KT,5),an(5)+b(1)+org(_X,_Y+300)+pos(_X,_Y)+fscy(150)+rndx(10)+blur(8)+t(rndx(0)+fscy(100))+EFT1 ,_TXT)
  142.         ass_main(ASS_BUF,SubL(_BT+_SK,_BT+_SK+_KT,5),an(5)+b(1)+blur(8)+org(_X,_Y+300)+move(_X,_Y+5,_X,_Y-5)+fscy(150)+bord(4)+t(fscy(100))+alpha3(128)+EFT2 ,_TXT)
  143.         ass_main(ASS_BUF,SubL(_BT+_SK+_KT,_ET,5),an(5)+b(1)+blur(6)+pos(_X,_Y) ,_TXT)
  144.         ass_main(ASS_BUF,SubL(_ET,_ET+30,5),an(5)+b(1)+blur(3)+move(_X,_Y,_X+randint(-800,800),_Y+randint(-30,30))+fad(0,300)+bord(2)+t(frz(randint(-1280,1280))+fsc(randint(20,100),randint(20,100))) ,_TXT)
  145.         for j in range(60):
  146.             ass_main(ASS_BUF,SubL(_BT+_SK+randint(0,_KT),_BT+_SK+_KT+randint(-_KT,_KT),1),an(5)+be(8)+fad(0,300)+blur(8)+move(_X,_Y,_X-randint(0,150),_Y-randint(-65,65))+fsc(30,30)+color3(color33[randint(0,6)])+p(randint(2,3)) ,"m 20 0 b 20 10 30 20 40 20 b 30 20 20 30 20 40 b 20 30 10 20 0 20 b 10 20 20 10 20 0")
  147.         
  148.         
  149.    
  150.     return (ASS_BUF, None)
复制代码
中文:
  1. from tcaxPy import *
  2. from s import *
  3. from gdiFont import *  #加入GDIfont模块
  4. from util.tcCurve import *
  5. import math
  6. import random

  7. def tcaxPy_Init():
  8.     global _FontFileName
  9.     global _FaceID
  10.     global _Fs
  11.     global _TextWidth
  12.     global _TextHeight
  13.     global _TextLength
  14.     global _TextAdvDiff
  15.     global _ResolutionX
  16.     global _FD
  17.     global _TextInitX
  18.     global _Ascender        # 字体上行高度
  19.     global _Descender        # 字体下行高度 通常为负数
  20.     global _H
  21.     global _3C
  22.     global _KarTime         
  23.     _KarTime = GetVal(val_KarTime)# 第i句卡拉OK歌词的第j个字符的Karaoke时间 = !$start!
  24.     _H = GetVal(val_FontSize)
  25.     _3C = GetVal(val_3C)
  26.     _FontFileName = GetVal(val_FontFileName)
  27.     _FaceID       = GetVal(val_FaceID)
  28.     _Fs           = GetVal(val_FontSize)
  29.     _Ascender = GetVal(val_Ascender) #字体上行高度
  30.     _TextHeight   = GetVal(val_TextHeight)# 第i句卡拉OK歌词的j个字符的高度
  31.     _TextWidth    = GetVal(val_TextWidth)# 第i句卡拉OK歌词的j个字符的宽度
  32.     _TextLength   = GetVal(val_TextLength)# 第i句卡拉OK歌词的文字总长度
  33.     _TextAdvDiff  = GetVal(val_TextAdvanceDiff)# 从初始位置到第i句卡拉OK歌词的j个字符的水平步距
  34.     _TextInitX  = GetVal(val_TextInitX)
  35.     _ResolutionX  = GetVal(val_ResolutionX)
  36.     _FD           = 1000 / GetVal(val_FXFPS)
  37.     global GdiFont   #GDIfont
  38.     GdiFont = gfInitFont(GetVal(val_FontFaceName), _Fs, GetVal(val_Spacing), GetVal(val_SpaceScale), 0, False)   #GDIfont
  39.     global Font
  40.     Font = InitFont(GetVal(val_FontFileName), GetVal(val_FaceID), _Fs, GetVal(val_Spacing), GetVal(val_SpaceScale), 0xFFFFFF, 0, 0)



  41. def p(y):#绘图缩放代码
  42.     if y == int(y):
  43.         Y = str(int(y))
  44.     else:
  45.         Y = str(format(y, '.2f'))
  46.     return '\\p{0}'.format(Y)
  47.    
  48. def frxyz(x):
  49.     X1 = randint(-x,x)
  50.     X2 = randint(-x,x)
  51.     X3 = randint(-x,x)
  52.     return frx(X1)+fry(X2)+frz(X3)

  53.    


  54. def tcaxPy_Main(_i, _j, _n, _BT, _ET, _SK, _KT, _X, _Y, _A, _TXT):
  55.     ASS_BUF = []                # 用于保存ASS特效
  56.     _7X = _X - int(_A / 2 + 0.5)              #每个字的上X坐标= !$left!
  57.     _7Y = _Y - int(_H / 2 + 0.5)              #每个字的上Y坐标=!$top!
  58.     _bottom = _Y + int(_H / 2 + 0.5)              #每个字的下Y坐标





  59.     if _i > -1 and _i < 4 :
  60.         ass_main(ASS_BUF,SubL(_BT-10+_j*3,_BT+_SK,1),an(5)+blur(4)+fsc(0,0)+move(_X+30,_Y,_X,_Y,0,400)+alpha(255)+t(0,400,alpha(0)+fsc(100,100)) ,_TXT)#入场效果
  61.         ass_main(ASS_BUF,SubL(_BT+_SK,_ET,1),an(5)+blur(4)+pos(_X,_Y) ,_TXT)
  62.         ass_main(ASS_BUF,SubL(_ET,_ET+_j*10,1),an(5)+blur(4)+move(_X,_Y,_X+40,_Y+5)+t(fsc(50,50)+bord(0)+blur(20)+fad(0,700)) ,_TXT)
  63.         

  64.     if _i > 3 and _i < 8 :
  65.         ass_main(ASS_BUF,SubL(_BT-10+_j*3,_BT+_SK,1),an(5)+blur(4)+move(_X+130,_Y,_X,_Y,0,400)+alpha(255)+t(0,400,alpha(0)) ,_TXT)
  66.         ass_main(ASS_BUF,SubL(_BT+_SK,_ET,1),an(5)+blur(4)+pos(_X,_Y),_TXT)
  67.         ass_main(ASS_BUF,SubL(_ET,_ET+50,1),an(5)+blur(4)+pos(_X,_Y)+t(frz(500)+fsc(0,0)+alpha(255)) ,_TXT)

  68.                
  69.     if _i > 7 and _i < 11 :
  70.         pcolor2 = ["&HF2CCFF&","&HF3BFFF&","&HFF6BF4&","&HD49DFF&","&HBE7FFF&"]
  71.         size1 = randint(30,50)
  72.         size2 = randint(10,40)
  73.         ass_main(ASS_BUF,SubL(_BT-50+randint(-20,40),_BT+_SK,1),an(5)+blur(4)+fsc(0,0)+pos(_X,_Y)+t(0,400,randint(5,15)*0.1,frz(720)+fsc(100,100)+fad(300,0)) ,_TXT)
  74.         ass_main(ASS_BUF,SubL(_BT+_SK,_BT+_SK+_KT,1),an(5)+pos(_X,_Y)+blur(4) ,_TXT)
  75.         step1 = _ET+80-(_BT+_SK+_KT)
  76.         ass_main(ASS_BUF,SubL(_BT+_SK+_KT,_ET+80,1),an(5)+pos(_X,_Y)+color3("00FFF1")+color1("FFFFFF")+alpha(255)+t(0,200,alpha(0)+bord(0)+blur(1)+be(1))+t(step1*4+randint(-100,200),step1*4+randint(100,400),fsc(randint(50,250),randint(50,250))+blur(8)+be(8)+alpha(255)) ,_TXT)

  77.             
  78.     if _i > 10 and _i < 17 :
  79.         ass_main(ASS_BUF,SubL(_BT-50+randint(-20,40),_BT+_SK,1),an(5)+blur(8)+be(8)+bord(0)+fsc(200,200)+pos(_X,_Y)+alpha(255)+t(0,500,randint(5,15)*0.1,fsc(100,100)+blur(0)+be(0)+alpha(0)) ,_TXT)
  80.         ass_main(ASS_BUF,SubL(_BT+_SK,_ET,1),an(5)+blur(2)+bord(1)+pos(_X,_Y) ,_TXT)
  81.         ass_main(ASS_BUF,SubL(_ET,_ET+_n*2.5,1),an(5)+blur(2)+bord(1)+pos(_X,_Y)+t(0,100,0.5,fsc(80,80)+bord(1.3)+blur(2)+color3("FFFFFF"))+t(100,_n*25,0.5,fsc(130,130)+alpha(255)+bord(1)+blur(0)) ,_TXT)

  82.    
  83.     if _i > 16 :
  84.         ass_main(ASS_BUF,SubL(_BT-40+_j*2,_BT+_SK,1),an(5)+b(1)+pos(_X,_Y)+fad(200,0)+fsc(0,0)+t(0,200,fsc(220,220))+t(200,330,fsc(80,80))+t(330,520,fsc(140,140))+t(520,610,fsc(150,150))+t(610,710,fsc(120,120))+t(710,820,fsc(100,100))+rndy(20)+t(rndy(0))+blur(6) ,_TXT)
  85.         ass_main(ASS_BUF,SubL(_BT+_SK,_ET,5),an(5)+b(1)+blur(6)+pos(_X,_Y) ,_TXT)
  86.         ass_main(ASS_BUF,SubL(_ET,_ET+30,5),an(5)+b(1)+blur(3)+move(_X,_Y,_X+randint(-800,800),_Y+randint(-30,30))+fad(0,300)+bord(2)+t(frz(randint(-1280,1280))+fsc(randint(20,100),randint(20,100))) ,_TXT)

  87.         
  88.    
  89.     return (ASS_BUF, None)
复制代码
修复了http://www.tcax.org/forum.php?mo ... &extra=page%3D1
中间那部分的伪曲线的衔接不完整的瑕疵,嘛~
以上~个人的template移植完成,还有少许简单的就不移植了,接下来开个大坑~

补上个第80行代码的template
  1. Comment: 0,0:00:00.00,0:00:00.00,song-jp-1,,0,0,0,template noblank notext,!maxloop(math.ceil($dur/10))!!retime("presyl",syl.duration*(j-1)/(maxj-1),syl.duration*(j-1)/(maxj-1)+700)!{\move(!$left+$width*(j-1)/(maxj-1)-0.1*syl.height!, !$top+0.4*$height+0.6*$height*((1+(-1)^syl.i)/2)+((-1)^(syl.i+1))*0.6*$height*(j-1)/(maxj-1)!,!$left+$width*(j-1)/(maxj-1)-0.1*syl.height-$height*math.random(10,40)/10!, !$top+0.2*$height+0.6*$height*((1+(-1)^syl.i)/2)+((-1)^(syl.i+1))*0.6*$height*(j-1)/(maxj-1)+math.random(-0.4*$height,0.4*$height)!)\an5\fscx!math.random(20,40)!\fscy!math.random(20,40)!\bord0.5\blur4\1vc(&H00FFFF&,&H00FFFF&,&HFFFFFF&,&HFFFFFF&)\fad(0,300)\frz45\p1}!shape2[math.random(3)]!
复制代码
预览:http://pan.baidu.com/s/1sj6O12H


2

查看全部评分

Rank: 5Rank: 5

沙发
发表于 2013-12-26 07:03:04 |只看该作者
tcc 日文
  1. # tcc file version

  2. < tcc file version = 1.000 >

  3. # mode configuration

  4. < inherit ass header = false >
  5. < k mode = word >
  6. < text layout = horizontal >
  7. < tcaxpy init = true >
  8. < tcaxpy user = false >
  9. < tcaxpy fin = false >

  10. # py settings
  11. < py file = jiji-007.py >    < beg line = 1 >    < end line = 0 >





  12. < k-timed ass file = song-jp_k.ass >
  13. < font file = FOT-SkipStd-B.ttf >    < font face id = 1 >    < font size = 52 >
  14. < fx width = 1280 >    < fx height = 720 >    < fx fps = 59.940 >
  15. < alignment = 2 >
  16. < x offset = 10 >    < y offset = 20 >
  17. < spacing = 0 >    < space scale = 1.000 >



  18. # style settings

  19. < font face name = "" >
  20. < bord = 2 >    < shad = 0 >
  21. < primary color = FFFFFF >    < secondary color = 000000 >    < outline color = 2A88C3 >    < back color = 000000 >
  22. < primary alpha = 0 >    < secondary alpha = 240 >    < outline alpha = 0 >    < back alpha = 240 >

  23. # additional settings

  24. < blur = 0.000 >
复制代码
中文
  1. # tcc file version

  2. < tcc file version = 1.000 >

  3. # mode configuration

  4. < inherit ass header = false >
  5. < k mode = word >
  6. < text layout = horizontal >
  7. < tcaxpy init = true >
  8. < tcaxpy user = false >
  9. < tcaxpy fin = false >

  10. # py settings
  11. < py file = jiji-007-ch.py >    < beg line = 1 >    < end line = 0 >





  12. < k-timed ass file = song-ch_k.ass >
  13. < font file = 方正隶变_GBK.TTF >    < font face id = 1 >    < font size = 37 >
  14. < fx width = 1280 >    < fx height = 720 >    < fx fps = 59.940 >
  15. < alignment = 2 >
  16. < x offset = 10 >    < y offset = 62 >
  17. < spacing = 0 >    < space scale = 1.000 >



  18. # style settings

  19. < font face name = "" >
  20. < bord = 2 >    < shad = 0 >
  21. < primary color = FFFFFF >    < secondary color = 000000 >    < outline color = 2A88C3 >    < back color = 000000 >
  22. < primary alpha = 0 >    < secondary alpha = 240 >    < outline alpha = 0 >    < back alpha = 240 >

  23. # additional settings

  24. < blur = 0.000 >
复制代码

Rank: 5Rank: 5

板凳
发表于 2013-12-26 11:20:13 |只看该作者
本帖最后由 忘却の小伊 于 2013-12-26 12:06 编辑

from s import


这个里面你用到的希望能贴出来...

好多看不明白....

Rank: 4

地板
发表于 2013-12-26 11:49:56 |只看该作者
其实那些图形代码在哪里找的?还是lz自己写的?好华丽啊

Rank: 5Rank: 5

5#
发表于 2013-12-26 23:54:29 |只看该作者
本帖最后由 jijidata 于 2013-12-26 23:54 编辑
忘却の小伊 发表于 2013-12-26 11:20
from s import


这个是置顶帖的mod的tag
用到的有\rnd\moves4,还有颜色渐变

Rank: 5Rank: 5

6#
发表于 2013-12-27 00:00:30 |只看该作者
qq502761713 发表于 2013-12-26 11:49
其实那些图形代码在哪里找的?还是lz自己写的?好华丽啊

论坛里的矢量图收集贴以及各种模板里收集的,画这玩意儿好费时,不到万不得已我都懒得画

Rank: 4

7#
发表于 2014-6-22 03:54:02 |只看该作者
好长,拿回去试一下

Administrator

TCAX Dev.

Rank: 7Rank: 7Rank: 7

8#
发表于 2014-8-10 10:46:43 |只看该作者
顶一个, 很清爽的效果, 非常赞

Rank: 4

9#
发表于 2014-10-27 11:41:36 |只看该作者
大神,能帮忙看看嘛?

截图02.jpg (155.29 KB, 下载次数: 1698)

截图02.jpg

Rank: 5Rank: 5

10#
发表于 2014-10-28 22:57:39 |只看该作者
oiuu 发表于 2014-10-27 11:41
大神,能帮忙看看嘛?

tcc中字体大小改为偶数试试~或者不想纠结的话删掉100行的+randint(-A,-A/2)

Rank: 4

11#
发表于 2014-10-30 13:00:46 |只看该作者
jijidata 发表于 2014-10-28 22:57
tcc中字体大小改为偶数试试~或者不想纠结的话删掉100行的+randint(-A,-A/2)

两种方法都已经试过,还是错误。

Rank: 4

12#
发表于 2014-10-31 22:24:20 |只看该作者
lol, you are too lazy to draw >> like me XD
Nice effect Bro =D

Rank: 4

13#
发表于 2021-10-7 18:17:31 |只看该作者
本帖最后由 Seekladoom 于 2021-10-7 22:19 编辑
oiuu 发表于 2014-10-27 11:41
大神,能帮忙看看嘛?
解决问题的关键在于确定_A的数值,因为Python(Python 3.2)的随机函数randint的输出结果不能有小数,有小数就会报错。

因此在tcc中设置好字体参数以后,可以先写这么一个py脚本检查_A的具体数值:
  1. from tcaxPy import *

  2. def tcaxPy_Init():
  3.     pass
  4.    
  5. def tcaxPy_Main(_i, _j, _n, _BT, _ET, _SK, _KT, _X, _Y, _A, _TXT):
  6.     ASS_BUF = []        # 用于保存ASS特效

  7.     ass_main(ASS_BUF,SubL(_BT,_ET,1),'',_A)

  8.     return (ASS_BUF, None)
复制代码
然后再确认_A在randint中的计算结果是否有小数,有小数就将randint中的参数修改到最终计算结果只有整数即可。

要避免在randint函数本身的计算结果中出现小数的话,可以这样改:
randint(-_A/3,_A) → randint(-_A,_A*3)/3

贴一下修改过程及测试用文件:

jiji 007 randint test.rar (0 Bytes, 下载次数: 3039)
  1. from tcaxPy import *
  2. import random # 配合第22-23行使用

  3. def tcaxPy_Init():
  4.     pass
  5.    
  6. def tcaxPy_Main(_i, _j, _n, _BT, _ET, _SK, _KT, _X, _Y, _A, _TXT):
  7.     ASS_BUF = []        # 用于保存ASS特效

  8.     #  1.原写法:直接报错
  9.     #  报错内容(关键部分):ValueError: non-integer arg 1 for randrange()
  10.     #ass_main(ASS_BUF,SubL(_BT,_ET,1),'',randint(-_A/3,_A))

  11.     #  2.直接给_A-10
  12.     #  报错内容(关键部分):invalid syntax
  13.     #ass_main(ASS_BUF,SubL(_BT,_ET,1),'',randint((-_A-10)/3,_A+10))
  14.    
  15.     #  3.不改变原有计算结果的修改方法(能正常运行且无报错)
  16.     ass_main(ASS_BUF,SubL(_BT,_ET,1),'',randint(-_A,_A*3)/3)
  17.    
  18.     #  4.在原有计算结果的基础上保留两位小数的修改方法(写进脚本连起来依然报错)
  19.     #  报错内容:TypeError: bad operand type for unary -: 'str'
  20.     #ass_main(ASS_BUF,SubL(_BT,_ET,1),'',str(format(randint(-_A,_A*3)/3,'.2f')))

  21.     #  5.直接把randint换成uniform(能正常运行且无报错)
  22.     ass_main(ASS_BUF,SubL(_BT,_ET,1),'',uniform(-_A/3,_A))
  23.    
  24.     return (ASS_BUF, None)
复制代码

补充:lua的随机函数math.random在绝大部分情况下也是只能输出整数的,极少数情况可以输出小数但因其不稳定而不具备实用价值。然而可以通过对其计算结果使用乘法或除法来获得小数的随机值计算结果。

Rank: 4

14#
发表于 2021-10-7 22:07:50 |只看该作者
本帖最后由 Seekladoom 于 2021-10-7 22:40 编辑

基于上述内容给出以下两种不改变计算结果的规范改法:

方法1:把randint内部计算结果弄成整数,小数计算结果靠randint外部的除法解决
TCAX Karaoke Effect 020 - 1.rar (66.93 KB, 下载次数: 3065)
  1.         posX1 = _X+randint(-_A*2,-_A)/2
  2.         posX2 = _X+randint(-_A,_A*3)/3
  3.         PP = [(posX1, _Y),(posX1, _Y),(posX1, _Y),(_X+randint(-_A*2,_A*2), _Y+randint(-50,50)), (_X+randint(-_A*15,_A*15)/10, _Y+randint(-90,50)),(posX2 ,_Y),(posX2,_Y),(posX2 ,_Y)]
复制代码

方法2:在最前面加个import random,再把所有涉及到_A运算的randint全部换成uniform

TCAX Karaoke Effect 020 - 2.rar (67.68 KB, 下载次数: 3041)
  1.         posX1 = _X+uniform(-_A,-_A/2)
  2.         posX2 = _X+uniform(-_A/3,_A)
  3.         PP = [(posX1, _Y),(posX1, _Y),(posX1, _Y),(_X+uniform(-_A*2,_A*2), _Y+randint(-50,50)), (_X+uniform(-_A*1.5,_A*1.5), _Y+randint(-90,50)),(posX2 ,_Y),(posX2,_Y),(posX2 ,_Y)]
复制代码


您需要登录后才可以回帖 登录 | 新人加入

GitHub|TCAX 主页

GMT+8, 2024-11-22 07:18

Powered by Discuz! X2

© 2001-2011 Comsenz Inc.

回顶部
RealH