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

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

[已解决] Comparison of pos setting behaviours by PixPos() & tcas_main() function [复制链接]

Moderator

Effect Researcher.

Rank: 5Rank: 5

跳转到指定楼层
楼主
发表于 2016-4-11 15:57:56 |只看该作者 |倒序浏览
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.
2

查看全部评分

Administrator

TCAX Dev.

Rank: 7Rank: 7Rank: 7

沙发
发表于 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).

Moderator

Effect Researcher.

Rank: 5Rank: 5

板凳
发表于 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.

Administrator

TCAX Dev.

Rank: 7Rank: 7Rank: 7

地板
发表于 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

Moderator

Effect Researcher.

Rank: 5Rank: 5

5#
发表于 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.
您需要登录后才可以回帖 登录 | 新人加入

GitHub|TCAX 主页

GMT+8, 2024-11-22 02:13

Powered by Discuz! X2

© 2001-2011 Comsenz Inc.

回顶部
RealH