tcaxLib
Version 1.0.0
|
Functions | |
def | tcaxLibGetVersion |
Get the current tcaxLib version. | |
def | PixPoints |
Get points from PIX. | |
def | BlankPix |
Create a blank PIX. | |
def | PixResize |
Resize a PIX. | |
def | PixResizeF |
Resize a PIX, the same as PixResize but accept fractional width and height. | |
def | PixEnlarge |
Enlarge a PIX. | |
def | PixCrop |
Crop a PIX. | |
def | PixStrip |
Strip the blank border of a PIX. | |
def | PixTexture |
Apply a texture on a PIX. | |
def | PixMask |
Apply a mask to a PIX. | |
def | PixReplaceAlpha |
Replace the alpha channel of the source PIX with the alpha channel of the destination PIX. | |
def | PixBlur |
Blur a PIX using Gauss IIR blur. | |
def | CombinePixs |
Combine two PIXs. | |
def | PixColorMul |
Change the color of a PIX by multiplying factors to each channel of RGBA. | |
def | PixColorShift |
Change the color of a PIX by shifting values of each channel of RGBA. | |
def | PixColorTrans |
Make the color in a PIX with specified rgb value transparent. | |
def | PixColorRGBA |
Change the value of colors including alpha channels in the PIX with flat rgba value. | |
def | PixColorRGB |
Change the value of colors in the PIX with flat rgb value. | |
def | PixColorA |
Change the value of alpha channels in the PIX with constant alpha value. | |
def | BilinearFilter |
Bilinear Filter, mainly used when creating effects of moving a PIX so that it will look smoother. | |
def | ScaleFilter |
Scale Filter, mainly used when creating effects of moving a PIX so that it will look smoother. | |
def | InitBigPix |
Create a blank BigPIX. | |
def | BigPixAdd |
Add a PIX to the BigPIX. | |
def | ConvertBigPix |
Convert a BigPIX to PIX. | |
def | CreateAssFile |
Create an ASS file and returns the handler to the file. | |
def | AppendAssFile |
Append to an ASS file and returns the handler to the file. | |
def | WriteAssFile |
Write ASS strings to ASS file. | |
def | FinAssFile |
Finalize the ASS file (close the handler to the file and destroy contents assigned to it). | |
def | CreateTcasFile |
Create an TCAS file and returns the handler to the file. | |
def | WriteTcasFile |
Write ASS strings to ASS file. | |
def | FinTcasFile |
Finalize the TCAS file (close the handler to the file and destroy contents assigned to it). | |
def | InitFont |
Initialize a font and returns the handler to the font. | |
def | FinFont |
Finalize the font and destroy the handler. | |
def | TextPix |
Initialize a font and retrieves a PIX of the specified text from the font. | |
def | TextPix |
Retrieve a PIX of the specified text from a font. | |
def | TextOutlinePoints |
Get text outline points. | |
def | TextOutlinePoints |
Get text outline points. | |
def | TextMetrics |
Initialize a font and retrieves the metrics of the specified text from the font. | |
def | TextMetrics |
Retrieve the metrics of the specified text from a font. | |
def | ImagePix |
Retrieve a PIX from a PNG image. | |
def | ImagePix |
Retrieve a PIX from a PNG image, and resize the PIX to specified size. | |
def | SavePix |
Save a PIX to a PNG file. | |
def | SavePix |
Resize a PIX to specified size and save it to a PNG file. | |
def | TextOutlineDraw |
Get the text outline (which is consisted of contours, lines, bezier arcs) as a string of ASS drawing commands. | |
def | TextOutlineDraw |
Get the text outline (which is consisted of contours, lines, bezier arcs) as a string of ASS drawing commands. | |
def | IsCjk |
Check if a text string is a CJK string, here CJK means "Chinese or Japanese or Korea" not "Chinese & Japanese & Korea". | |
def | VertLayout |
Change the text to fit the vertical text layout, only used for ASS FX. | |
def | ShowProgress |
Show progress only needed in tcax py user mode. | |
def | Bezier1 |
Get points of a linear bezier curve. | |
def | Bezier2 |
Get points of a quadratic bezier curve. | |
def | Bezier3 |
Get points of a cubic bezier curve. | |
def | BezierN |
Get points of a Nth order bezier curve with random control points within the specified interval. | |
def | tcas_main |
Append a PIX to the TCAS_BUF list. | |
def | tcas_keyframe |
Append a pair of key frame PIXs to the TCAS_BUF list. |
tcaxLib documentation
API references and usage examples of tcaxLib.pyd
def tcaxLib.AppendAssFile | ( | ass_file | ) |
Append to an ASS file and returns the handler to the file.
ass_file | a string, filename of the target ASS file |
def tcaxLib.Bezier1 | ( | nPoints, | |
xs, | |||
ys, | |||
xe, | |||
ye | |||
) |
Get points of a linear bezier curve.
nPoints | an integer, number of points you want to have |
xs | a float, position x of the start point |
ys | a float, position y of the start point |
xe | a float, position x of the end point |
ye | a float, position y of the end point |
def tcaxLib.Bezier2 | ( | nPoints, | |
xs, | |||
ys, | |||
xe, | |||
ye, | |||
xc, | |||
yc | |||
) |
Get points of a quadratic bezier curve.
nPoints | an integer, number of points you want to have |
xs | a float, position x of the start point |
ys | a float, position y of the start point |
xe | a float, position x of the end point |
ye | a float, position y of the end point |
xc | a float, position x of the control point |
yc | a float, position y of the control point |
def tcaxLib.Bezier3 | ( | nPoints, | |
xs, | |||
ys, | |||
xe, | |||
ye, | |||
xc1, | |||
yc1, | |||
xc2, | |||
yc2 | |||
) |
Get points of a cubic bezier curve.
nPoints | an integer, number of points you want to have |
xs | a float, position x of the start point |
ys | a float, position y of the start point |
xe | a float, position x of the end point |
ye | a float, position y of the end point |
xc1 | a float, position x of the 1st control point |
yc1 | a float, position y of the 1st control point |
xc2 | a float, position x of the 2nd control point |
yc2 | a float, position y of the 2nd control point |
def tcaxLib.BezierN | ( | nPoints, | |
xs, | |||
ys, | |||
xe, | |||
ye, | |||
xl1, | |||
yl1, | |||
xl2, | |||
yl2, | |||
order | |||
) |
Get points of a Nth order bezier curve with random control points within the specified interval.
nPoints | an integer, number of points you want to have |
xs | a float, position x of the start point |
ys | a float, position y of the start point |
xe | a float, position x of the end point |
ye | a float, position y of the end point |
xl1 | a float, position x of the 1st limit point |
yl1 | a float, position y of the 1st limit point |
xl2 | a float, position x of the 2nd limit point |
yl2 | a float, position y of the 2nd limit point |
order | an integer, the order of the bezier curve |
def tcaxLib.BigPixAdd | ( | bigPix, | |
pix, | |||
offset_x, | |||
offset_y, | |||
layer | |||
) |
def tcaxLib.BilinearFilter | ( | pix, | |
offset_x, | |||
offset_y | |||
) |
def tcaxLib.BlankPix | ( | width, | |
height, | |||
rgba | |||
) |
def tcaxLib.CombinePixs | ( | back, | |
overlay | |||
) |
def tcaxLib.ConvertBigPix | ( | bigPix | ) |
def tcaxLib.CreateAssFile | ( | ass_file, | |
ass_header | |||
) |
Create an ASS file and returns the handler to the file.
ass_file | a string, filename of the target ASS file |
ass_header | a string, the ASS file header |
def tcaxLib.CreateTcasFile | ( | tcas_file, | |
fx_width, | |||
fx_height, | |||
fx_fps | |||
) |
Create an TCAS file and returns the handler to the file.
tcas_file | a string, filename of the target TCAS file |
fx_width | an integer, width of the FX |
fx_height | an integer, height of the FX |
fx_fps | a float, FPS of the FX |
def tcaxLib.FinAssFile | ( | assFile | ) |
Finalize the ASS file (close the handler to the file and destroy contents assigned to it).
assFile | a handler, handler to the ASS file |
def tcaxLib.FinFont | ( | font | ) |
Finalize the font and destroy the handler.
font | a handler, the handler to the font |
def tcaxLib.FinTcasFile | ( | tcasFile | ) |
Finalize the TCAS file (close the handler to the file and destroy contents assigned to it).
tcasFile | a handler, handler to the TCAS file |
def tcaxLib.ImagePix | ( | filename | ) |
def tcaxLib.ImagePix | ( | filename, | |
width, | |||
height | |||
) |
def tcaxLib.InitBigPix | ( | ) |
Create a blank BigPIX.
Remark: a BigPix is indeed a list that has the following structure [(PIX, offset_x, offset_y, layer), (PIX, offset_x, offset_y, layer), ...], BigPix is used to put several PIXs together, therefore you can treate several PIXs as a whole. Unlike CombinePix(), BigPix usually contains PIXs that are in different positions. You can use BigPixAdd() to add a PIX to the BigPix, and use ConvertBigPix() to convert the BigPix back to PIX. By using BigPix you can even treate a whole text line as a single PIX.
def tcaxLib.InitFont | ( | font_file, | |
face_id, | |||
font_size, | |||
spacing, | |||
space_scale, | |||
color, | |||
bord, | |||
is_outline | |||
) |
Initialize a font and returns the handler to the font.
font_file | a string, filename of the target font file |
face_id | an integer, font face id, should always be 1 in TTF files |
font_size | an integer, font size, in em height |
spacing | an integer, spacing between texts, can be negative |
space_scale | a float, scale of white spaces |
color | an integer, rgb color of the font |
bord | an integer, border of the font, can be negative |
is_outline | an integer, 0 - include body, 1 - only retrieve the outline |
def tcaxLib.IsCjk | ( | text | ) |
Check if a text string is a CJK string, here CJK means "Chinese or Japanese or Korea" not "Chinese & Japanese & Korea".
text | a string, the target text that is going to be checked |
def tcaxLib.PixBlur | ( | pix, | |
radius | |||
) |
def tcaxLib.PixColorA | ( | PIX, | |
alpha | |||
) |
def tcaxLib.PixColorMul | ( | PIX, | |
r_f, | |||
g_f, | |||
b_f, | |||
a_f | |||
) |
Change the color of a PIX by multiplying factors to each channel of RGBA.
The value of each channel will be clipped into [0, 255]
pix | a PIX, the source PIX |
r_f | a float, the red channel factor, if r_f == 1, the red channel will stay the same |
g_f | a float, the green channel factor, if g_f == 1, the green channel will stay the same |
b_f | a float, the blue channel factor, if b_f == 1, the blue channel will stay the same |
a_f | a float, the alpha channel factor, if a_f == 1, the alpha channel will stay the same |
def tcaxLib.PixColorRGB | ( | PIX, | |
rgb | |||
) |
def tcaxLib.PixColorRGBA | ( | PIX, | |
rgba | |||
) |
def tcaxLib.PixColorShift | ( | PIX, | |
r, | |||
g, | |||
b, | |||
a | |||
) |
Change the color of a PIX by shifting values of each channel of RGBA.
The value of each channel will be clipped into [0, 255]
pix | a PIX, the source PIX |
r | an integer, the red channel offset, can be negative, if r == 0, the red channel will stay the same |
g | an integer, the green channel offset, can be negative, if g == 0, the green channel will stay the same |
b | an integer, the blue channel offset, can be negative, if b == 0, the blue channel will stay the same |
a | an integer, the alpha channel offset, can be negative, if a == 0, the alpha channel will stay the same |
def tcaxLib.PixColorTrans | ( | PIX, | |
rgb | |||
) |
def tcaxLib.PixCrop | ( | pix, | |
left, | |||
top, | |||
right, | |||
bottom | |||
) |
Crop a PIX.
pix | a PIX, the source PIX that is going to be cropped |
left | an integer, offset from the left side |
top | an integer, offset from the top |
right | an integer, offset from the left side, or when it is negative, offset from the right side |
bottom | an integer, offset from the top, or when it is negative, offset from the bottom |
def tcaxLib.PixEnlarge | ( | pix, | |
x, | |||
y | |||
) |
def tcaxLib.PixMask | ( | pix, | |
mask | |||
) |
def tcaxLib.PixPoints | ( | pix | ) |
def tcaxLib.PixReplaceAlpha | ( | pix, | |
alpha | |||
) |
def tcaxLib.PixResize | ( | pix, | |
width, | |||
height | |||
) |
def tcaxLib.PixResizeF | ( | pix, | |
width, | |||
height | |||
) |
def tcaxLib.PixStrip | ( | pix | ) |
def tcaxLib.PixTexture | ( | pix, | |
texture | |||
) |
def tcaxLib.SavePix | ( | filename, | |
pix | |||
) |
def tcaxLib.SavePix | ( | filename, | |
pix, | |||
width, | |||
height | |||
) |
def tcaxLib.ScaleFilter | ( | pix, | |
offset_x, | |||
offset_y | |||
) |
Scale Filter, mainly used when creating effects of moving a PIX so that it will look smoother.
Remark: unlike BilinearFilter, this filter is best fit for complicated pictures such as textured text, but is bad for solid colored square.
def tcaxLib.ShowProgress | ( | total, | |
completed, | |||
file_id, | |||
file_num | |||
) |
Show progress only needed in tcax py user mode.
total | an integer, total texts |
completed | an integer, texts that had been completed |
file_id | an integer, tcax py script file id |
file_num | an integer, number of tcax py scripts that the FX used |
def tcaxLib.tcas_keyframe | ( | TCAS_BUF, | |
pix_start, | |||
pix_end, | |||
start, | |||
end, | |||
offsetX, | |||
offsetY, | |||
type, | |||
layer | |||
) |
Append a pair of key frame PIXs to the TCAS_BUF list.
TCAS_BUF | a list, the list containing the raw TCAS FX data chunks |
pix_start | a PIX, the target start key frame PIX that is going to be added into the TCAS_BUF |
pix_end | a PIX, the target end key frame PIX that is going to be added into the TCAS_BUF |
start | an integer, the starting time of the PIX |
end | an integer, the end time of the PIX |
offsetX | a float, offset of the PIX in the horizontal direction |
offsetY | a float, offset of the PIX in the vertical direction |
type | an integer, type of the key frame PIX, 1 - normal, 2 - use bilinear filtering to make smooth motion |
layer | an integer, layer of the PIX |
def tcaxLib.tcas_main | ( | TCAS_BUF, | |
pix, | |||
start, | |||
end, | |||
offsetX, | |||
offsetY, | |||
layer | |||
) |
Append a PIX to the TCAS_BUF list.
TCAS_BUF | a list, the list containing the raw TCAS FX data chunks |
pix | a PIX, the target PIX that is going to be added into the TCAS_BUF |
start | an integer, the starting time of the PIX |
end | an integer, the end time of the PIX |
offsetX | a float, offset of the PIX in the horizontal direction |
offsetY | a float, offset of the PIX in the vertical direction |
layer | an integer, layer of the PIX |
def tcaxLib.tcaxLibGetVersion | ( | ) |
Get the current tcaxLib version.
def tcaxLib.TextMetrics | ( | font_file, | |
face_id, | |||
font_size, | |||
spacing, | |||
space_scale, | |||
text | |||
) |
Initialize a font and retrieves the metrics of the specified text from the font.
font_file | a string, filename of the target font file |
face_id | an integer, font face id, should always be 1 in TTF files |
font_size | an integer, font size, in em height |
spacing | an integer, spacing between texts, can be negative |
space_scale | a float, scale of white spaces |
text | a string, the text that is going to be measured |
def tcaxLib.TextMetrics | ( | font, | |
text | |||
) |
Retrieve the metrics of the specified text from a font.
font | a handler, the handler to the font |
text | a string, the text that is going to generate a PIX |
def tcaxLib.TextOutlineDraw | ( | font_file, | |
face_id, | |||
font_size, | |||
text, | |||
x, | |||
y | |||
) |
Get the text outline (which is consisted of contours, lines, bezier arcs) as a string of ASS drawing commands.
font_file | a string, filename of the target font file |
face_id | an integer, font face id, should always be 1 in TTF files |
font_size | an integer, font size, in em height |
text | a string, the text of which the outline will be retrieved |
x | an integer, position x of the offset |
y | an integer, position y of the offset |
def tcaxLib.TextOutlineDraw | ( | pyFont, | |
text, | |||
x, | |||
y | |||
) |
Get the text outline (which is consisted of contours, lines, bezier arcs) as a string of ASS drawing commands.
font | a handler, the handler to the font |
text | a string, the text of which the outline will be retrieved |
x | an integer, position x of the offset |
y | an integer, position y of the offset |
def tcaxLib.TextOutlinePoints | ( | font_file, | |
face_id, | |||
font_size, | |||
text, | |||
density | |||
) |
Get text outline points.
font_file | a string, filename of the target font file |
face_id | an integer, font face id, should always be 1 in TTF files |
font_size | an integer, font size, in em height |
text | a string, the text of which the outline will be retrieved |
density | a float, the density of points that we want to have, 1.0 is commonly used, however it can be less or larger than 1 according to the need |
def tcaxLib.TextOutlinePoints | ( | pyFont, | |
text, | |||
density | |||
) |
Get text outline points.
font | a handler, the handler to the font |
text | a string, the text of which the outline will be retrieved |
density | a float, the density of points that we want to have, 1.0 is commonly used, however it can be less or larger than 1 according to the need |
def tcaxLib.TextPix | ( | font_file, | |
face_id, | |||
font_size, | |||
spacing, | |||
space_scale, | |||
color, | |||
bord, | |||
is_outline, | |||
text | |||
) |
Initialize a font and retrieves a PIX of the specified text from the font.
font_file | a string, filename of the target font file |
face_id | an integer, font face id, should always be 1 in TTF files |
font_size | an integer, font size, in em height |
spacing | an integer, spacing between texts, can be negative |
space_scale | a float, scale of white spaces |
color | an integer, rgb color of the font |
bord | an integer, border of the font, can be negative |
is_outline | an integer, 0 - include body, 1 - only retrieve the outline |
text | a string, the text that is going to generate a PIX |
def tcaxLib.TextPix | ( | font, | |
text | |||
) |
def tcaxLib.VertLayout | ( | text | ) |
Change the text to fit the vertical text layout, only used for ASS FX.
text | a string, the target text that is going to be updated |
def tcaxLib.WriteAssFile | ( | assFile, | |
ASS_BUF | |||
) |
Write ASS strings to ASS file.
assFile | a handler, handler to the ASS file |
ASS_BUF | a list, the list containing the ASS FX strings |
def tcaxLib.WriteTcasFile | ( | tcasFile, | |
TCAS_BUF | |||
) |
Write ASS strings to ASS file.
tcasFile | a handler, handler to the TCAS file |
TCAS_BUF | a list, the list containing the raw TCAS FX data chunks |