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

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

[已解决] border_pixels! [复制链接]

Administrator

TCAX Dev.

Rank: 7Rank: 7Rank: 7

楼主
发表于 2013-11-12 22:43:25 |显示全部楼层
Alex 发表于 2013-11-12 14:14
hmmm. I didn't get you
do I have to focus what written in red color?

yes, focus on the text in red, indeed, there are two kinds of functions, to get a PIX structure that only contain the boarder pixels, the other, get points of the boarder.

below is a demo of usage of TextOutlinePoints.
  1. from tcaxPy import *

  2. def tcaxPy_Init():
  3.     global _Fs
  4.     global Font
  5.     _Fs = GetVal(val_FontSize)
  6.     Font = InitFont(GetVal(val_FontFileName), GetVal(val_FaceID), _Fs, GetVal(val_Spacing), GetVal(val_SpaceScale), 0xFFFFFF, 0, 0)

  7. def tcaxPy_Fin():
  8.     FinFont(Font)

  9. def tcaxPy_Main(_i, _j, _n, _BT, _ET, _SK, _KT, _X, _Y, _A, _TXT):

  10.     ASS_BUF = []
  11.     TCS_BUF = []

  12.     ass_main(ASS_BUF, SubL(_BT + 200, _ET), pos(_X, _Y) + color1('00FFFF') + bord(0) + blur(4) + fad(400, 0), _TXT)

  13.     dx = _X - int(_A / 2 + 0.5)
  14.     dy = _Y - int(_Fs / 2 + 0.5)
  15.     outline = TextOutlinePoints(Font, _TXT, 1.0)
  16.     num = len(outline)
  17.     dur = 200
  18.     for i in range(num):
  19.         ts = _BT + dur * i / num
  20.         te = _ET
  21.         x = dx + outline[i][0]
  22.         y = dy + outline[i][1]
  23.         EFT = pos(x, y) + alpha1(0) + alpha3(150) + alpha4(200) + bord(1) + shad(1) + be(1) + \
  24.               color1('0000FF') + color3('FF00FF') + color4('FFFF00') + fad(200, 0)
  25.         ass_main(ASS_BUF, SubL(ts, te, 1, Pix_Style), EFT, PixPt())

  26.     return (ASS_BUF, TCS_BUF)
复制代码

Administrator

TCAX Dev.

Rank: 7Rank: 7Rank: 7

沙发
发表于 2013-11-12 22:52:04 |显示全部楼层
Alex 发表于 2013-11-12 14:14
hmmm. I didn't get you
do I have to focus what written in red color?

moreover, PIX object can be converted to Points object, vice versa.
  1. FontOut = InitFont(_FontFileName, _FaceID, _Fs, _Spacing, GetVal(val_SpaceScale), 0xFFFFFF, 3, True)
  2. PIX = TextPix(FontOut, _txt)
复制代码
the PIX will contain pixels that shows a text whose boarder is 3, and with main structure hollowed.

you can use the following code to debug
  1. SavePix(abspath("pix.png"), PIX)
  2. Pause()
复制代码
btw, by using tcax's drawing utility, the cairo module, you can convert any vectorial drawing into pixels bitmaps. for your ref. http://www.tcax.org/forum.php?mod=viewthread&tid=208

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

GitHub|TCAX 主页

GMT+8, 2024-5-7 21:09

Powered by Discuz! X2

© 2001-2011 Comsenz Inc.

回顶部
RealH