2.12 <GskTransform>

Structure: <GskTransform>

Describes a 3D transform.

Unlike <GrapheneMatrix>, <GskTransform> retains the steps in how a transform was constructed, and allows inspecting them. It is modeled after the way CSS describes transforms.

<GskTransform> objects are immutable and cannot be changed after creation. This means code can safely expose them as properties of objects without having to worry about others changing them.

Procedures

Method: transform:equal? self [second] ⇒ %return
Method: equal? self [second] ⇒ %return

Checks two transforms for equality.

self

Passed: a <GskTransform>.

the first transform

second

Passed, or left out: a <GskTransform>, or #f.

the second transform

%return

Returned: a boolean.

true if the two transforms perform the same operation

Method: transform:get-category self ⇒ %return
Method: get-category self ⇒ %return

Returns the category this transform belongs to.

self

Passed: a <GskTransform>.

a transform

%return

Returned: a <GskTransformCategory>.

The category of the transform

Method: transform:invert self ⇒ %return
Method: invert self ⇒ %return

Inverts the given transform.

If self is not invertible, NULL is returned. Note that inverting NULL also returns NULL, which is the correct inverse of NULL. If you need to differentiate between those cases, you should check self is not NULL before calling this function.

This function consumes self. Use transform:ref first if you want to keep it around.

self

Passed: a <GskTransform>.

transform to invert

%return

Returned: a <GskTransform>, or #f.

The inverted transform

Method: transform:matrix self matrix ⇒ %return
Method: matrix self matrix ⇒ %return

Multiplies self with the given matrix.

This function consumes self. Use transform:ref first if you want to keep it around.

self

Passed: a <GskTransform>.

the next transform

matrix

Passed: a <GrapheneMatrix>.

the matrix to multiply self with

%return

Returned: a <GskTransform>.

The new transform

Method: transform:matrix-2d self xx yx xy yy dx dy ⇒ %return
Method: matrix-2d self xx yx xy yy dx dy ⇒ %return

Multiplies self with the matrix [ xx yx x0; xy yy y0; 0 0 1 ].

The result of calling transform:to-2d on the returned <GskTransform> should match the input passed to this function.

This function consumes self. Use transform:ref first if you want to keep it around.

self

Passed: a <GskTransform>.

the next transform

xx

Passed: a real number.

the xx member

yx

Passed: a real number.

the yx member

xy

Passed: a real number.

the xy member

yy

Passed: a real number.

the yy member

dx

Passed: a real number.

the x0 member

dy

Passed: a real number.

the y0 member

%return

Returned: a <GskTransform>, or #f.

The new transform

Procedure: transform:new ⇒ %return

Creates a new identity transform.

This function is meant to be used by language bindings. For C code, this is equivalent to using NULL.

%return

Returned: a <GskTransform>.

A new identity transform

Procedure: transform:parse string ⇒ %return out-transform

Parses a given into a transform.

Strings printed via transform:to-string can be read in again successfully using this function.

If string does not describe a valid transform, false is returned and NULL is put in out-transform.

string

Passed: a string.

the string to parse

%return

Returned: a boolean.

true if string described a valid transform

out-transform

Returned: a <GskTransform>.

return location for the transform

Method: transform:perspective self depth ⇒ %return
Method: perspective self depth ⇒ %return

Applies a perspective projection transform.

This transform scales points in X and Y based on their Z value, scaling points with positive Z values away from the origin, and those with negative Z values towards the origin. Points on the z=0 plane are unchanged.

This function consumes self. Use transform:ref first if you want to keep it around.

self

Passed: a <GskTransform>.

the next transform

depth

Passed: a real number.

distance of the z=0 plane. Lower values give a more flattened pyramid and therefore a more pronounced perspective effect.

%return

Returned: a <GskTransform>.

The new transform

Method: transform:print self string
Method: print self string

Converts the transform into a human-readable representation.

The result of this function can later be parsed with transform:parse.

self

Passed: a <GskTransform>.

a transform

string

Passed: a <GString>.

The string to print into

Method: transform:ref self ⇒ %return
Method: ref self ⇒ %return

Acquires a reference on the given transform.

self

Passed: a <GskTransform>.

a transform

%return

Returned: a <GskTransform>, or #f.

the transform with an additional reference

Method: transform:rotate self angle ⇒ %return
Method: rotate self angle ⇒ %return

Rotates self by an angle around the Z axis.

The rotation happens around the origin point of (0, 0).

This function consumes self. Use transform:ref first if you want to keep it around.

self

Passed: a <GskTransform>.

the next transform

angle

Passed: a real number.

the rotation angle, in degrees (clockwise)

%return

Returned: a <GskTransform>, or #f.

The new transform

Method: transform:rotate-3d self angle axis ⇒ %return
Method: rotate-3d self angle axis ⇒ %return

Rotates self angle degrees around axis.

For a rotation in 2D space, use transform:rotate

This function consumes self. Use transform:ref first if you want to keep it around.

self

Passed: a <GskTransform>.

the next transform

angle

Passed: a real number.

the rotation angle, in degrees (clockwise)

axis

Passed: a <GrapheneVec3>.

The rotation axis

%return

Returned: a <GskTransform>, or #f.

The new transform

Method: transform:scale self factor-x factor-y ⇒ %return
Method: scale self factor-x factor-y ⇒ %return

Scales self in 2-dimensional space by the given factors.

Use transform:scale-3d to scale in all 3 dimensions.

This function consumes self. Use transform:ref first if you want to keep it around.

self

Passed: a <GskTransform>.

the next transform

factor-x

Passed: a real number.

scaling factor on the X axis

factor-y

Passed: a real number.

scaling factor on the Y axis

%return

Returned: a <GskTransform>, or #f.

The new transform

Method: transform:scale-3d self factor-x factor-y factor-z ⇒ %return
Method: scale-3d self factor-x factor-y factor-z ⇒ %return

Scales self by the given factors.

This function consumes self. Use transform:ref first if you want to keep it around.

self

Passed: a <GskTransform>.

the next transform

factor-x

Passed: a real number.

scaling factor on the X axis

factor-y

Passed: a real number.

scaling factor on the Y axis

factor-z

Passed: a real number.

scaling factor on the Z axis

%return

Returned: a <GskTransform>, or #f.

The new transform

Method: transform:skew self skew-x skew-y ⇒ %return
Method: skew self skew-x skew-y ⇒ %return

Applies a skew transform.

This function consumes self. Use transform:ref first if you want to keep it around.

self

Passed: a <GskTransform>.

the next transform

skew-x

Passed: a real number.

skew factor, in degrees, on the X axis

skew-y

Passed: a real number.

skew factor, in degrees, on the Y axis

%return

Returned: a <GskTransform>, or #f.

The new transform

Method: transform:to-2d self ⇒ out-xx out-yx out-xy out-yy out-dx out-dy
Method: to-2d self ⇒ out-xx out-yx out-xy out-yy out-dx out-dy

Converts a transform to a 2D transformation matrix.

self must be a 2D transformation. If you are not sure, use

transform:get-category >= GSK_TRANSFORM_CATEGORY_2D

to check.

The returned values are a subset of the full 4x4 matrix that is computed by transform:to-matrix! and have the following layout:

  | xx yx |   |  a  b  0 |
  | xy yy | = |  c  d  0 |
  | dx dy |   | tx ty  1 |

This function can be used to convert between a <GskTransform> and a matrix type from other 2D drawing libraries, in particular Cairo.

self

Passed: a <GskTransform>.

a 2D transform

out-xx

Returned: a real number.

return location for the xx member

out-yx

Returned: a real number.

return location for the yx member

out-xy

Returned: a real number.

return location for the xy member

out-yy

Returned: a real number.

return location for the yy member

out-dx

Returned: a real number.

return location for the x0 member

out-dy

Returned: a real number.

return location for the y0 member

Method: transform:to-2d-components self ⇒ out-skew-x out-skew-y out-scale-x out-scale-y out-angle out-dx out-dy
Method: to-2d-components self ⇒ out-skew-x out-skew-y out-scale-x out-scale-y out-angle out-dx out-dy

Converts a transform to 2D transformation factors.

To recreate an equivalent transform from the factors returned by this function, use

gsk_transform_skew ( gsk_transform_scale ( gsk_transform_rotate ( gsk_transform_translate (NULL, &GRAPHENE_POINT_INIT (dx, dy)), angle), scale_x, scale_y), skew_x, skew_y)

self must be a 2D transformation. If you are not sure, use

transform:get-category >= GSK_TRANSFORM_CATEGORY_2D

to check.

self

Passed: a <GskTransform>.

a transform

out-skew-x

Returned: a real number.

return location for the skew factor in the x direction

out-skew-y

Returned: a real number.

return location for the skew factor in the y direction

out-scale-x

Returned: a real number.

return location for the scale factor in the x direction

out-scale-y

Returned: a real number.

return location for the scale factor in the y direction

out-angle

Returned: a real number.

return location for the rotation angle

out-dx

Returned: a real number.

return location for the translation in the x direction

out-dy

Returned: a real number.

return location for the translation in the y direction

Method: transform:to-affine self ⇒ out-scale-x out-scale-y out-dx out-dy
Method: to-affine self ⇒ out-scale-x out-scale-y out-dx out-dy

Converts a transform to 2D affine transformation factors.

To recreate an equivalent transform from the factors returned by this function, use

gsk_transform_scale ( gsk_transform_translate ( NULL, &GRAPHENE_POINT_T (dx, dy)), sx, sy)

self must be a 2D affine transformation. If you are not sure, use

transform:get-category >= GSK_TRANSFORM_CATEGORY_2D_AFFINE

to check.

self

Passed: a <GskTransform>.

a transform

out-scale-x

Returned: a real number.

return location for the scale factor in the x direction

out-scale-y

Returned: a real number.

return location for the scale factor in the y direction

out-dx

Returned: a real number.

return location for the translation in the x direction

out-dy

Returned: a real number.

return location for the translation in the y direction

Method: transform:to-matrix! self out-matrix ⇒ out-matrix
Method: to-matrix! self out-matrix ⇒ out-matrix

Computes the 4x4 matrix for the transform.

The previous value of out-matrix will be ignored.

self

Passed: a <GskTransform>.

a transform

out-matrix

Passed, filled in, and returned: a <GrapheneMatrix>.

return location for the matrix

Method: transform:to-string self ⇒ %return
Method: to-string self ⇒ %return

Converts the transform into a human-readable string.

The resulting string can be parsed with transform:parse.

This is a wrapper around transform:print.

self

Passed: a <GskTransform>.

a transform

%return

Returned: a string.

A new string for self

Method: transform:to-translate self ⇒ out-dx out-dy
Method: to-translate self ⇒ out-dx out-dy

Converts a transform to a translation operation.

self must be a 2D transformation. If you are not sure, use

transform:get-category >= GSK_TRANSFORM_CATEGORY_2D_TRANSLATE

to check.

self

Passed: a <GskTransform>.

a transform

out-dx

Returned: a real number.

return location for the translation in the x direction

out-dy

Returned: a real number.

return location for the translation in the y direction

Method: transform:transform self [other] ⇒ %return
Method: transform self [other] ⇒ %return

Applies all the operations from other to self.

This function consumes self. Use transform:ref first if you want to keep it around.

self

Passed: a <GskTransform>.

transform to apply other to

other

Passed, or left out: a <GskTransform>, or #f.

transform to apply

%return

Returned: a <GskTransform>, or #f.

The new transform

Method: transform:transform-bounds! self rect out-rect ⇒ out-rect
Method: transform-bounds! self rect out-rect ⇒ out-rect

Transforms a rectangle using the given transform.

The result is the bounding box containing the coplanar quad.

The input and output rect may point to the same rectangle.

self

Passed: a <GskTransform>.

a transform

rect

Passed: a <GrapheneRect>.

the rectangle to transform

out-rect

Passed, filled in, and returned: a <GrapheneRect>.

return location for the bounds of the transformed rectangle

Method: transform:transform-point! self point out-point ⇒ out-point
Method: transform-point! self point out-point ⇒ out-point

Transforms a point using the given transform.

self

Passed: a <GskTransform>.

a transform

point

Passed: a <GraphenePoint>.

the point to transform

out-point

Passed, filled in, and returned: a <GraphenePoint>.

return location for the transformed point

Method: transform:translate self point ⇒ %return
Method: translate self point ⇒ %return

Translates self in 2-dimensional space by point.

This function consumes self. Use transform:ref first if you want to keep it around.

self

Passed: a <GskTransform>.

the next transform

point

Passed: a <GraphenePoint>.

the point to translate the transform by

%return

Returned: a <GskTransform>, or #f.

The new transform

Method: transform:translate-3d self point ⇒ %return
Method: translate-3d self point ⇒ %return

Translates self by point.

This function consumes self. Use transform:ref first if you want to keep it around.

self

Passed: a <GskTransform>.

the next transform

point

Passed: a <GraphenePoint3D>.

the point to translate the transform by

%return

Returned: a <GskTransform>, or #f.

The new transform

Method: transform:unref self
Method: unref self

Releases a reference on the given transform.

If the reference was the last, the resources associated to the self are freed.

self

Passed: a <GskTransform>.

a transform