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

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

[未解决] TypeError: 'NoneType' object is not subscriptable [复制链接]

Rank: 4

跳转到指定楼层
楼主
发表于 2022-1-9 00:17:29 |只看该作者 |倒序浏览
本帖最后由 Alex 于 2022-2-7 22:48 编辑

Hi, I trying to use Bezier function which is in util.tcCurve but I got an error
  1. from tcaxPy import *
  2. from util.tcCurve import *

  3. def tcaxPy_Init():
  4.     global _Fs
  5.     global _FD           
  6.     global _Spacing      
  7.     global Font        
  8.     _Fs = GetVal(val_FontSize)
  9.     _FD = 1000 / GetVal(val_FXFPS)
  10.     _FontFileName = GetVal(val_FontFileName)
  11.     _FaceID = GetVal(val_FaceID)
  12.     _Spacing = GetVal(val_Spacing)
  13.     Font = InitFont(_FontFileName, _FaceID, _Fs, _Spacing, GetVal(val_SpaceScale), MakeRGB(255, 255, 255), 0, False)

  14. def tcaxPy_Fin():
  15.     FinFont(Font)

  16. def tcaxPy_Main(_i, _j, _n, _start, _end, _elapk, _k, _x, _y, _a, _txt):
  17.     ASS_BUF  = []        
  18.     TCAS_BUF = []        

  19.     dx = _x  - int((_a + _Spacing) / 2 + 0.5)   
  20.     dy = _y - int(_Fs / 2 + 0.5)               
  21.      
  22.     EFT = move(_x, _y,_x, _y)  + fad(90, 0) + shad(0)  + bord(0)
  23.     ass_main(ASS_BUF, SubL(_start, _end, 3), EFT, _txt)

  24.     PIX = TextPix(Font,_txt)
  25.     points = PixPoints(PIX)         
  26.     pt_num = len(points)
  27.     dx = _x - int((_a + _Spacing) / 2 + 0.5) + PIX[0][0]
  28.     dy = _y - int(_Fs / 2 + 0.5) + PIX[0][1] + 1


  29.     inix = dx - randint(15, 30)  
  30.     tab_posx = (inix + randint(-40, 40), inix + randint(-130, 130), inix + randint(-130, 130), inix + randint(-40, 40))     
  31.     tab_posy = (dy + _Fs + randint(-15, 20), _y + randint(-100, 100), _y + randint(-110, 110), dy + randint(-15, 20))      


  32.     Points = [(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])]
  33.     posb = []

  34.     for i in range(pt_num ):

  35.         indice_text = randint(0, pt_num - 1)
  36.         indice_pos = randint(0, pt_num  - 1)

  37.         x = dx + points[i][0]
  38.         y = dy + points[i][1]


  39.         PP=  posb.append(Bezier(Points,pt_num))

  40.         x_fin = PP[i][0]
  41.         y_fin = PP[i][1]

  42.         rand_ini = randint(50, 400)
  43.         ts = _start +  _elapk  + _j * 2.5
  44.         te = ts + _k + 70 + _j * 2.5
  45.         rand_end = 10 * (te - ts)
  46.         EFT = move(x, y, x_fin, y_fin, rand_ini, rand_end) + fad(0, randint(90,150)) + color1(col) + shad(0) + bord(0) + alpha(255 - points[indice_text][2])
  47.         ass_main(ASS_BUF, SubL(ts, te, 0, Pix_Style), EFT, PixPt())

  48.     return (ASS_BUF, TCAS_BUF)
复制代码

Capture.PNG (20.1 KB, 下载次数: 1710)

Capture.PNG

Rank: 4

沙发
发表于 2022-1-9 00:26:47 |只看该作者
?????

Rank: 4

板凳
发表于 2022-2-7 23:34:07 |只看该作者
本帖最后由 Alex 于 2022-2-7 23:59 编辑

I just fixed the error but the pixels not moving in curve?
There's an issue with position!! move(165,39,-135665737821,-21123381180,348,930)

PP.zip (171.21 KB, 下载次数: 2289)
  1. from tcaxPy import *

  2. from util.tcCurve import *

  3. def tcaxPy_Init():
  4.     global _Fs
  5.     global _FD           
  6.     global _Spacing      
  7.     global Font        
  8.     _Fs = GetVal(val_FontSize)
  9.     _FD = 1000 / GetVal(val_FXFPS)
  10.     _FontFileName = GetVal(val_FontFileName)
  11.     _FaceID = GetVal(val_FaceID)
  12.     _Spacing = GetVal(val_Spacing)
  13.     Font = InitFont(_FontFileName, _FaceID, _Fs, _Spacing, GetVal(val_SpaceScale), MakeRGB(255, 255, 255), 0, False)

  14. def tcaxPy_Fin():
  15.     FinFont(Font)

  16. def tcaxPy_Main(_i, _j, _n, _start, _end, _elapk, _k, _x, _y, _a, _txt):
  17.     ASS_BUF  = []        
  18.     TCAS_BUF = []        

  19.     dx = _x  - int((_a + _Spacing) / 2 + 0.5)   
  20.     dy = _y - int(_Fs / 2 + 0.5)               
  21.      
  22.     EFT = move(_x, _y,_x, _y)  + fad(90, 0) + shad(0)  + bord(0)
  23.     ass_main(ASS_BUF, SubL(_start, _start+ _elapk, 3), EFT, _txt)

  24.     PIX = TextPix(Font,_txt)
  25.     points = PixPoints(PIX)         
  26.     pt_num = len(points)
  27.     dx = _x - int((_a + _Spacing) / 2 + 0.5) + PIX[0][0]
  28.     dy = _y - int(_Fs / 2 + 0.5) + PIX[0][1] + 1


  29.     inix = dx - randint(15, 30)  
  30.     tab_posx = (inix + randint(-40, 40), inix + randint(-130, 130), inix + randint(-130, 130), inix + randint(-40, 40))     
  31.     tab_posy = (dy + _Fs + randint(-15, 20), _y + randint(-100, 100), _y + randint(-110, 110), dy + randint(-15, 20))      


  32.     Points = [(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])]
  33.     posb = []

  34.     for i in range(pt_num ):

  35.         indice_text = randint(0, pt_num - 1)
  36.         indice_pos = randint(0, pt_num  - 1)

  37.         x = dx + points[i][0]
  38.         y = dy + points[i][1]

  39.         posb.append(Bezier(Points,pt_num))

  40.         x_fin = posb[i ][0]
  41.         y_fin = posb[i][1]

  42.         rand_ini = randint(50, 400)
  43.         ts = _start +  _elapk  + _j * 2.5
  44.         te = ts + _k + 70 + _j * 2.5
  45.         rand_end = 10 * (te - ts)
  46.         EFT = move(x, y, x_fin, y_fin, rand_ini, rand_end) + shad(0) + bord(0) + alpha(255 - points[indice_text][2])
  47.         ass_main(ASS_BUF, SubL(ts, te, 0, Pix_Style), EFT, PixPt())

  48.     return (ASS_BUF, TCAS_BUF)
复制代码

Administrator

TCAX Dev.

Rank: 7Rank: 7Rank: 7

地板
发表于 2022-2-10 22:11:04 |只看该作者

Rank: 4

5#
发表于 2022-2-11 01:02:44 |只看该作者
本帖最后由 Alex 于 2022-2-11 01:07 编辑

Thanks for responding Milky
I have looked at the links that you have mentioned it as ref , still there's an issue with the pixels movement in the bezi

test1.zip (73.02 KB, 下载次数: 2286)
  1. from tcaxPy import *
  2. from util.tcCurve import *
  3. from util.gdiFont import *

  4. def tcaxPy_Init():
  5.     global _Fs
  6.     global _FD           
  7.     global _Spacing      
  8.     global Font        
  9.     global GdiFont      
  10.     _Fs = GetVal(val_FontSize)
  11.     _FD = 1000 / GetVal(val_FXFPS)
  12.     _FontFileName = GetVal(val_FontFileName)
  13.     _FaceID = GetVal(val_FaceID)
  14.     _Spacing = GetVal(val_Spacing)
  15.     GdiFont = gfInitFont(GetVal(val_FontFaceName), _Fs, _Spacing, GetVal(val_SpaceScale), 0, False)

  16. def tcaxPy_Fin():
  17.     gfFinFont(GdiFont)

  18. def tcaxPy_Main(_i, _j, _n, _start, _end, _elapk, _k, _x, _y, _a, _txt):
  19.     ASS_BUF  = []        
  20.     TCAS_BUF = []        

  21.     dx = _x  - int((_a + _Spacing) / 2 + 0.5)   
  22.     dy = _y - int(_Fs / 2 + 0.5)               
  23.      
  24.     EFT = move(_x, _y,_x, _y)  + fad(90, 0) + shad(0)  + bord(0)
  25.     ass_main(ASS_BUF, SubL(_start, _start+ _elapk, 3), EFT, _txt)

  26.     points = gfGetPoints(GdiFont, _txt)
  27.     pt_num = len(points)
  28.     dx = _x - int((_a + _Spacing) / 2 + 0.5)
  29.     dy = _y - int(_Fs / 2 + 0.5)


  30.     inix = dx - randint(15, 30)  
  31.     tab_posx = (inix + randint(-40, 40), inix + randint(-130, 130), inix + randint(-130, 130), inix + randint(-40, 40))     
  32.     tab_posy = (dy + _Fs + randint(-15, 20), _y + randint(-100, 100), _y + randint(-110, 110), dy + randint(-15, 20))      

  33.     maxi = int(tab_posy[0] - tab_posy[3]) + 90
  34.     Points = [(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])]
  35.     bucle = max(pt_num, maxi)
  36.     posb = []

  37.     for i in range(pt_num):

  38.         indice_text = randint(0, pt_num - 1)
  39.         indice_pos = randint(0, maxi - 1)

  40.         x = dx + points[indice_text][0]
  41.         y = dy + points[indice_text][1]

  42.         posb.append(Bezier(Points,pt_num))
  43.         x_fin =  posb[i][0]
  44.         y_fin =  posb[i][1]

  45.         rand_ini = randint(50, 400)
  46.         ts = _start +  _elapk  + _j * 2.5
  47.         te = ts + _k + 70 + _j * 2.5
  48.         rand_end = 10 * (te - ts)
  49.         EFT = move(x, y, x_fin, y_fin, rand_ini, rand_end) + shad(0) + bord(0) + alpha(255 - points[indice_text][2])
  50.         ass_main(ASS_BUF, SubL(ts, te, 0, Pix_Style), EFT, PixPt())

  51.     return (ASS_BUF, TCAS_BUF)
复制代码
When I tired to do

x_fin =  posb[indice_pos ][0]
y_fin =  posb[indice_pos ][1]

It says list index out of range!
您需要登录后才可以回帖 登录 | 新人加入

GitHub|TCAX 主页

GMT+8, 2024-11-22 01:28

Powered by Discuz! X2

© 2001-2011 Comsenz Inc.

回顶部
RealH