tcaxLib  Version 1.0.0
Functions
tcaxLib Namespace Reference

tcaxLib documentation More...

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.

Detailed Description

tcaxLib documentation

API references and usage examples of tcaxLib.pyd


Function Documentation

def tcaxLib.AppendAssFile (   ass_file)

Append to an ASS file and returns the handler to the file.

Parameters:
ass_filea string, filename of the target ASS file
Returns:
assFile the handler to the ASS file
def tcaxLib.Bezier1 (   nPoints,
  xs,
  ys,
  xe,
  ye 
)

Get points of a linear bezier curve.

Parameters:
nPointsan integer, number of points you want to have
xsa float, position x of the start point
ysa float, position y of the start point
xea float, position x of the end point
yea float, position y of the end point
Returns:
((x1, y1), (x2, y2), ...)
def tcaxLib.Bezier2 (   nPoints,
  xs,
  ys,
  xe,
  ye,
  xc,
  yc 
)

Get points of a quadratic bezier curve.

Parameters:
nPointsan integer, number of points you want to have
xsa float, position x of the start point
ysa float, position y of the start point
xea float, position x of the end point
yea float, position y of the end point
xca float, position x of the control point
yca float, position y of the control point
Returns:
((x1, y1), (x2, y2), ...)
def tcaxLib.Bezier3 (   nPoints,
  xs,
  ys,
  xe,
  ye,
  xc1,
  yc1,
  xc2,
  yc2 
)

Get points of a cubic bezier curve.

Parameters:
nPointsan integer, number of points you want to have
xsa float, position x of the start point
ysa float, position y of the start point
xea float, position x of the end point
yea float, position y of the end point
xc1a float, position x of the 1st control point
yc1a float, position y of the 1st control point
xc2a float, position x of the 2nd control point
yc2a float, position y of the 2nd control point
Returns:
((x1, y1), (x2, y2), ...)
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.

Parameters:
nPointsan integer, number of points you want to have
xsa float, position x of the start point
ysa float, position y of the start point
xea float, position x of the end point
yea float, position y of the end point
xl1a float, position x of the 1st limit point
yl1a float, position y of the 1st limit point
xl2a float, position x of the 2nd limit point
yl2a float, position y of the 2nd limit point
orderan integer, the order of the bezier curve
Returns:
((x1, y1), (x2, y2), ...)
def tcaxLib.BigPixAdd (   bigPix,
  pix,
  offset_x,
  offset_y,
  layer 
)

Add a PIX to the BigPIX.

Parameters:
bigPixa BigPIX, the source BigPIX
pixa PIX, the PIX that is going to be added
offset_xa float, offset of the PIX in the horizontal direction
offset_ya float, offset of the PIX in the vertical direction
layeran integer, layer of the PIX
Returns:
0 on success
def tcaxLib.BilinearFilter (   pix,
  offset_x,
  offset_y 
)

Bilinear Filter, mainly used when creating effects of moving a PIX so that it will look smoother.

Parameters:
pixa PIX, the source PIX
offset_xa float, offset of the PIX in the horizontal direction
offset_ya float, offset of the PIX in the vertical direction
Returns:
PIX the target PIX
def tcaxLib.BlankPix (   width,
  height,
  rgba 
)

Create a blank PIX.

Parameters:
widthan integer, target width of the PIX
heightan integer, target height of the PIX
rgbaan integer, target rgba of the PIX, usually in hexadecimal
Returns:
PIX the target PIX
def tcaxLib.CombinePixs (   back,
  overlay 
)

Combine two PIXs.

Parameters:
backa PIX, the back PIX
overlaya PIX, the overlay PIX
Returns:
PIX the target PIX
def tcaxLib.ConvertBigPix (   bigPix)

Convert a BigPIX to PIX.

Parameters:
bigPixa BigPIX, the source BigPIX
Returns:
PIX the target PIX
def tcaxLib.CreateAssFile (   ass_file,
  ass_header 
)

Create an ASS file and returns the handler to the file.

Parameters:
ass_filea string, filename of the target ASS file
ass_headera string, the ASS file header
Returns:
assFile the handler to the ASS file
def tcaxLib.CreateTcasFile (   tcas_file,
  fx_width,
  fx_height,
  fx_fps 
)

Create an TCAS file and returns the handler to the file.

Parameters:
tcas_filea string, filename of the target TCAS file
fx_widthan integer, width of the FX
fx_heightan integer, height of the FX
fx_fpsa float, FPS of the FX
Returns:
tcasFile the handler to the TCAS file
def tcaxLib.FinAssFile (   assFile)

Finalize the ASS file (close the handler to the file and destroy contents assigned to it).

Parameters:
assFilea handler, handler to the ASS file
Returns:
0 on success
def tcaxLib.FinFont (   font)

Finalize the font and destroy the handler.

Parameters:
fonta handler, the handler to the font
Returns:
0 on success
def tcaxLib.FinTcasFile (   tcasFile)

Finalize the TCAS file (close the handler to the file and destroy contents assigned to it).

Parameters:
tcasFilea handler, handler to the TCAS file
Returns:
0 on success
def tcaxLib.ImagePix (   filename)

Retrieve a PIX from a PNG image.

Parameters:
filenamea string, filename of the target image, it should be a PNG file
Returns:
PIX the target PIX
def tcaxLib.ImagePix (   filename,
  width,
  height 
)

Retrieve a PIX from a PNG image, and resize the PIX to specified size.

Parameters:
filenamea string, filename of the target image, it should be a PNG file
widthan integer, width of the target PIX
heightan integer, height of the target PIX
Returns:
PIX the target PIX

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.

Returns:
BigPIX the target BigPIX
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.

Parameters:
font_filea string, filename of the target font file
face_idan integer, font face id, should always be 1 in TTF files
font_sizean integer, font size, in em height
spacingan integer, spacing between texts, can be negative
space_scalea float, scale of white spaces
coloran integer, rgb color of the font
bordan integer, border of the font, can be negative
is_outlinean integer, 0 - include body, 1 - only retrieve the outline
Returns:
font the handler to the font
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".

Parameters:
texta string, the target text that is going to be checked
Returns:
1 - true, 0 - false
def tcaxLib.PixBlur (   pix,
  radius 
)

Blur a PIX using Gauss IIR blur.

Parameters:
pixa PIX, the source PIX that is going to be blurred
radiusan integer, radius of the Gauss kernel
Returns:
PIX the target PIX
def tcaxLib.PixColorA (   PIX,
  alpha 
)

Change the value of alpha channels in the PIX with constant alpha value.

Parameters:
pixa PIX, the source PIX
alphaan integer, the target alpha, in [0, 255]
Returns:
PIX the target PIX
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]

Parameters:
pixa PIX, the source PIX
r_fa float, the red channel factor, if r_f == 1, the red channel will stay the same
g_fa float, the green channel factor, if g_f == 1, the green channel will stay the same
b_fa float, the blue channel factor, if b_f == 1, the blue channel will stay the same
a_fa float, the alpha channel factor, if a_f == 1, the alpha channel will stay the same
Returns:
PIX the target PIX
def tcaxLib.PixColorRGB (   PIX,
  rgb 
)

Change the value of colors in the PIX with flat rgb value.

Parameters:
pixa PIX, the source PIX
rgban integer, the target color, not include the alpha channel
Returns:
PIX the target PIX
def tcaxLib.PixColorRGBA (   PIX,
  rgba 
)

Change the value of colors including alpha channels in the PIX with flat rgba value.

Parameters:
pixa PIX, the source PIX
rgbaan integer, the target color
Returns:
PIX the target PIX
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]

Parameters:
pixa PIX, the source PIX
ran integer, the red channel offset, can be negative, if r == 0, the red channel will stay the same
gan integer, the green channel offset, can be negative, if g == 0, the green channel will stay the same
ban integer, the blue channel offset, can be negative, if b == 0, the blue channel will stay the same
aan integer, the alpha channel offset, can be negative, if a == 0, the alpha channel will stay the same
Returns:
PIX the target PIX
def tcaxLib.PixColorTrans (   PIX,
  rgb 
)

Make the color in a PIX with specified rgb value transparent.

Parameters:
pixa PIX, the source PIX
rgban integer, the target color, not include the alpha channel
Returns:
PIX the target PIX
def tcaxLib.PixCrop (   pix,
  left,
  top,
  right,
  bottom 
)

Crop a PIX.

Parameters:
pixa PIX, the source PIX that is going to be cropped
leftan integer, offset from the left side
topan integer, offset from the top
rightan integer, offset from the left side, or when it is negative, offset from the right side
bottoman integer, offset from the top, or when it is negative, offset from the bottom
Returns:
PIX the target PIX
def tcaxLib.PixEnlarge (   pix,
  x,
  y 
)

Enlarge a PIX.

Parameters:
pixa PIX, the source PIX that is going to be enlarged
xan integer, the value that is increased in the horizontal direction
yan integer, the value that is increased in the vertical direction
Returns:
PIX the target PIX
def tcaxLib.PixMask (   pix,
  mask 
)

Apply a mask to a PIX.

Remark: unlike the PixTexture() function, the positions will be used.

Parameters:
pixa PIX, the source PIX that is going to be masked with the mask
maska PIX, the mask PIX
Returns:
PIX the target PIX
def tcaxLib.PixPoints (   pix)

Get points from PIX.

Parameters:
pixa PIX, the source PIX
Returns:
((x1, y1), (x2, y2), ...)
def tcaxLib.PixReplaceAlpha (   pix,
  alpha 
)

Replace the alpha channel of the source PIX with the alpha channel of the destination PIX.

Remark: the transparent pixels of the source PIX will stay unchanged.

Parameters:
pixa PIX, the source PIX whose alpha is going to be replaced by the alpha of the alpha PIX
alphaa PIX, the alpha PIX
Returns:
PIX the target PIX
def tcaxLib.PixResize (   pix,
  width,
  height 
)

Resize a PIX.

Parameters:
pixa PIX, the source PIX that is going to be resized
widthan integer, target width
heightan integer, target height
Returns:
PIX the resized PIX
def tcaxLib.PixResizeF (   pix,
  width,
  height 
)

Resize a PIX, the same as PixResize but accept fractional width and height.

Parameters:
pixa PIX, the source PIX that is going to be resized
widtha float, target width
heighta float, target height
Returns:
PIX the resized PIX
def tcaxLib.PixStrip (   pix)

Strip the blank border of a PIX.

Parameters:
pixa PIX, the source PIX whose blank border if any is going to be stripped out
Returns:
PIX the target PIX
def tcaxLib.PixTexture (   pix,
  texture 
)

Apply a texture on a PIX.

Remark: the texture will be resized to fit the target pix, and the positions will be just ignored.

Parameters:
pixa PIX, the source PIX that is going to be overlayed with the texture
texturea PIX, the texture PIX
Returns:
PIX the target PIX
def tcaxLib.SavePix (   filename,
  pix 
)

Save a PIX to a PNG file.

Parameters:
filenamea string, filename of the target image
pixa PIX, the target PIX that is going to be saved
Returns:
0 on success
def tcaxLib.SavePix (   filename,
  pix,
  width,
  height 
)

Resize a PIX to specified size and save it to a PNG file.

Parameters:
filenamea string, filename of the target image
pixa PIX, the target PIX that is going to be saved
widthan integer, width of the target PIX
heightan integer, height of the target PIX
Returns:
0 on success
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.

Parameters:
pixa PIX, the source PIX
offset_xa float, offset of the PIX in the horizontal direction
offset_ya float, offset of the PIX in the vertical direction
Returns:
PIX the target PIX
def tcaxLib.ShowProgress (   total,
  completed,
  file_id,
  file_num 
)

Show progress only needed in tcax py user mode.

Parameters:
totalan integer, total texts
completedan integer, texts that had been completed
file_idan integer, tcax py script file id
file_numan integer, number of tcax py scripts that the FX used
Returns:
0 on success
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.

Parameters:
TCAS_BUFa list, the list containing the raw TCAS FX data chunks
pix_starta PIX, the target start key frame PIX that is going to be added into the TCAS_BUF
pix_enda PIX, the target end key frame PIX that is going to be added into the TCAS_BUF
startan integer, the starting time of the PIX
endan integer, the end time of the PIX
offsetXa float, offset of the PIX in the horizontal direction
offsetYa float, offset of the PIX in the vertical direction
typean integer, type of the key frame PIX, 1 - normal, 2 - use bilinear filtering to make smooth motion
layeran integer, layer of the PIX
Returns:
0 on success
def tcaxLib.tcas_main (   TCAS_BUF,
  pix,
  start,
  end,
  offsetX,
  offsetY,
  layer 
)

Append a PIX to the TCAS_BUF list.

Parameters:
TCAS_BUFa list, the list containing the raw TCAS FX data chunks
pixa PIX, the target PIX that is going to be added into the TCAS_BUF
startan integer, the starting time of the PIX
endan integer, the end time of the PIX
offsetXa float, offset of the PIX in the horizontal direction
offsetYa float, offset of the PIX in the vertical direction
layeran integer, layer of the PIX
Returns:
0 on success

Get the current tcaxLib version.

Returns:
unicode string the current 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.

Parameters:
font_filea string, filename of the target font file
face_idan integer, font face id, should always be 1 in TTF files
font_sizean integer, font size, in em height
spacingan integer, spacing between texts, can be negative
space_scalea float, scale of white spaces
texta string, the text that is going to be measured
Returns:
(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 tcaxLib.TextMetrics (   font,
  text 
)

Retrieve the metrics of the specified text from a font.

Parameters:
fonta handler, the handler to the font
texta string, the text that is going to generate a PIX
Returns:
(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 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.

Parameters:
font_filea string, filename of the target font file
face_idan integer, font face id, should always be 1 in TTF files
font_sizean integer, font size, in em height
texta string, the text of which the outline will be retrieved
xan integer, position x of the offset
yan integer, position y of the offset
Returns:
unicode string the target ASS drawing commands
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.

Parameters:
fonta handler, the handler to the font
texta string, the text of which the outline will be retrieved
xan integer, position x of the offset
yan integer, position y of the offset
Returns:
unicode string the target ASS drawing commands
def tcaxLib.TextOutlinePoints (   font_file,
  face_id,
  font_size,
  text,
  density 
)

Get text outline points.

Parameters:
font_filea string, filename of the target font file
face_idan integer, font face id, should always be 1 in TTF files
font_sizean integer, font size, in em height
texta string, the text of which the outline will be retrieved
densitya 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
Returns:
((x1, y1), (x2, y2), ...)
def tcaxLib.TextOutlinePoints (   pyFont,
  text,
  density 
)

Get text outline points.

Parameters:
fonta handler, the handler to the font
texta string, the text of which the outline will be retrieved
densitya 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
Returns:
((x1, y1), (x2, y2), ...)
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.

Parameters:
font_filea string, filename of the target font file
face_idan integer, font face id, should always be 1 in TTF files
font_sizean integer, font size, in em height
spacingan integer, spacing between texts, can be negative
space_scalea float, scale of white spaces
coloran integer, rgb color of the font
bordan integer, border of the font, can be negative
is_outlinean integer, 0 - include body, 1 - only retrieve the outline
texta string, the text that is going to generate a PIX
Returns:
PIX the target PIX
def tcaxLib.TextPix (   font,
  text 
)

Retrieve a PIX of the specified text from a font.

Parameters:
fonta handler, the handler to the font
texta string, the text that is going to generate a PIX
Returns:
PIX the target PIX
def tcaxLib.VertLayout (   text)

Change the text to fit the vertical text layout, only used for ASS FX.

Parameters:
texta string, the target text that is going to be updated
Returns:
string the target text
def tcaxLib.WriteAssFile (   assFile,
  ASS_BUF 
)

Write ASS strings to ASS file.

Parameters:
assFilea handler, handler to the ASS file
ASS_BUFa list, the list containing the ASS FX strings
Returns:
0 on success
def tcaxLib.WriteTcasFile (   tcasFile,
  TCAS_BUF 
)

Write ASS strings to ASS file.

Parameters:
tcasFilea handler, handler to the TCAS file
TCAS_BUFa list, the list containing the raw TCAS FX data chunks
Returns:
0 on success
 All Classes Namespaces Files Functions