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

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

[已解决] PixTexture color! [复制链接]

Rank: 4

跳转到指定楼层
楼主
发表于 2013-11-3 15:09:09 |只看该作者 |正序浏览
When I'm using PixTexture the colors of the syllable some of them not same, some of them have more alpha


Untitled32.png

before in NyuFx have same problem but Youka have fixed

Administrator

TCAX Dev.

Rank: 7Rank: 7Rank: 7

25#
发表于 2013-11-25 21:44:12 |只看该作者
Alex 发表于 2013-11-19 14:45
Hahaha... I see that, I miss you XD
Anyway.  I didn't use pixels its shape only and the position is  ...

Sorry for the late reply, busy recently.
plz, upload the files, :)

Rank: 4

24#
发表于 2013-11-19 15:38:15 |只看该作者
本帖最后由 Alex 于 2013-11-19 17:20 编辑
  1.         th =   _TH[_i][_j]/1.4
  2.         tw =  _TW[_i][_j]/2
  3.         XP_fix = 20

  4.         ts = _start  
  5.         te = _end  
  6.         text1 = "{\\pos(%d,%d)\\bord0\\1c&H000000&\\clip(m %d %d l %d %d l %d %d l %d %d)}%s"%(x,y ,x-tw,y-th, x+tw, y-th, x+tw, y+th, x-tw, y+th, _txt)
  7.         ass_main(ASS_BUF, SubL(ts,te, 5),'', text1)
  8.         text2 = "{\\an8\\pos(%d,%d)\\bord0\\p1}m %d %d l %d %d l %d %d l %d %d"%(x+XP_fix,y , tw,th, -tw, th, -tw, -th, tw, -th)
  9.         ass_main(ASS_BUF, SubL(ts,te,1) ,'',text2)
复制代码

Rank: 4

23#
发表于 2013-11-19 14:45:57 |只看该作者
本帖最后由 Alex 于 2013-11-19 15:30 编辑

Hahaha... I see that, I miss you XD
Anyway.  I didn't use pixels its shape only and the position is _x & _y
if u want all files I will upload

Administrator

TCAX Dev.

Rank: 7Rank: 7Rank: 7

22#
发表于 2013-11-19 13:15:14 |只看该作者
Alex 发表于 2013-11-17 20:13
it's ok now,

but shape position why it's different should be same text clip   -_-


Maybe you forgot to use PIX[0][0] and PIX[0][1]


p.s. I just had a four day vocation :xD

Rank: 4

21#
发表于 2013-11-17 20:13:12 |只看该作者
本帖最后由 Alex 于 2013-11-17 20:16 编辑

it's ok now,

but shape position why it's different should be same text clip   -_-

8.png
  1.         th =   _TH[_i][_j]/1.4
  2.         tw =  _TW[_i][_j]/2
  3.         XP_fix = 20


  4.         text3 = "{\\an8\\pos(%d,%d)\\bord0\\p1}m %d %d l %d %d l %d %d l %d %d"%(x+XP_fix,y , tw,th, -tw, th, -tw, -th, tw, -th)
  5.         ass_main(ASS_BUF, SubL(_start,te,1) ,'',text3)
复制代码

Administrator

Shanzhai Pro.

Rank: 7Rank: 7Rank: 7

20#
发表于 2013-11-14 21:19:06 |只看该作者
Alex 发表于 2013-11-14 20:07
as I remember I have did that _width[_i] [_j]
anyway I will see again

Are you sure?

Rank: 4

19#
发表于 2013-11-14 20:07:14 |只看该作者
as I remember I have did that _width[_i] [_j]
anyway I will see again

Administrator

Shanzhai Pro.

Rank: 7Rank: 7Rank: 7

18#
发表于 2013-11-14 18:11:51 |只看该作者
Alex 发表于 2013-11-14 15:16
Nothing happened ,  saying that %i same %d +_+
I tested everything, doesn't solve m ...

change _width[_i] to _width[_i] [_j]

Rank: 4

17#
发表于 2013-11-14 15:16:28 |只看该作者


Nothing happened ,  saying that %i same %d +_+
I tested everything, doesn't solve my problem!

Administrator

TCAX Dev.

Rank: 7Rank: 7Rank: 7

16#
发表于 2013-11-13 22:01:56 |只看该作者
Alex 发表于 2013-11-13 18:03
Ok

I'm trying to make a square clip by using text metrics ( Height & width Only)

then you can try "%i" xD

or a more python 3k way, using the string format function
  1. def t1(t1, t2, code):    # deprecated
  2.     return '\\t({0},{1},{2})'.format(int(t1), int(t2), code)

  3. def t(a1, a2 = None, a3 = None, a4 = None):
  4.     if a2 == None:
  5.         return '\\t({code})'.format(code = a1)
  6.     elif a3 == None:
  7.         if a1 == int(a1):
  8.             A = str(int(a1))
  9.         else:
  10.             A = str(format(a1, '.2f'))
  11.         return '\\t({a},{code})'.format(a = A, code = a2)
  12.     elif a4 == None:
  13.         return '\\t({t1},{t2},{code})'.format(t1 = int(a1), t2 = int(a2), code = a3)
  14.     else:
  15.         if a3 == int(a3):
  16.             A = str(int(a3))
  17.         else:
  18.             A = str(format(a3, '.2f'))
  19.         return '\\t({t1},{t2},{a},{code})'.format(t1 = int(a1), t2 = int(a2), a = A, code = a4)
复制代码
you can find these ASS tag functions in tcaxPy.py under the TCAX's root directory.

Rank: 4

15#
发表于 2013-11-13 18:03:19 |只看该作者
本帖最后由 Alex 于 2013-11-13 18:31 编辑

Ok

I'm trying to make a square clip by using text metrics ( Height & width Only)
but I got a problem -_-



Why I can't use %d ?


Im using a normal "\k"
  1. from tcaxPy import *


  2. def tcaxPy_Init():
  3.     global _FD                              
  4.     global _Blur
  5.     global _text
  6.     global _textLength
  7.     global _width
  8.     global _height
  9.     global _advance
  10.     global _fx_width
  11.     global _fx_height

  12.     _fx_width = GetVal (val_ResolutionX)
  13.     _fx_height = GetVal (val_ResolutionY)
  14.     _text = GetVal (val_Text)
  15.     _textLength = GetVal (val_TextLength)
  16.     _width = GetVal(val_TextWidth)
  17.     _height = GetVal (val_TextHeight)
  18.     _advance = GetVal (val_TextAdvance)
  19.     _FD = 1000 / GetVal(val_FXFPS)
  20.     _Blur = GetVal(val_Blur)


  21. def tcaxPy_Fin():
  22.     pass



  23. def tcaxPy_Main(_i, _j, _n, _start, _end, _elapk, _k, _x, _y, _a, _txt):
  24.     ASS_BUF  = []         
  25.     TCAS_BUF = []      

  26.     x = _x
  27.     y = _y

  28.     text = "{\\pos(%d,%d)\\clip(m %d %d l %d %d l %d %d)} " % (x,y, _width[_i],y-10,x+10,y-10,x+10,y+10)
  29.     text1 = "{\\pos(%d,%d)}%s" % (x,y,_txt)
  30.     ass_main(ASS_BUF, SubL(_start , _end , 2), '', text)
  31.     ass_main(ASS_BUF, SubL(_start , _end , 2), '', text1)                           

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

Administrator

TCAX Dev.

Rank: 7Rank: 7Rank: 7

14#
发表于 2013-11-12 22:55:23 |只看该作者
Alex 发表于 2013-11-12 18:28
milky!

How can I use width & height to get metrics of text?


if you have a PIX object, there is a quick way to get width and height
  1. width = PIX[1][0]
  2. height = PIX[1][1]
复制代码
if you want to get the pre-calculated metrics of texts, use
  1. # tm info (horizontal)
  2. val_Ascender         = 33        # 字体上行高度
  3. val_Descender        = 34        # 字体下行高度 通常为负数
  4. val_TextWidth        = 35        # 第i句卡拉OK歌词的j个字符的宽度
  5. val_TextHeight       = 36        # 第i句卡拉OK歌词的j个字符的高度
  6. val_TextKerning      = 37        # 第i句卡拉OK歌词的j个字符与之前一个字符的kerning 一句歌词第一个字符的kerning为0
  7. val_TextAdvance      = 38        # 第i句卡拉OK歌词的j个字符的水平步距
  8. val_TextAdvanceDiff  = 39        # 从初始位置到第i句卡拉OK歌词的j个字符的水平步距
  9. val_TextLength       = 40        # 第i句卡拉OK歌词的文字总长度
  10. val_TextInitX        = 41        # 第i句卡拉OK歌词的j个字符的左上角X轴坐标
  11. val_TextInitY        = 42        # 第i句卡拉OK歌词的j个字符的左上角Y轴坐标
  12. val_TextBearingY     = 43        # 第i句卡拉OK歌词的j个字符的Y轴bearing
复制代码
e.g.width of the text in the i(th) line j(th) \k tag,
  1. width = GetVal(val_TextWidth)[i][j]
复制代码
the last but least common way is to use

## Initialize a font and retrieves the metrics of the specified text from the font.
# @param font_file a string, filename of the target font file
# @param face_id an integer, font face id, should always be 1 in TTF files
# @param font_size an integer, font size, in em height
# @param spacing an integer, spacing between texts, can be negative
# @param space_scale a float, scale of white spaces
# @param text a string, the text that is going to be measured
# @return (0 width, 1 height, 2 horiBearingX, 3 horiBearingY, 4 horiAdvance, 5 vertBearingX, 6 vertBearingY, 7 vertAdvance, 8 x_ppem, 9 y_ppem, 10 x_scale, 11 y_scale, 12 ascender, 13 descender, 14 px_height, 15 max_advance)
def TextMetrics(font_file, face_id, font_size, spacing, space_scale, text):

## Retrieve the metrics of the specified text from a font.
# @param font a handler, the handler to the font
# @param text a string, the text that is going to generate a PIX
# @return (0 width, 1 height, 2 horiBearingX, 3 horiBearingY, 4 horiAdvance, 5 vertBearingX, 6 vertBearingY, 7 vertAdvance, 8 x_ppem, 9 y_ppem, 10 x_scale, 11 y_scale, 12 ascender, 13 descender, 14 px_height, 15 max_advance)
def TextMetrics(font, text):



APIs from tcaxLib module can be found on http://www.tcax.org/docs/tcaxLib/namespacemembers_func.html

mofe info about PIX, and TCAS FX, http://www.tcax.org/forum.php?mod=viewthread&tid=220, if I not showed you this link before

Rank: 4

13#
发表于 2013-11-12 18:28:27 |只看该作者
milky!

How can I use width & height to get metrics of text?

Rank: 4

12#
发表于 2013-11-8 00:34:46 |只看该作者
I knew what is the problem before ur answer , thank you =D

Administrator

TCAX Dev.

Rank: 7Rank: 7Rank: 7

11#
发表于 2013-11-7 20:48:41 |只看该作者
Alex 发表于 2013-11-5 23:11
When i used pixel, I got some space between letters, I think it's happening for pixels
you can see  ...


the text layout, in the horizontal direction, letters are put with 'advance' distance between each other. not just incremented by just 'width', so there may be space between letters.

you can find more information about text layout, by Googling FreeType Text Layout

glyph.png (5.66 KB, 下载次数: 1291)

glyph

glyph

Rank: 4

10#
发表于 2013-11-5 23:11:06 |只看该作者
本帖最后由 Alex 于 2013-11-5 23:52 编辑

When i used pixel, I got some space between letters, I think it's happening for pixels
you can see the pic, and you will see there is a space between letters

anyway it's ok

Thank you for your patience with me, it's just a testing XD

Administrator

TCAX Dev.

Rank: 7Rank: 7Rank: 7

9#
发表于 2013-11-5 22:18:53 |只看该作者
Alex 发表于 2013-11-5 12:25

any description? I can't get your meaning from the pic

Rank: 4

8#
发表于 2013-11-5 12:25:47 |只看该作者

Administrator

TCAX Dev.

Rank: 7Rank: 7Rank: 7

7#
发表于 2013-11-4 23:27:46 |只看该作者
Alex 发表于 2013-11-4 22:41
I have another 2 question

Why the position it's not exactly correct, there is space between letter ...
Why the position it's not exactly correct, there is space between letters?


Plz post an image to help me understand your question.


to your 2nd question

see the info below

< alignment = 7 >
#  indicate where to put the texts, you can refer to the number keyboard. Default alignment for horizontal layout is an1, default alignment for vertical layout is an9


the alignment set in the TCC file only affects the Offset of the line.
use an() tag function to apply an alignment effect for your FX
您需要登录后才可以回帖 登录 | 新人加入

GitHub|TCAX 主页

GMT+8, 2024-5-14 18:09

Powered by Discuz! X2

© 2001-2011 Comsenz Inc.

回顶部
RealH