The transform methods

Table of Contents

About the transform methods

Transform methods

About the transform methods

The default coordinate system has its origin in the upper-left corner. The positive x-axis extends to the right. The positive y-axis extends downward. You can change this coordinate system by using one or more of the transform methods described on this page. This image shows the default coordinate system.

initial coordinates example

This image shows a drawing without transformations.

a drawing without transformations

The transform methods are defined in the RVG, RVG::Group, and RVG::Use classes. You can also chain these methods to the shape methods and to the image method.

Transform methods

matrix

obj.matrix(sx, rx, ry, sy, tx, ty) -> obj

Description

Multiplies the current transformation matrix by a matrix having the specified values. See the SVG standard for more information. Note that the meaning of rx and ry depends on the ImageMagick version, as described below.

Arguments
sx, sy
The scale factor in the x-dimension and y-dimension, measured in user coordinates.
rx, ry
Matrix elements, not angles. With ImageMagick 7.1.2-0 or later, or 6.9.13-26 or later, a point (x, y) is mapped to (sx*x + rx*y + tx, ry*x + sy*y + ty), so SVG's matrix(a, b, c, d, e, f) is matrix(a, c, b, d, e, f) here. With older versions, a point is mapped to (sx*x + ry*y + tx, rx*x + sy*y + ty), the same as SVG's matrix(sx, rx, ry, sy, tx, ty).
tx, ty
The translation on the x-axis and the y-axis, measured in user coordinates.

rotate

obj.rotate(angle[, cx, cy]) -> obj

Description

Rotates the axes about the origin or, if cx and cy are present, about the specified point.

Arguments
angle
The amount of rotation. Positive angles rotate clockwise, negative angles rotate counter-clockwise.
cx, cy
If present, the point to rotate about.
Example

See scale.

scale

obj.scale(sx[, sy]) -> obj

Description

Scales the axes.

Arguments
sx
The amount of scaling on the x-axis.
sy
If present, the amount of scaling on the y-axis. Otherwise defaults to sx.
Example

rotate and scale example

skewX

obj.skewX(angle) -> obj

Description

Skews the x-axis.

Arguments
angle
The skew amount, measured in degrees. ImageMagick shears by sin(angle), not tan(angle) as SVG does, so the result differs from SVG's skewX. For example, an angle of 30 slants the axis by about 26.6 degrees.
Example

See skewY

skewY

obj.skewY(angle) -> obj

Description

Skews the y-axis.

Arguments
angle
The skew amount, measured in degrees. ImageMagick shears by -tan(angle/2), not tan(angle) as SVG does, so the result differs from SVG's skewY. A positive angle slants the axis the opposite way to SVG, by half the angle.
Example

skewX and skewY example

translate

obj.translate(tx[, ty]) -> obj

Description

Moves the origin.

Arguments
tx
The location of the new origin on the x-axis.
ty
The location of the new origin on the y-axis. If omitted, defaults to tx.
Example

translate example