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.
This image shows 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
Replaces the current transformation matrix with a new matrix having the specified values. See the
SVG standard
for more information.
Arguments
- sx, sy
- The scale factor in the x-dimension and y-dimension, measured in user coordinates.
- rx, ry
- The amount of rotation about the x-axis and y-axis, measured in degrees.
- 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
skewX
obj.skewX(angle) ->
obj
Description
Skews the x-axis.
Arguments
- angle
- The skew amount, measured in degrees.
Example
See skewY
skewY
obj.skewY(angle) ->
obj
Description
Skews the y-axis.
Arguments
- angle
- The skew amount, measured in degrees.
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