Name
TransformBrush -- apply affine transformation to a brush (V4.5)
Synopsis
TransformBrush(id, sx, rx, ry, sy[, smooth])
Function
This function can be used to apply affine transformation to a brush. You have to pass a 2x2 transformation matrix to this function that will define how each pixel in the brush 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 ScaleBrush() and then RotateBrush(), but this would lead to quality losses. If you do the transformation using TransformBrush() 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 image 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 image 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 would apply this matrix to every pixel in your brush, the result would be just a copy of the brush. But of course, if TransformBrush() 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 brush. For instance, if you transform brush 1 to 12x8 pixels and then transform it back to 640x480, you will get a messed image. Therefore you should always keep the original brush and transform only copies of it.

Inputs
id
identifier of the brush 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
TransformBrush(1, Cos(angle), Sin(angle), -Sin(angle), Cos(angle))
The code above rotates brush number 1 by 45 degrees using a 2x2 transformation matrix.

Show TOC