Name
TransformBox -- apply affine transformation to rectangle (V10.0)
Synopsis
tx, ty, tw, th = TransformBox(x, y, w, h, m[, origin, anchorx, anchory])
Function
This function applies the 2x2 transformation matrix specified by m to the rectangle specified by x, y, w and h and returns the size and coordinates of the transformed rectangle. The origin parameter is a boolean value which specifies whether or not the rectangle should be moved to the origin before transforming it. The anchorx and anchory values specify the anchor point to use for the transformation. This should be a floating point value between 0.0 and 1.0 where 0.0 means the left/upper edge and 1.0 indicates the right/bottom edge. anchorx and anchory both default to 0 which means the upper-left corner of the rectangle is the default anchor point.

The transformation matrix m must be passed as a table that has the following fields initialized:

sx:
Amount of scaling on the x axis.

rx:
Amount of rotation on the x axis.

ry:
Amount of rotation on the y axis.

sy:
Amount of scaling on the y axis.

You can use the Matrix2D() function to construct such a matrix. See Matrix2D for details.

Inputs
x
left edge of rectangle
y
upper edge of rectangle
w
rectangle width
h
rectangle height
m
table containing a 2x2 transformation matrix
origin
optional: whether or not to move the rectangle to the origin before transforming it (defaults to True)
anchorx
optional: horizontal anchor point (defaults to 0 which means left edge)
anchory
optional: vertical anchor point (defaults to 0 which means top edge)
Results
tx
transformed left edge
ty
transformed upper edge
tw
transformed width
th
transformed height

Show TOC