- UID
- 215
- 积分
- 15394
- 帖子
- 1163
- 主题
- 27
- 论坛币
- 428
- 威望
- 125
- EP值
- 1992
- MP值
- 26
- 阅读权限
- 100
- 注册时间
- 2011-10-13
- 在线时间
- 668 小时
- 最后登录
- 2018-6-25
|
本帖最后由 渣渣疯子 于 2012-9-16 19:36 编辑
- from tcaxPy import *
- from draw2pix import *
- def tcaxPy_Init():
- global _FontFileName # frame duration, in millisecond
- global _FD
- global _Fs
- global _Length
- global _Bd
- global _Br
- global _FaceID
- global _Font
- global _Spacing
- _FontFileName = GetVal(val_FontFileName)
- _FD = 1000 / GetVal(val_FXFPS)
- _Fs = GetVal(val_FontSize)
- _Length = GetVal(val_TextLength)
- _Bd = GetVal(val_Bord)
- _Br = GetVal(val_Blur)
- _FaceID = GetVal(val_FaceID)
- _Spacing = GetVal(val_Spacing)
- _Font = InitFont(_FontFileName, _FaceID, _Fs, GetVal(val_Spacing), GetVal(val_SpaceScale), 0xFFFFFF, 2, 0)
- cairo_init(100, 100)
- def fr(x):
- X = randint(-x,x)
- return frx(X)+fry(X)+frz(X)
- def tcaxPy_Main(_i, _j, _n, _BT, _ET, _SK, _KT, _X, _Y, _A, _TXT):
- ASS_BUF = [] # used for saving ASS FX lines
- ###########butterfly##############
- butterfly = ["m 21 15 b 20 13 18 10 16 8 b 14 6 11 4 9 3 b 8 2 6 1 4 1 b 3 1 3 1 0 0 b 3 3 3 3 3 4 b 4 5 5 6 5 7 b 6 8 7 10 8 11 b 8 12 9 12 9 13 b 9 14 10 15 10 16 b 11 16 11 17 12 17 b 13 17 13 17 14 17 b 13 18 13 18 12 19 b 12 19 11 20 11 20 b 12 21 13 20 13 20 b 12 21 12 22 12 23 b 12 23 13 23 13 23 b 13 24 12 25 12 26 b 13 26 13 25 14 25 b 13 26 14 29 8 38 b 13 28 14 29 15 27 b 15 28 15 28 15 29 b 16 28 16 26 17 26 b 17 26 18 26 17 27 b 19 24 20 20 22 18 b 22 17 22 17 22 16 m 23 16 b 24 15 25 13 26 12 b 27 10 29 9 30 7 b 32 6 34 4 36 3 b 37 2 39 2 40 1 b 41 1 41 1 46 -1 b 42 2 41 3 41 4 b 40 5 40 6 39 7 b 38 8 38 10 37 11 b 36 12 36 14 35 15 b 34 16 33 16 32 17 b 32 18 33 18 33 19 b 33 19 34 20 34 20 b 33 20 32 20 31 20 b 32 21 33 22 34 23 b 33 23 33 23 32 23 b 33 24 33 25 34 26 b 33 26 33 25 32 25 b 32 26 33 28 38 38 b 33 28 32 27 31 27 b 31 28 31 27 32 29 b 31 28 31 27 30 26 b 30 27 30 27 30 28 b 29 27 29 26 28 25 b 28 26 28 26 28 27 b 28 26 27 26 27 25 b 26 22 25 20 23 18 " , "m 22 13 b 22 14 21 14 21 15 b 19 10 15 7 12 4 b 9 2 5 0 3 0 b 0 0 -1 0 0 2 b 1 4 4 7 4 9 b 6 11 7 12 8 15 b 9 18 11 17 13 17 b 11 18 10 19 10 20 b 10 21 13 21 10 22 b 10 23 8 25 11 25 b 9 26 9 28 10 28 b 11 30 9 33 8 35 b 7 36 7 38 7 39 b 9 38 9 37 9 36 b 10 35 10 32 12 32 b 13 33 13 31 14 31 b 14 32 16 32 15 30 b 18 30 18 27 18 26 b 18 23 21 20 21 17 b 22 18 21 19 21 21 b 21 22 21 23 22 23 m 22 13 b 22 14 23 14 23 15 b 25 11 27 8 31 5 b 35 2 37 1 39 0 b 45 -1 44 1 43 3 b 41 5 40 8 38 10 b 37 12 37 13 36 15 b 36 17 33 17 31 17 b 33 18 33 18 34 19 b 36 22 34 21 34 22 b 36 24 35 24 34 24 b 35 26 36 28 34 28 b 34 31 36 34 37 35 b 38 36 38 38 37 38 b 36 38 35 36 35 35 b 35 34 34 32 33 32 b 32 32 31 33 31 31 b 30 32 29 31 29 30 b 27 30 27 28 26 25 b 26 23 23 20 23 17 b 22 18 23 20 23 21 b 23 23 22 23 22 23 "]
- num = 150
- xs = _X + randint(200,300)
- ys = _Y + randint(-30,60)
- xc1 = _X + randint(100,200)
- yc1 = _Y + randint(-20,40)
- xc2 = _X + randint(0,100)
- yc2 = _Y + randint(-10,20)
- xe = _X - int(_A / 2)
- ye = _Y - int(_Fs / 2)
- points = Bezier3(num, xs, ys, xe, ye, xc1, yc1, xc2, yc2)
- COLOR = ["50FFD9","DEABF3","FFFF00","1300EF","39F53A","F443C3","1F43FA"]
- C1 = COLOR[randint(0,6)]
- PIC = butterfly[randint(0,1)]
- RAN1 = randint(100,130)
- for i in range(num):
- POS = pos(points[i][0], points[i][1])
- ts = _BT-num + (i * 1) + (_j * 10)
- te = _BT-num + ((i+1) * 1) + (_j * 10)
- ass_main(ASS_BUF, SubL(ts,te,2), an(5)+alpha1(150)+fsc(RAN1,RAN1)+bord(1)+color3(C1)+color1(C1)+blur(1.5)+frz(90)+frx(i * randint(1,3))+POS, "{\p3}" + PIC + "{\p0}")
- ts1 = _BT + 1 + (_j * 10)
- te1 = _BT+_SK+_KT
- e = ts1
- while e < te1 - 20:
- ass_main(ASS_BUF, SubL(e,e+30,2), an(5)+pos(_X - int(_A / 2),_Y - int(_Fs / 2))+alpha1(150)+color1(C1)+fsc(RAN1,RAN1)+bord(1)+color3(C1)+blur(1.5)+frz(90)+frx(randint(0,90))+t(frx(randint(0,90))), "{\p3}" + PIC + "{\p0}")
- e = e + 30
- ass_main(ASS_BUF, SubL(_BT-30,_BT+_SK),an(5)+pos(_X,_Y)+color1("FFFFFF")+color3("FFFFFF")+bord(1),_TXT)
- ###########fire##################
- fire_str = ('{\p5}m 0 0 b 8 1 9 -28 -2 -41 b 3 -23 -17 0 0 0{\p0}','{\p5}m 1 41 b 20 39 1 13 13 -11 b 5 1 -18 22 1 41{\p0}','{\p4}m 6 39 b 4 29 1 13 27 -37 b -1 -3 -15 34 6 39{\p0}','{\p5}m -3 43 b -9 22 -1 33 16 -47 b 1 3 -17 0 -3 43{\p0}')
- COLOR2 = ("007EFF","3F7EF6","0060FF")
- ts2 = _BT + _SK
- count = int(te1 - ts2)
- step = int(_FD / 10)
- PIX = TextPix(_Font, _TXT)
- points = PixPoints(PIX)
- pt_num = len(points)
- dx = _X - int(_A / 2 + 0.5) + PIX[0][0]
- dy = _Y - int(_Fs / 2 + 0.5) + PIX[0][1]
- for i in range(0, count, step):
- for j in range (3):
- C2 = COLOR2[randint(0,2)]
- pt = points[randint(0, pt_num - 1)]
- t0 = randint(int(ts2), int(te1))
- t1 = t0 + 30
- tmpz = randint(0, 359)
- tmpstr = fire_str[randint(0, 3)]
- x = dx + pt[0]
- y = dy + pt[1]
- ass_main(ASS_BUF, SubL(t0,t1, 10, Pix_Style), an(5)+move(x,y,x,y-25)+alpha1(100) + color1(C2) + alpha3(150) + color3(C2) +bord(3) + blur(3) + frz(tmpz) + t(fsc(120, 120) + bord(1) + fry(361) + frz(-57)) + fad(0, 200), tmpstr)
- ass_main(ASS_BUF, SubL(ts2,te1), an(5)+pos(_X,_Y)+color1("0000FF")+color3("002FFF")+bord(2)+blur(2),_TXT)
- ############ash#################
- dx1 = _X - int((_A + _Spacing) / 2 + 0.5) # 一个固定操作, 将an5的坐标转换为an7
- dy1 = _Y - int(_Fs / 2 + 0.5) # ASS特效默认采用an5坐标, TCAS特效则采用an7坐标
- # _txt PIX
- PIX = TextPix(_Font, _TXT) # Get a PIX object from normal text, PIX can be considered as image
- points = PixPoints(PIX) # Get points from the PIX object.
- pt_num = len(points)
- dx1 = _X - int((_A + _Spacing) / 2 + 0.5) + PIX[0][0]
- dy1 = _Y - int(_Fs / 2 + 0.5) + PIX[0][1]
- # draw PIX
- PIX_draw = draw2pix(PIC)
- PIX_draw = PixStrip(PIX_draw) # 裁剪空白边框部分, 可以提升效率等
- points_draw = PixPoints(PIX_draw)
- pt_num_draw = len(points_draw)
- # 因为两个点集的点数可能不同, 所以需要一个合理的映射, 以下算法只是一个简单示例
- num = pt_num_draw
- te2 = _ET
- for h in range(0,num,step):
- indice_text = randint(0, pt_num - 1)
- indice_draw = randint(0, pt_num_draw - 1)
- x = dx1 - int(_A / 2) + points[indice_text][0]
- y = dy1 - int(_Fs / 2) + points[indice_text][1]
- x_fin = _X - int(_A / 2) + points_draw[indice_draw][0]
- y_fin = _Y - int(_A / 2) + points_draw[indice_draw][1]
- DX = _X - int(_A / 2 + 0.5) + points_draw[i][0]
- DY = _Y - int(_Fs / 2 + 0.5) + points_draw[i][1]
- ass_main(ASS_BUF, SubL(te1-20+randint(0,40),te2+randint(-20,20),2),move(DX,DY,DX+randint(-5,40),DY+randint(-30,10))+color1(C1)+color3(C1)+bord(0)+alpha(100), PixPt())
- ass_main(ASS_BUF, SubL(te1,te2),an(5)+pos(_X,_Y)+color1("A09E99")+color3("CCCCCC")+bord(2)+blur(2),_TXT)
- return (ASS_BUF,None)
复制代码 不管好坏...算是做了个结束,收尾的地方做的不是很好,矢量图散成粒子控制的还是不是很好,定位,时间,不知道为什么调整不好,试了好多种办法,最后还是只能用最简单的随机定位...把手里的最后一个想法勉强实现了。。。好吧...我还是变懒了...
draw2pix.py
(629 Bytes, 下载次数: 3029)
会用到的附件,放到工程文件夹下面 |
-
1
查看全部评分
-
|