Package: cairo

Function cairo:matrix-init

Lambda List

cairo:matrix-init (matrix xx yx xy yy x0 y0)

Arguments

matrix -- a cairo:matrix-t instance to initialize
xx -- a number with the xx component of the transformation
yx -- a number with the yx component of the transformation
xy -- a number with the xy component of the transformation
yy -- a number with the yy component of the transformation
x0 -- a number with the x translation component of the transformation
y0 -- a number with the y translation component of the transformation

Return Value

The initialized cairo:matrix-t instance.

Details

Sets the matrix to be the affine transformation given by the xx, yx, xy, yy, x0, y0 arguments. The transformation is given by:
xnew = xx * x + xy * y + x0
ynew = yx * x + yy * y + y0  
The cairo:with-matrix and cairo:with-matrices macros are more convenient for defining and initialising a matrix in one step.

Examples

The cairo:matrix-t structure is a foreign CFFI type. Therefore, to create a matrix, we must define a foreign object:
(cffi:with-foreign-object (matrix '(:struct cairo:matrix-t))
  (cairo:matrix-init matrix 0.5 0.0 0.0 1.0 2.0 3.0)
  (cairo:matrix-to-float matrix))
=> (0.5d0 0.0d0 0.0d0 1.0d0 2.0d0 3.0d0)    
Defining and initialising a matrix with the cairo:with-matrix macro.
(cairo:with-matrix (matrix 1/2 0 0 1 2 3)
  (cairo:matrix-to-float matrix))
=> (0.5d0 0.0d0 0.0d0 1.0d0 2.0d0 3.0d0)    

Notes

The arguments are coerced to double floats before being passed to the foreign C functions.
 

See also

2025-1-18