2.23 <PangoMatrix>

Structure: <PangoMatrix>

A <PangoMatrix> specifies a transformation between user-space and device coordinates.

The transformation is given by

x_device = x_user * matrix->xx + y_user * matrix->xy + matrix->x0;
y_device = x_user * matrix->yx + y_user * matrix->yy + matrix->y0;

Fields

xx

1st component of the transformation matrix

xy

2nd component of the transformation matrix

yx

3rd component of the transformation matrix

yy

4th component of the transformation matrix

x0

x translation

y0

y translation

Procedures

Method: matrix:concat self new-matrix
Method: concat self new-matrix

Changes the transformation represented by self to be the transformation given by first applying transformation given by new-matrix then applying the original transformation.

self

Passed: a <PangoMatrix>.

a <PangoMatrix>

new-matrix

Passed: a <PangoMatrix>.

a <PangoMatrix>

Method: matrix:copy self ⇒ %return
Method: copy self ⇒ %return

Copies a <PangoMatrix>.

self

Passed: a <PangoMatrix>.

a <PangoMatrix>

%return

Returned: a <PangoMatrix>, or #f.

the newly allocated <PangoMatrix>

Method: matrix:free self
Method: free self

Free a <PangoMatrix>.

self

Passed: a <PangoMatrix>.

a <PangoMatrix>, may be #f

Method: matrix:get-font-scale-factor self ⇒ %return
Method: get-font-scale-factor self ⇒ %return

Returns the scale factor of a matrix on the height of the font.

That is, the scale factor in the direction perpendicular to the vector that the X coordinate is mapped to. If the scale in the X coordinate is needed as well, use matrix:get-font-scale-factors.

self

Passed: a <PangoMatrix>.

a <PangoMatrix>, may be #f

%return

Returned: a real number.

the scale factor of self on the height of the font, or 1.0 if self is #f.

Method: matrix:get-font-scale-factors self ⇒ xscale yscale
Method: get-font-scale-factors self ⇒ xscale yscale

Calculates the scale factor of a matrix on the width and height of the font.

That is, xscale is the scale factor in the direction of the X coordinate, and yscale is the scale factor in the direction perpendicular to the vector that the X coordinate is mapped to.

Note that output numbers will always be non-negative.

self

Passed: a <PangoMatrix>.

a <PangoMatrix>

xscale

Returned: a real number.

output scale factor in the x direction

yscale

Returned: a real number.

output scale factor perpendicular to the x direction

Method: matrix:get-slant-ratio self ⇒ %return
Method: get-slant-ratio self ⇒ %return

Gets the slant ratio of a matrix.

For a simple shear matrix in the form:

1 λ 0 1

this is simply λ.

self

Passed: a <PangoMatrix>.

a <PangoMatrix>

%return

Returned: a real number.

the slant ratio of self

Method: matrix:rotate self degrees
Method: rotate self degrees

Changes the transformation represented by self to be the transformation given by first rotating by degrees degrees counter-clockwise then applying the original transformation.

self

Passed: a <PangoMatrix>.

a <PangoMatrix>

degrees

Passed: a real number.

degrees to rotate counter-clockwise

Method: matrix:scale self scale-x scale-y
Method: scale self scale-x scale-y

Changes the transformation represented by self to be the transformation given by first scaling by sx in the X direction and sy in the Y direction then applying the original transformation.

self

Passed: a <PangoMatrix>.

a <PangoMatrix>

scale-x

Passed: a real number.

amount to scale by in X direction

scale-y

Passed: a real number.

amount to scale by in Y direction

Method: matrix:transform-distance self dx dy ⇒ dx dy
Method: transform-distance self dx dy ⇒ dx dy

Transforms the distance vector (dx,dy) by self.

This is similar to matrix:transform-point, except that the translation components of the transformation are ignored. The calculation of the returned vector is as follows:

dx2 = dx1 * xx + dy1 * xy;
dy2 = dx1 * yx + dy1 * yy;

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.

self

Passed: a <PangoMatrix>.

a <PangoMatrix>

dx

Passed, and returned: a real number.

in/out X component of a distance vector

dy

Passed, and returned: a real number.

in/out Y component of a distance vector

Method: matrix:transform-pixel-rectangle! self rect ⇒ rect
Method: transform-pixel-rectangle! self rect ⇒ rect

First transforms the rect using self, then calculates the bounding box of the transformed rectangle.

This function is useful for example when you want to draw a rotated PangoLayout to an image buffer, and want to know how large the image should be and how much you should shift the layout when rendering.

For better accuracy, you should use matrix:transform-rectangle! on original rectangle in Pango units and convert to pixels afterward using extents_to_pixels’s first argument.

self

Passed: a <PangoMatrix>.

a <PangoMatrix>

rect

Passed, and returned: a <PangoRectangle>.

in/out bounding box in device units

Method: matrix:transform-point self x y ⇒ x y
Method: transform-point self x y ⇒ x y

Transforms the point (x, y) by self.

self

Passed: a <PangoMatrix>.

a <PangoMatrix>

x

Passed, and returned: a real number.

in/out X position

y

Passed, and returned: a real number.

in/out Y position

Method: matrix:transform-rectangle! self rect ⇒ rect
Method: transform-rectangle! self rect ⇒ rect

First transforms rect using self, then calculates the bounding box of the transformed rectangle.

This function is useful for example when you want to draw a rotated PangoLayout to an image buffer, and want to know how large the image should be and how much you should shift the layout when rendering.

If you have a rectangle in device units (pixels), use matrix:transform-pixel-rectangle!.

If you have the rectangle in Pango units and want to convert to transformed pixel bounding box, it is more accurate to transform it first (using this function) and pass the result to extents-to-pixels!, first argument, for an inclusive rounded rectangle. However, there are valid reasons that you may want to convert to pixels first and then transform, for example when the transformed coordinates may overflow in Pango units (large matrix translation for example).

self

Passed: a <PangoMatrix>.

a <PangoMatrix>

rect

Passed, and returned: a <PangoRectangle>.

in/out bounding box in Pango units

Method: matrix:translate self tx ty
Method: translate self tx ty

Changes the transformation represented by self to be the transformation given by first translating by (tx, ty) then applying the original transformation.

self

Passed: a <PangoMatrix>.

a <PangoMatrix>

tx

Passed: a real number.

amount to translate in the X direction

ty

Passed: a real number.

amount to translate in the Y direction