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 coerced to a double float with the xx component of the affine transformation
yx -- a number coerced to a double float with the yx component of the affine transformation
xy -- a number coerced to a double float with the xy component of the affine transformation
yy -- a number coerced to a double float with the yy component of the affine transformation
x0 -- a number coerced to a double float with the x translation component of the affine transformation
y0 -- a number coerced to a double float with the y translation component of the affine 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  

Example

The cairo:matrix-t structure is a CFFI type. Therefore to create a matrix we have to 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)    

Note

The cairo:with-matrix and cairo:with-matrices macros are more convenient to define and initialize a matrix in one step.
 

See also

2024-1-27