Name

transform( ) — transform a polygon

Synopsis

GD::Polygon::transform(scaleX, rotateX, scaleY, rotateY, x, y)

This method will apply a transformation matrix to each vertex in a polygon. A transformation matrix is a way of mapping one coordinate system into another; the transform( ) method provides a means for managing multiple coordinate spaces while creating images. Each polygon can be defined in terms of its own coordinate space, for example, and then later mapped to that of the final image.

The transform( ) method takes the following as parameters (note their order, listed earlier):

scaleX, scaleY

The horizontal and vertical scaling factors within the current coordinate system (i.e., before rotations or offsets). These factors are expressed in multiples of the current polygon size, so a scale factor of 4 indicates a 400% increase in size. Use a fractional value to reduce the size.

rotateX, rotateY

The rotation factor, in degrees, to be applied to each vertex.

x, y

The horizontal and vertical offset that should be applied to each vertex.

Get Programming Web Graphics with Perl and GNU Softwar now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.