cairo::matrix+x86_64 +linux

Generic matrix operations.

cairo::matrix_t is used throughout cairo to convert between different coordinate spaces. A cairo::matrix_t holds an affine transformation, such as a scale, rotation, shear, or a combination of these. The transformation of a point (x,y) is given by:

x_new = xx * x + xy * y + x0; y_new = yx * x + yy * y + y0;

The current transformation matrix of a cairo::context_t, represented as a cairo::matrix_t, defines the transformation from user-space coordinates to device-space coordinates. See cairo::get_matrix and cairo::set_matrix.

Index

Functions

fn init(xx: f64, yx: f64, xy: f64, yy: f64, x0: f64, y0: f64) cairo::matrix_t;
fn init_identity() cairo::matrix_t;
fn init_rotate(radians: f64) cairo::matrix_t;
fn init_scale(sx: f64, sy: f64) cairo::matrix_t;
fn init_translate(tx: f64, ty: f64) cairo::matrix_t;
fn invert(matrix: *cairo::matrix_t) (void | cairo::error);
fn multiply(a: *const cairo::matrix_t, b: *const cairo::matrix_t) cairo::matrix_t;
fn rotate(matrix: *cairo::matrix_t, radians: f64) void;
fn scale(matrix: *cairo::matrix_t, sx: f64, sy: f64) void;
fn transform_distance(matrix: *const cairo::matrix_t, dx: f64, dy: f64) (f64, f64);
fn transform_point(matrix: *const cairo::matrix_t, x: f64, y: f64) (f64, f64);
fn translate(matrix: *cairo::matrix_t, tx: f64, ty: f64) void;

Functions

fn init[link]

fn init(xx: f64, yx: f64, xy: f64, yy: f64, x0: f64, y0: f64) cairo::matrix_t;

Initialize a matrix to the affine transformation given by xx, yx, xy, yy, x0, y0. The transformation is given by:

x_new = xx * x + xy * y + x0; y_new = yx * x + yy * y + y0;

Parameters

fn init_identity[link]

fn init_identity() cairo::matrix_t;

Initialize a matrix to an identity transformation.

fn init_rotate[link]

fn init_rotate(radians: f64) cairo::matrix_t;

Initialize a matrix to a transformation that rotates by radians.

Parameters

fn init_scale[link]

fn init_scale(sx: f64, sy: f64) cairo::matrix_t;

Initialize a matrix to a transformation that scales by sx and sy in the X and Y dimensions, respectively.

Parameters

fn init_translate[link]

fn init_translate(tx: f64, ty: f64) cairo::matrix_t;

Initialize a matrix to a transformation that translates by tx and ty in the X and Y dimensions, respectively.

Parameters

fn invert[link]

fn invert(matrix: *cairo::matrix_t) (void | cairo::error);

Changes matrix to be the inverse of its original value. Not all transformation matrices have inverses; if the matrix collapses points together (it is degenerate), then it has no inverse and this function will fail.

If matrix has an inverse, modifies matrix to be the inverse matrix. Otherwise, returns cairo::error.

fn multiply[link]

fn multiply(a: *const cairo::matrix_t, b: *const cairo::matrix_t) cairo::matrix_t;

Multiplies the affine transformations in a and b together. The effect of the resulting transformation is to first apply the transformation in a to the coordinates and then apply the transformation in b to the coordinates.

fn rotate[link]

fn rotate(matrix: *cairo::matrix_t, radians: f64) void;

Applies rotation by radians to the transformation in matrix. The effect of the new transformation is to first rotate the coordinates by radians, then apply the original transformation to the coordinates.

Parameters

fn scale[link]

fn scale(matrix: *cairo::matrix_t, sx: f64, sy: f64) void;

Applies scaling by sx, sy to the transformation in matrix. The effect of the new transformation is to first scale the coordinates by sx and sy, then apply the original transformation to the coordinates.

Parameters

fn transform_distance[link]

fn transform_distance(matrix: *const cairo::matrix_t, dx: f64, dy: f64) (f64, f64);

Transforms the distance vector (dx, dy) by matrix. This is similar to transform_point except that the translation components of the transformation are ignored. The calculation of the returned vector is as follows:

dx2 = dx1 * a + dy1 * c; dy2 = dx1 * b + dy1 * d;

Affine transformations are position invariant, so the same vector always transforms to the same vector. If (x1, y1) transforms to (x2, y2) then (x1 + dx1, y1 + dy1) will transform to (x1 + dx2, y1 + dy2) for all values of x1 and x2.

Parameters

fn transform_point[link]

fn transform_point(matrix: *const cairo::matrix_t, x: f64, y: f64) (f64, f64);

Transforms the point (x, y) by matrix.

Parameters

fn translate[link]

fn translate(matrix: *cairo::matrix_t, tx: f64, ty: f64) void;

Applies a translation by tx, ty to the transformation in matrix. The effect of the new transformation is to first translate the coordinates by tx and ty, then apply the original transformation to the coordinates.

Parameters