Definition: |
include pGUI.e
cdCanvasTransform(cdCanvas hCdCanvas, object matrix) |
Description: |
Defines a transformation matrix with 6 elements. If the matrix is NULL, the transformation is reset to the identity. Default value: NULL.
The matrix contains scale (sx,sy), rotation (angle) and translation (dx,dy) elements as follows: |x'| |sx*cos(angle) -sin(angle) dx| |x| |1 3 5| |y'| = | sin(angle) sy*cos(angle) dy| * |y| with indices |2 4 6| |1|In other words: matrix[1] = sx*cos(angle) // Horizontal Scale and Rotation component matrix[2] = sin(angle) // Rotation component (can also contain an horizontal shear component) matrix[3] = -sin(angle) // Rotation component (can also contain a vertical shear component) matrix[4] = sy*cos(angle) // Vertical Scale and Rotation component matrix[5] = dx // Horizontal Translation component matrix[6] = dy // Vertical Translation componentBut notice that the indices are different of the cdCanvasVectorTextTransform. Functions that retrieve images from the canvas are not affected by the transformation matrix, such as GetImage, GetImageRGB and ScrollArea. Transformation matrix is independent of the World Coordinate and Origin functions. And those are affected if a transformation is set, just like other regular primitives. The transformation matrix and world coordinates perform similar functions. World coordinates were developed before the transformation matrix support. The transformation matrix operates at a lower level than world coordinates, and, as such, might be faster, but might behave differently on different platforms. World coordinates behave consistently across platforms. |
Related functions |
object matrix = cdCanvasGetTransform(cdCanvas hCdCanvas)
Returns the transformation matrix. If the identity is set, returns NULL. cdCanvasTransformMultiply(cdCanvas hCdCanvas, sequence matrix) Left multiply the current transformation by the given transformation. cdCanvasTransformTranslate(cdCanvas hCdCanvas, atom dx, dy) Applies a translation to the current transformation. cdCanvasTransformScale(cdCanvas hCdCanvas, atom sx, sy) Applies a scale to the current transformation. cdCanvasTransformRotate(cdCanvas hCdCanvas, atom angle) Applies a rotation to the current transformation. Angle is in degrees, oriented counter-clockwise from the horizontal axis. atom {tx,ty} = cdCanvasTransformPoint(cdCanvas hCdCanvas, atom x, y) Applies a transformation to a given point. Since the one function can accept integers and floats in the parameters, and return atoms or integers, there is no need for a separate cdfCanvasTransformPoint wrapper. Internally it only uses the cdfCanvasTransformPoint C function. |