Class (GI Struct)

Gsk-4.0GskTransform

Describes a 3D transform.

Unlike graphene_matrix_t, Gsk.Transform retains the steps in how a transform was constructed, and allows inspecting them. It is modeled after the way CSS describes transforms.

Gsk.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.

Index

Constructors

Properties

$gtype: GType<Transform>

Methods

  • Checks two transforms for equality.

    Parameters

    • Optionalsecond: Transform

      the second transform

    Returns boolean

    true if the two transforms perform the same operation

  • 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 Gsk.Transform.ref first if you want to keep it around.

    Returns Transform

    The inverted transform

  • 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 next. Use Gsk.Transform.ref first if you want to keep it around.

    Parameters

    • depth: number

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

    Returns Transform

    The new transform

  • Rotates next by an angle around the Z axis.

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

    This function consumes next. Use Gsk.Transform.ref first if you want to keep it around.

    Parameters

    • angle: number

      the rotation angle, in degrees (clockwise)

    Returns Transform

    The new transform

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

    Use Gsk.Transform.scale_3d to scale in all 3 dimensions.

    This function consumes next. Use Gsk.Transform.ref first if you want to keep it around.

    Parameters

    • factor_x: number

      scaling factor on the X axis

    • factor_y: number

      scaling factor on the Y axis

    Returns Transform

    The new transform

  • Scales next by the given factors.

    This function consumes next. Use Gsk.Transform.ref first if you want to keep it around.

    Parameters

    • factor_x: number

      scaling factor on the X axis

    • factor_y: number

      scaling factor on the Y axis

    • factor_z: number

      scaling factor on the Z axis

    Returns Transform

    The new transform

  • Applies a skew transform.

    This function consumes next. Use Gsk.Transform.ref first if you want to keep it around.

    Parameters

    • skew_x: number

      skew factor, in degrees, on the X axis

    • skew_y: number

      skew factor, in degrees, on the Y axis

    Returns Transform

    The new transform

  • Converts a transform to a 2D transformation matrix.

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

    `gsk_transform_get_category()` >= GSK_TRANSFORM_CATEGORY_2D
    

    to check.

    The returned values are a subset of the full 4x4 matrix that is computed by Gsk.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 Gsk.Transform and a matrix type from other 2D drawing libraries, in particular Cairo.

    Returns [number, number, number, number, number, number]

  • 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_T (dx, dy)),
                angle),
            scale_x, scale_y),
        skew_x, skew_y)
    

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

    `gsk_transform_get_category()` >= GSK_TRANSFORM_CATEGORY_2D
    

    to check.

    Returns [number, number, number, number, number, number, number]

  • 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

    `gsk_transform_get_category()` >= GSK_TRANSFORM_CATEGORY_2D_AFFINE
    

    to check.

    Returns [number, number, number, number]

  • Converts a transform to a translation operation.

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

    `gsk_transform_get_category()` >= GSK_TRANSFORM_CATEGORY_2D_TRANSLATE
    

    to check.

    Returns [number, number]

  • Releases a reference on the given transform.

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

    Returns void

  • Parses a given into a transform.

    Strings printed via Gsk.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.

    Parameters

    • string: string

      the string to parse

    Returns [boolean, Transform]