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

 找回密码
 新人加入
查看: 4269|回复: 3

[完整特效] [youkaze]014_Boku_H_ED [复制链接]

Moderator

youkaze

Rank: 5Rank: 5

发表于 2012-11-27 11:14:20 |显示全部楼层
  1. from tcaxPy import *
  2. from gdiFont import *  #加入GDIfont模块
  3. from draw2pix import *


  4. def tcaxPy_Init():



  5.     global _FontFileName   
  6.     global _FaceID
  7.     global _Fs
  8.     global _TextWidth
  9.     global _TextHeight
  10.     global _TextLength
  11.     global _TextAdvDiff
  12.     global _ResolutionX
  13.     global _OffsetX
  14.     global _FD
  15.     global _Spacing     # 字体间距


  16.     _FontFileName = GetVal(val_FontFileName)
  17.     _FaceID       = GetVal(val_FaceID)
  18.     _Fs           = GetVal(val_FontSize)
  19.     _TextHeight   = GetVal(val_TextHeight)
  20.     _TextWidth    = GetVal(val_TextWidth)
  21.     _TextLength   = GetVal(val_TextLength)
  22.     _TextAdvDiff  = GetVal(val_TextAdvanceDiff)
  23.     _ResolutionX  = GetVal(val_ResolutionX)
  24.     _OffsetX      = GetVal(val_OffsetX)
  25.     _FD           = 1000 / GetVal(val_FXFPS)
  26.     _Spacing = GetVal(val_Spacing)



  27.     global GdiFont   #GDIfont
  28.    
  29.     GdiFont = gfInitFont(GetVal(val_FontFaceName), _Fs, GetVal(val_Spacing), GetVal(val_SpaceScale), 0, False)   #GDIfont
  30.    
  31.     global Font
  32.     Font = InitFont(GetVal(val_FontFileName), GetVal(val_FaceID), _Fs, GetVal(val_Spacing), GetVal(val_SpaceScale), 0xFFFFFF, 0, 0)
  33.     cairo_init(100, 100)

  34. def tcaxPy_Fin():
  35.     gfFinFont(GdiFont)   #GDIfont
  36.    
  37.     FinFont(Font)



  38. def tcaxPy_Main(_i, _j, _n, _BT, _ET, _SK, _KT, _x, _y, _a, _txt):

  39.     ASS_BUF = []
  40.    
  41.     ass_main(ASS_BUF, SubL(_BT-90+_j*5,_BT-30+_j*5,2),an(7)+pos(_x, _y-12)+org(_x,_y)+t(fry(90))+fscx(130)+fscy(130)+color1("9729FF")+bord(0)+fad(100,0), "{\p1}m 0 23 b 6 18 11 13 14 8 b 16 4 16 -2 11 -3 b 6 -4 3 -2 0 0 b 1 1 2 3 3 5 b 4 0 8 1 10 2 b 12 3 12 5 11 7 b 9 11 5 16 2 20 b 2 15 3 9 3 5 b 2 3 1 1 0 0 b -1 1 -2 3 -3 5 b -3 9 -2 15 -2 20 b -5 16 -9 11 -11 7 b -12 5 -12 3 -10 2 b -8 1 -4 0 -3 5 b -2 3 -1 1 0 0 b -3 -2 -6 -4 -10 -3 b -16 -2 -16 4 -14 8 b -11 13 -6 18 0 23 ")
  42.    
  43.     ass_main(ASS_BUF, SubL(_BT-30+_j*5,_BT+(_j+1)*5,1),pos(_x, _y)+org(_x,_y)+fry(270)+t(fry(360))+bord(2), _txt)
  44.     ass_main(ASS_BUF, SubL(_BT+(_j+1)*5,_BT+_SK,1),pos(_x, _y)+bord(2), _txt)
  45.    
  46.    
  47.    
  48.     dx = _x - int((_a + _Spacing) / 2 + 0.5)     # 一个固定操作, 将an5的坐标转换为an7
  49.     dy = _y - int(_Fs / 2 + 0.5)                 # ASS特效默认采用an5坐标, TCAS特效则采用an7坐标
  50.     # _txt PIX
  51.    
  52.     points = gfGetPoints(GdiFont, _txt)  #GDIfont

  53.     PIX = PixFromPoints(points)   #GDIfont
  54.     points1 = PixPoints(PIX)
  55.     pt_num = len(points1)
  56.    
  57.     dx = _x - int((_a + GetVal(val_Spacing)) / 2 + 0.5) + PIX[0][0]
  58.     dy = _y - int(_Fs / 2 + 0.5) + PIX[0][1]
  59.     # draw PIX
  60.     PIX_draw = draw2pix('m 0 0 m 0 23 b 6 18 11 13 14 8 b 16 4 16 -2 11 -3 b 6 -4 3 -2 0 0 b 1 1 2 3 3 5 b 4 0 8 1 10 2 b 12 3 12 5 11 7 b 9 11 5 16 2 20 b 2 15 3 9 3 5 b 2 3 1 1 0 0 b -1 1 -2 3 -3 5 b -3 9 -2 15 -2 20 b -5 16 -9 11 -11 7 b -12 5 -12 3 -10 2 b -8 1 -4 0 -3 5 b -2 3 -1 1 0 0 b -3 -2 -6 -4 -10 -3 b -16 -2 -16 4 -14 8 b -11 13 -6 18 0 23 ')
  61.     PIX_draw = PixStrip(PIX_draw)    # 裁剪空白边框部分, 可以提升效率等
  62.     points_draw = PixPoints(PIX_draw)
  63.     pt_num_draw = len(points_draw)
  64.    
  65.     # 因为两个点集的点数可能不同, 所以需要一个合理的映射, 以下算法只是一个简单示例
  66.     num = max(pt_num, pt_num_draw)
  67.     ts = _BT+_SK
  68.     te = _BT+_SK+_KT
  69.     for i in range(pt_num_draw):
  70.         indice_text = randint(0, pt_num - 1)
  71.         indice_draw = i
  72.         x = dx + points1[indice_text][0]
  73.         y = dy + points1[indice_text][1]
  74.         x_fin = _x + points_draw[indice_draw][0]
  75.         y_fin = _y + points_draw[indice_draw][1]
  76.         DX = _x + points_draw[i][0]
  77.         DY = _y + points_draw[i][1]
  78.         EFT = move(x,y,x_fin-_a/2, y_fin-_Fs/2+5) + color1('FFFFFF') + alpha(255 - PIX[2][4 * (points1[indice_text][1] * PIX[1][0] + points1[indice_text][0]) + 3])
  79.         ass_main(ASS_BUF, SubL(ts, te+70+randint(-30,30), 0, Pix_Style), EFT, PixPt())
  80.         
  81.         ass_main(ASS_BUF, SubL(te+70+randint(-30,30), te+150+randint(-30,30), 0, Pix_Style), move(DX-_a/2,DY-_Fs/2+5,_x-3,_y-30,700,1000) + color1('FFFFFF')+alpha(255 - points_draw[indice_draw][2]), PixPt())
  82.    
  83.    
  84.    
  85.     return (ASS_BUF, None)
复制代码
运行此脚本需要以下附带文件
draw2pix.py (792 Bytes, 下载次数: 1858)
1

查看全部评分

Rank: 4

发表于 2014-4-21 02:55:26 |显示全部楼层
四月君大大我这又是什么情况啊?parse出的ASS字幕能正常显示,效果也能完美的实现,但图片中的第二句我就看不懂了?
这是指init函数中初始化的变量有两个没有用上吗?

图片

图片

Administrator

TCAX Dev.

Rank: 7Rank: 7Rank: 7

发表于 2014-4-21 21:26:45 |显示全部楼层
小星佟 发表于 2014-4-21 02:55
四月君大大我这又是什么情况啊?parse出的ASS字幕能正常显示,效果也能完美的实现,但图片中的第二句我就看 ...

这个脚本没定义(使用)tcaxPy_Init函数. 所以tcc文件中, 要置为 false

Rank: 4

发表于 2014-4-21 21:32:52 |显示全部楼层
milkyjing 发表于 2014-4-21 21:26
这个脚本没定义(使用)tcaxPy_Init函数. 所以tcc文件中, 要置为 false

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

GitHub|TCAX 主页

GMT+8, 2024-4-18 09:19

Powered by Discuz! X2

© 2001-2011 Comsenz Inc.

回顶部
RealH