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

 找回密码
 新人加入
查看: 4311|回复: 17

[入场效果] SylFX_out_01 [复制链接]

Rank: 4

发表于 2014-12-13 00:04:42 |显示全部楼层
本帖最后由 ALKOON 于 2014-12-14 13:16 编辑

Hi everyone

This is a simple Fx, actually first test I make by NyuFx(Lua), so I thought it's better to make it by using TCAX
but unfortunately the second FX_02 wasn't as I want, so I hope from  Milky. or saiy to find a sulation for this problem that I got XD

NyuFx_Lua(Demo): http://www.dailymotion.com/video/x2cdr55_demotest_creation

TCAX_Python(Demo) : http://www.dailymotion.com/video/x2cert7_tcax-simple-test


Script:
  1. from tcaxPy import *
  2. from pixLibs.ImageStone.pixStone import *

  3. def tcaxPy_Init():
  4.     global _FD         
  5.     global _Fs
  6.     global _Length
  7.     global _Width
  8.     global _Height
  9.     global Font
  10.     global FontOut
  11.     global PIX_tex
  12.     global PIX_tex2

  13.     _FD = 1000 / GetVal(val_FXFPS)
  14.     _Fs = GetVal(val_FontSize)
  15.     _Length = GetVal(val_TextLength)
  16.     _Height   = GetVal(val_TextHeight)
  17.     _Width    = GetVal(val_TextWidth)
  18.     _FontFileName = GetVal(val_FontFileName)
  19.     _FaceID       = GetVal(val_FaceID)
  20.     Font    = InitFont(_FontFileName, _FaceID, _Fs, GetVal(val_Spacing), GetVal(val_SpaceScale), MakeRGB(0, 0, 0), 0, 0)   
  21.     FontOut = InitFont(_FontFileName, _FaceID, _Fs, GetVal(val_Spacing), GetVal(val_SpaceScale), MakeRGB(0, 0, 0), 2, 0)   
  22.     PIX_tex = ImagePix(abspath('img (13).png'), _Fs, 0)   
  23.     PIX_tex2 = ImagePix(abspath('img (13).png'))   
  24.    

  25. def tcaxPy_Fin():
  26.     FinFont(Font)


  27. def tcaxPy_Main(_i, _j, _n, _BT, _ET, _SK, _KT, _x, _y, _a, _txt):
  28.     ASS_BUF  = []         
  29.     TCAS_BUF = []        


  30.     PIX_t = TextPix(Font, _txt)              

  31.     dx = _x - int(_a / 2 + 0.5) + PIX_t[0][0]
  32.     dy = _y - int(_Fs / 2 + 0.5) + PIX_t[0][1]
  33.    
  34.     PIX_t = PixTexture(PIX_t, PIX_tex)     
  35.     PIX_out = TextPix(FontOut, _txt)      
  36.     PIX_out = PixTexture(PIX_out, PIX_tex2)      
  37.     PIX_out = PixColorMul(PIX_out, 1, 1, 1, 1)   
  38.     PIX_out = PixBlur(PIX_out, 0)           
  39.     PIX_ori = CombinePixs(PIX_out, PIX_t)   
  40.     points = PixPoints(PIX_ori)
  41.     pt_num = len(points)
  42.     pt = pt_num
  43.          
  44.     x = dx  
  45.     y = dy   

  46.    
  47.     for i in range(pt):
  48.         w = points[i][0]
  49.         h = points[i][1]
  50.         idx  = 4 * (h * PIX_ori[1][0] + w)            
  51.         PixR = PIX_ori[2][idx + 0]                        
  52.         PixG = PIX_ori[2][idx + 1]                    
  53.         PixB = PIX_ori[2][idx + 2]                       
  54.         PixA = PIX_ori[2][idx + 3]                    
  55.         
  56.         x = dx + points[i][0]
  57.         y = dy + points[i][1]

  58.         syl_dur = _KT
  59.         start = _BT
  60.         end = _BT + _SK
  61.         w_mov = (points[i][0]/ _Width[_i] [_j])*syl_dur
  62.          
  63.         EFT1 = an(7)+shad(0)+blur(2)+bord(2)+move(x,y,x,y)+alpha3(242)+fscxy(90,90)+alpha1(255-PixA)+color1(FmtRGB(PixR,PixG,PixB)) +color3(FmtRGB(PixR,PixG,PixB))   
  64.         ass_main(ASS_BUF, SubL(start,end+w_mov,3,Pix_Style), EFT1, PixPt())

  65.         ### --(I tried to cut the text_pixle from half (make it half-falf, but it's not coming as I want so I think sthe problem is with _Height[_i][_j] I guess  )-- ###

  66.         py = points[i][1] < _Height[_i][_j] / 2 and -1 or 1  

  67.         xr_mov = -70 + randint(-10,10)
  68.         yr_mov = randint(-15,15)  
  69.         start1 = end+w_mov
  70.         end1 = start1 +100
  71.         ttt = end - start
  72.         x1 = x+xr_mov
  73.         y1 = y+yr_mov
  74.         y2 = y1*py
  75.         FRZ = t(frz(580))+t(frz(-330))
  76.         

  77.         #FX_01 (Normal-Frz)
  78.         if _i ==0 :
  79.             EFT1 = an(7)+FRZ+blur(2)+bord(2)+org(x,y)+move(x+randint(-1,1),y,x1,y1)+fad(0,150)+alpha3(245)+fscxy(90,90)+alpha1(255-PixA) +color1(FmtRGB(PixR,PixG,PixB)) +color3(FmtRGB(PixR,PixG,PixB))
  80.             ass_main(ASS_BUF, SubL(start1,end1,3,Pix_Style), EFT1, PixPt())

  81.         #FX_012 ( Pixels (half\falf) )
  82.         if _i == 1:
  83.             EFT1 = an(7)+FRZ+blur(2)+bord(2)+org(x,y)+move(x+randint(-1,1),y,x1,y2)+fad(0,150)+alpha3(240)+fscxy(90,90)+alpha1(255-PixA) +color1(FmtRGB(PixR,PixG,PixB)) +color3(FmtRGB(PixR,PixG,PixB))
  84.             ass_main(ASS_BUF, SubL(start1,end1,3,Pix_Style), EFT1, PixPt())

  85.         #FX_03 (pixels Down)
  86.         if _i == 2:
  87.             EFT1 = an(7)+blur(2)+bord(2)+move(x+randint(-1,1),y,x+randint(-5,5),y+randint(35,45))+fad(0,150)+alpha3(240)+fscxy(90,90)+alpha1(255-PixA) +color1(FmtRGB(PixR,PixG,PixB)) +color3(FmtRGB(PixR,PixG,PixB))
  88.             ass_main(ASS_BUF, SubL(start1,end1,3,Pix_Style), EFT1, PixPt())


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

Rank: 4

发表于 2014-12-13 01:55:37 |显示全部楼层
TCC
  1. # tcc file version

  2. < tcc file version = 1.0 >


  3. # mode configuration

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


  10. # py settings

  11. < py file = k_test.py >     < beg line = 1 >    < end line = 10 >


  12. # main settings

  13. < k-timed ass file = test.ass >
  14. < font file = hockey.ttf >    < font face id = 1 >    < font size = 40 >
  15. < fx width = 1280 >    < fx height = 720 >    < fx fps = 23.976 >
  16. < alignment = 8 >
  17. < x offset = 0 >    < y offset = 20 >
  18. < spacing = 1 >    < space scale = 1.0 >


  19. # style settings

  20. < font face name = "" >
  21. < bord = 0 >    < shad = 0 >
  22. < primary color = F0E7DA >    < secondary color = FFFFFF >    < outline color = 000066 >    < back color = 000000 >
  23. < primary alpha = 0 >    < secondary alpha = 255 >    < outline alpha = 0 >    < back alpha = 255 >


  24. # additional settings

  25. < blur = 0.0 >
复制代码

Rank: 4

发表于 2014-12-13 10:20:45 |显示全部楼层
本帖最后由 几年 于 2014-12-13 10:45 编辑

video preview 链接:http://pan.baidu.com/s/1bngwl1l 密码:pri6
here is my guess,text height include descent and ascent,in general,when draw rectangle with upper-left point and width,height,it's not just the minimum bounding,here is a visual result from Aegisub,most parser do it like this way.
dummy_001_0.png

boxTest.zip (1.45 KB, 下载次数: 1888)

Rank: 4

发表于 2014-12-13 10:37:58 |显示全部楼层
本帖最后由 ALKOON 于 2014-12-13 10:39 编辑


Actually I already know that, I can make it by auto.4 or by using NyuFX, I was doing that since 2010 & there's many ways, but because I'm not familiar with TCAX -_-", anyway I'm not going to fix this one, it's up to who care to use this kind of fx or who will use my script

thank u =D

Rank: 4

发表于 2014-12-13 10:50:21 |显示全部楼层
ALKOON 发表于 2014-12-13 10:37
Actually I already know that, I can make it by auto.4 or by using NyuFX, I was doing that since 201 ...

anyway,thanks for sharing,nice effect.:P

Rank: 4

发表于 2014-12-13 19:25:21 |显示全部楼层
几年 发表于 2014-12-13 10:50
anyway,thanks for sharing,nice effect.:P

Most welcome =D

Administrator

TCAX Dev.

Rank: 7Rank: 7Rank: 7

发表于 2014-12-14 16:14:37 |显示全部楼层
Cool effect, thanks for your sharing, ALKOON :)

values of points (i.e. Pixel xy-Coordinates) retrieved by PixPoints(), are exactly between [(0, 0), (width - 1, height - 1)]
here width and height construct the minimal box that holds the text



2014-12-14_165437.jpg


It seems that the cut does going through the middle of every text.

------------------------------------------------------------------------------------------------------------

TCAX using FreeType library as its built-in font engine (to retrive metrics, pixels, etc.)

some links that I thought may be helpful

http://www.tcax.org/forum.php?mod=viewthread&tid=59    (http://freetype.sourceforge.net/ ... tutorial/step2.html)

http://www.tcax.org/forum.php?mod=viewthread&tid=38

http://www.tcax.org/forum.php?mod=viewthread&tid=32

http://www.tcax.org/forum.php?mod=viewthread&tid=31

http://www.tcax.org/forum.php?mo ... =1079&fromuid=2

Rank: 4

发表于 2014-12-15 16:31:09 |显示全部楼层
Thank you milky =D
but don't you think it's too much that I have to read ? XD
anyway it's helpful, I'll read when I have time ^^.

Administrator

TCAX Dev.

Rank: 7Rank: 7Rank: 7

发表于 2014-12-15 21:05:09 |显示全部楼层
ALKOON 发表于 2014-12-15 16:31
Thank you milky =D
but don't you think it's too much that I have to read ? XD
anyway it's helpful, I ...

:) Yes, I think so. But I cannot figure out exactly what problem are you facing, so, I give it back to you.

I wonder whether it's convenient for you to draw a simple graph to show your idea about how the pixels (particles from text) should move?

Rank: 4

发表于 2014-12-16 00:31:11 |显示全部楼层
As u said, the cut should going through the middle of every text.

like that https://mega.co.nz/#!VU0FyCbZ!WV ... _BRRXDvLK-IKM1sPQyI

Administrator

Shanzhai Pro.

Rank: 7Rank: 7Rank: 7

发表于 2014-12-16 14:33:32 |显示全部楼层
GJ!
Maybe you can try this
"py = points[1] < round(PIX_ori[1][1]/2) and -1 or 1"
instead of
"py = points[1] < _Height[_i][_j] / 2 and -1 or 1"

If you want to know the structure of PIX, you can read this
http://www.tcax.org/docs/tcaxLib/struct_p_i_x.html

Rank: 4

发表于 2014-12-16 16:47:27 |显示全部楼层
本帖最后由 ALKOON 于 2014-12-16 16:48 编辑

round(PIX_ori[1][1])
It's better than
_Height[_i][_j]

but not going exactly through the middle of every text .but when I changed the font (capital letters), it's going through the middle of every text when i used _Height[_i][_j]
anyway thank u milky and saiy =D
I will try later again

Rank: 4

发表于 2014-12-16 17:21:01 |显示全部楼层
I can't figure out why you are trying to get through the middle of every text,if so,y coordinate of every split position are different,to make these y coordinates in the same line,need fix the position of every text,but it will cause odd result.

NyuFx:
try
convert.text_to_shape
shape.bounding

TCAX:
TextOutlineDraw

Administrator

TCAX Dev.

Rank: 7Rank: 7Rank: 7

发表于 2014-12-16 21:47:30 |显示全部楼层
ALKOON 发表于 2014-12-16 16:47
round(PIX_ori[1][1])
It's better than
_Height[_i][_j]

_Height[_i][_j] should be equal with the original PIX[1][1] (PIX_t), since 'PIX' has the structure ((initX, initY), (width, height),...), but 'PIX' may be manipulated, applied with filters, transformations, etc. some of them will enlarge or reduce PIX, such as PixBlur (enlarges a bit), so in this case _Height[_i][_j] will be smaller than PIX[1][1] (what's more, after combination with PIX generated from FontOut font, PIX will be even larger, _Height[_i][_j] should be with the same metric as PIXs directly generated from Font)

so, as a conclusion,
the solution provided by saiyaku is better.

but still cannot figure why not cut exactly through every middle of texts,
I suggest you using tcaxLog() --- to dump information into log files, or simply use Python built-in print(),
and with the help of Pause() function, to do some debug.

Rank: 4

发表于 2015-8-17 20:38:24 |显示全部楼层
完全没看懂大神之间的对话,而且不会用

Rank: 4

发表于 2016-3-21 13:51:30 |显示全部楼层
牛牛牛

Rank: 4

发表于 2016-6-7 16:55:51 |显示全部楼层
高手啊,太强了

Rank: 4

发表于 2018-9-12 22:04:29 |显示全部楼层
感谢分享!!!
您需要登录后才可以回帖 登录 | 新人加入

GitHub|TCAX 主页

GMT+8, 2024-4-18 23:01

Powered by Discuz! X2

© 2001-2011 Comsenz Inc.

回顶部
RealH