标题: 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:
def PixPos(PIX, x, y):
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:
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()):
from tcaxPy import *
def tcaxPy_Init():
global font
global font_out
global font_size
font_file = GetVal(val_FontFileName)
face_id = GetVal(val_FaceID)
font_size = GetVal(val_FontSize)
spacing = GetVal(val_Spacing)
space_scale = GetVal(val_SpaceScale)
font = InitFont(font_file, face_id, font_size, spacing, space_scale, 0xFFFFFF, 0, 0)
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:
def PixPos(PIX, x, y):
return ((x, y), PIX[1], PIX[2])
def PixPosShift(PIX, dx, dy):
x = PIX[0][0]
y = PIX[0][1]
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
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.