About all my projects
Gnome::Gsk4::N-Transform

Gnome::Gsk4::N-Transform

Description

Gnome::Gsk4::N-Transform is an object to describe transform matrices.

Unlike Gnome::Graphene::N-Matrix, Gnome::Gsk4::N-Transform retains the steps in how a transform was constructed, and allows inspecting them. It is modeled after the way CSS describes transforms.

Gnome::Gsk4::N-Transform 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.

Class initialization

new

:native-object

Create an object using a native object from elsewhere. See also Gnome::N::TopLevelSupportClass.

multi method new ( N-Object :$native-object! )

new-transform

No documentation of method new.

method new-transform ( --> Gnome::Gsk4::Transform \)

Methods

equal

Checks two transforms for equality.

method equal ( N-Object $second --> Bool )
  • $second; the second transform

Return value; True if the two transforms perform the same operation.

get-category

Returns the category this transform belongs to.

method get-category (--> GskTransformCategory )

Return value; The category of the transform.

invert

Inverts the given transform.

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

method invert (--> N-Object )

Return value; The inverted transform.

matrix

Multiplies $next with the given $matrix.

method matrix ( N-Object $matrix --> N-Object )
  • $matrix; the matrix to multiply $next with

Return value; The new transform.

perspective

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.

method perspective ( Num() $depth --> N-Object )
  • $depth; distance of the z=0 plane. Lower values give a more flattened pyramid and therefore a more pronounced perspective effect..

Return value; The new transform.

print

Converts $self into a human-readable string representation suitable for printing.

The result of this function can later be parsed with .Transform.parse().

method print ( N-Object $string )
  • $string; The string to print into

ref

Acquires a reference on the given Gnome::Gsk4::N-Transform.

method ref (--> N-Object )

Return value; the Gnome::Gsk4::N-Transform with an additional reference.

rotate

Rotates $next $angle degrees in 2D - or in 3D-speak, around the z axis.

method rotate ( Num() $angle --> N-Object )
  • $angle; the rotation angle, in degrees (clockwise).

Return value; The new transform.

rotate-3d

Rotates $next $angle degrees around $axis.

For a rotation in 2D space, use .rotate()

method rotate-3d ( Num() $angle, N-Object $axis --> N-Object )
  • $angle; the rotation angle, in degrees (clockwise).

  • $axis; The rotation axis

Return value; The new transform.

scale

Scales $next in 2-dimensional space by the given factors.

Use .scale-3d() to scale in all 3 dimensions.

method scale ( Num() $factor-x, Num() $factor-y --> N-Object )
  • $factor-x; scaling factor on the X axis.

  • $factor-y; scaling factor on the Y axis.

Return value; The new transform.

scale-3d

Scales $next by the given factors.

method scale-3d ( Num() $factor-x, Num() $factor-y, Num() $factor-z --> N-Object )
  • $factor-x; scaling factor on the X axis.

  • $factor-y; scaling factor on the Y axis.

  • $factor-z; scaling factor on the Z axis.

Return value; The new transform.

skew

Applies a skew transform.

method skew ( Num() $skew-x, Num() $skew-y --> N-Object )
  • $skew-x; skew factor, in degrees, on the X axis.

  • $skew-y; skew factor, in degrees, on the Y axis.

Return value; The new transform.

to-2d

Converts a Gnome::Gsk4::N-Transform to a 2D transformation matrix. $self must be a 2D transformation. If you are not sure, use .get-category() >= %GSK_TRANSFORM_CATEGORY_2D to check.

The returned values have the following layout:

This function can be used to convert between a Gnome::Gsk4::N-Transform and a matrix type from other 2D drawing libraries, in particular Cairo.

method to-2d ( Num() $out-xx, Num() $out-yx, Num() $out-xy, Num() $out-yy, Num() $out-dx, Num() $out-dy )
  • $out-xx; (transfer ownership: full) return location for the xx member.

  • $out-yx; (transfer ownership: full) return location for the yx member.

  • $out-xy; (transfer ownership: full) return location for the xy member.

  • $out-yy; (transfer ownership: full) return location for the yy member.

  • $out-dx; (transfer ownership: full) return location for the x0 member.

  • $out-dy; (transfer ownership: full) return location for the y0 member.

to-2d-components

Converts a Gnome::Gsk4::N-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_T (dx, dy)),
            angle),
        scale_x, scale_y),
    skew_x, skew_y)
C<$self> must be a 2D transformation. If you are not sure, use

   C<.get-category()> >= %GSK_TRANSFORM_CATEGORY_2D

to check.

method to-2d-components ( Num() $out-skew-x, Num() $out-skew-y, Num() $out-scale-x, Num() $out-scale-y, Num() $out-angle, Num() $out-dx, Num() $out-dy )
  • $out-skew-x; (transfer ownership: full) return location for the skew factor in the x direction.

  • $out-skew-y; (transfer ownership: full) return location for the skew factor in the y direction.

  • $out-scale-x; (transfer ownership: full) return location for the scale factor in the x direction.

  • $out-scale-y; (transfer ownership: full) return location for the scale factor in the y direction.

  • $out-angle; (transfer ownership: full) return location for the rotation angle.

  • $out-dx; (transfer ownership: full) return location for the translation in the x direction.

  • $out-dy; (transfer ownership: full) return location for the translation in the y direction.

to-affine

Converts a Gnome::Gsk4::N-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)
C<$self> must be a 2D affine transformation. If you are not

sure, use

C<.get-category()> >= %GSK_TRANSFORM_CATEGORY_2D_AFFINE

to check.

method to-affine ( Num() $out-scale-x, Num() $out-scale-y, Num() $out-dx, Num() $out-dy )
  • $out-scale-x; (transfer ownership: full) return location for the scale factor in the x direction.

  • $out-scale-y; (transfer ownership: full) return location for the scale factor in the y direction.

  • $out-dx; (transfer ownership: full) return location for the translation in the x direction.

  • $out-dy; (transfer ownership: full) return location for the translation in the y direction.

to-matrix

Computes the actual value of $self and stores it in $out-matrix.

The previous value of $out-matrix will be ignored.

method to-matrix ( N-Object $out-matrix )
  • $out-matrix; The matrix to set

to-string

Converts a matrix into a string that is suitable for printing.

The resulting string can be parsed with .Transform.parse().

This is a wrapper around .print().

method to-string (--> Str )

Return value; A new string for $self.

to-translate

Converts a Gnome::Gsk4::N-Transform to a translation operation. $self must be a 2D transformation. If you are not sure, use

C<.get-category()> >= %GSK_TRANSFORM_CATEGORY_2D_TRANSLATE

to check.

method to-translate ( Num() $out-dx, Num() $out-dy )
  • $out-dx; (transfer ownership: full) return location for the translation in the x direction.

  • $out-dy; (transfer ownership: full) return location for the translation in the y direction.

transform

Applies all the operations from $other to $next.

method transform ( N-Object $other --> N-Object )
  • $other; Transform to apply

Return value; The new transform.

transform-bounds

Transforms a Gnome::Graphene::N-Rect using the given transform $self.

The result is the bounding box containing the coplanar quad.

method transform-bounds ( N-Object $rect, N-Object $out-rect )
  • $rect; a Gnome::Graphene::N-Rect

  • $out-rect; return location for the bounds of the transformed rectangle

transform-point

Transforms a Gnome::Graphene::N-Point using the given transform $self.

method transform-point ( N-Object $point, N-Object $out-point )
  • $point; a Gnome::Graphene::N-Point

  • $out-point; return location for the transformed point

translate

Translates $next in 2-dimensional space by $point.

method translate ( N-Object $point --> N-Object )
  • $point; the point to translate the transform by

Return value; The new transform.

translate-3d

Translates $next by $point.

method translate-3d ( N-Object $point --> N-Object )
  • $point; the point to translate the transform by

Return value; The new transform.

unref

Releases a reference on the given Gnome::Gsk4::N-Transform.

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

method unref ( )

Functions

parse

Parses the given $string into a transform and puts it in $out-transform.

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

If $string does not describe a valid transform, False is returned and undefined is put in $out-transform.

method parse ( Str $string, N-Object $out-transform --> Bool )
  • $string; the string to parse.

  • $out-transform; (transfer ownership: full) The location to put the transform in

Return value; True if $string described a valid transform..