Name
TransformTextObject -- apply affine transformation to text object (V10.0)
Synopsis
TransformTextObject(id, sx, rx, ry, sy[, smooth])
Library
text

Function
This function can be used to apply affine transformation to a text object. You have to pass a 2x2 transformation matrix to this function that will define how each pixel in the text object will be transformed. This function is useful if you want to apply rotation and scaling at the same time. Of course, you could do this with calls to ScaleTextObject() and then RotateTextObject(), but this would lead to quality losses. If you do the transformation using TransformTextObject() instead, everything will be done in a single run.

The 2x2 transformation matrix consists of four floating point factors:

sx:
Specifies the amount of scaling on the x axis. This must not be zero. If it is negative, the text object is flipped on the y axis.

rx:
Specifies the amount of rotation on the x axis. This can be 0.

ry:
Specifies the amount of rotation on the y axis. This can be 0.

sy:
Specifies the amount of scaling on the y axis. This must not be zero. If it is negative, the text object is flipped on the x axis.

The identity matrix is defined as

 
( 1  0 )
( 0  1 )

If you pass this matrix, then no transformation will be applied because there is no rotation and no scaling defined. I.e. if Hollywood applied this matrix to every pixel in your text object, the result would be just a copy of the text object. But of course, if TransformTextObject() detects that you passed an identity matrix, it will return immediately and do nothing.

The optional argument smooth can be set to True if Hollywood shall use interpolation during the transformation. This yields results that look better but interpolation is quite slow.

Please note: You should always do transformation operations using the original text object. For instance, if you transform text object 1 to 12x8 pixels and then transform it back to 640x480, you will get a messed text object. Therefore you should always keep the original text object and transform only copies of it.

Note that for vector text objects, TransformTextObject() will always operate on the untransformed text object. This means that any previous transformations applied to the text object using TransformTextObject(), ScaleTextObject(), or RotateTextObject() will be undone when calling TransformTextObject().

Inputs
id
identifier of the text object to be transformed
sx
scale x factor; must never be 0
rx
rotate x factor
ry
rotate y factor
sy
scale y factor; must never be 0
smooth
optional: whether or not affine transformation should use interpolation
Example
angle = Rad(45)    ; convert degrees to radians
TransformTextObject(1, Cos(angle), Sin(angle), -Sin(angle), Cos(angle))
The code above rotates text object number 1 by 45 degrees using a 2x2 transformation matrix.

Show TOC