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

标题: Comparison of pos setting behaviours by PixPos() & tcas_main() function [打印本页]

作者: 面麻    时间: 2016-4-11 15:57:56     标题: Comparison of pos setting behaviours by PixPos() & tcas_main() function

Right as what the title shows, I found the differences of position setting behaviors between PixPos() and tcas_main() function.
We could found the original codes of PixPos() function at tcaxPy.py, which has been listed below:
  1. def PixPos(PIX, x, y):
  2.     return ((x, y), PIX[1], PIX[2])
复制代码
It returns a PIX structure with a change of position info only.
About tcas_main() function, I could merely provide its parameter info by its definition:
  1. def tcas_main(TCAS_BUF, pix, start, end, offsetX, offsetY, layer):
复制代码
offsetX and offsetY stand for the offsets in the horizontal and vertical direction respectively.
At first, I estimated that their effects would be the same, but a different result is showed by the preview.
The test script is (Note: When using PixPos() function, we must set offsetX and offsetY as 0 in tcas_main()):
  1. from tcaxPy import *


  2. def tcaxPy_Init():
  3.     global font
  4.     global font_out
  5.     global font_size
  6.     font_file   = GetVal(val_FontFileName)
  7.     face_id     = GetVal(val_FaceID)
  8.     font_size   = GetVal(val_FontSize)
  9.     spacing     = GetVal(val_Spacing)
  10.     space_scale = GetVal(val_SpaceScale)
  11.     font = InitFont(font_file, face_id, font_size, spacing, space_scale, 0xFFFFFF, 0, 0)
  12.     font_out = InitFont(font_file, face_id, font_size, spacing, space_scale, 0xFF0000, 2, 1)


  13. def tcaxPy_Fin():
  14.     FinFont(font)
  15.     FinFont(font_out)


  16. def tcaxPy_Main(_i, _j, _n, _start, _end, _elapk, _k, _x, _y, _a, _txt):

  17.     TCAS_BUF = []        # used for saving TCAS FX raw data

  18.     # an5 -> an7, TCAS uses an7
  19.     ux = _x - int(_a / 2 + 0.5)
  20.     uy = _y - int(font_size / 2 + 0.5)

  21.     text = TextPix(font, _txt)
  22.     bord = TextPix(font_out, _txt)
  23.     bord = PixBlur(bord, 2)
  24.     main = CombinePixs(bord, text)
  25.     #main = PixPos(main, ux, uy)

  26.     ts = 10 * _start
  27.     te = 10 * _end

  28.     tcas_main(TCAS_BUF, main, ts, te, ux, uy, 0)
  29.     #tcas_main(TCAS_BUF, main, ts, te, 0, 0, 0)

  30.     return (None, TCAS_BUF)
复制代码
We could find the difference clearly from the samples below:
pixpos():
pixpos()

tcas_main():
tcas_main()

I prefer the effect of position setting behavior by tcas_main().
It seems that the effect of PixPos() function has a little problem.

Looking forward to your answer and explanation.

图片附件: [tcas_main()] tcas_main.png (2016-4-11 15:51:25, 64.8 KB) / 下载次数 1532
http://tcax.org/forum.php?mod=attachment&aid=MjAzMnxlZTA1M2JjMXwxNzMwNDIwMzQ5fDB8MA%3D%3D



图片附件: [pixpos()] pixpos.png (2016-4-11 15:50:32, 65.72 KB) / 下载次数 1504
http://tcax.org/forum.php?mod=attachment&aid=MjAzMXxhNTNjMmVmMHwxNzMwNDIwMzQ5fDB8MA%3D%3D


作者: milkyjing    时间: 2016-5-2 11:51:13

I think it's the misunderstanding of PixPos, check the source code, find the difference between PixPos and PixPosShift (the behavior of which the tcas_main is like).
作者: 面麻    时间: 2016-5-2 12:32:44

milkyjing 发表于 2016-5-2 11:51
I think it's the misunderstanding of PixPos, check the source code, find the difference between PixP ...

Reference of function definition in tcaxPy.py:
  1. def PixPos(PIX, x, y):
  2.     return ((x, y), PIX[1], PIX[2])

  3. def PixPosShift(PIX, dx, dy):
  4.     x = PIX[0][0]
  5.     y = PIX[0][1]
  6.     return ((x + dx, y + dy), PIX[1], PIX[2])
复制代码
Still, I could not grasp my wrong.
Do you mean that in this script PixPos() ought to be replaced with PixPosShift()?
However, I see the parameters x&y in PixPos() and offsetX&offsetY in tcas_main() as the same.
作者: milkyjing    时间: 2016-5-3 22:13:51

every PIX object has its initial position specified in PIX[0], (a tuple of two dimensional x, y pair)

PixPos resets the initial position by (x, y), while PixPosShift added to it

http://www.tcax.org/forum.php?mo ... =1079&fromuid=2
作者: 面麻    时间: 2016-5-3 23:40:16

Thank you for replying me during your busy working.
This confusion counts a lot for me.
After PixPos()'s being replaced with PixPosShift(), the positions have become normal in preview.




欢迎光临 TCAX 字幕特效制作工具官方论坛 | ASS | TCAS | Python | Aegisub | Lua (http://tcax.org/) Powered by Discuz! X2