Gjsify LogoGjsify Logo

GskTransform is an object to describe transform matrices.

Unlike graphene_matrix_t, 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.

record

Hierarchy

  • Transform

Index

Constructors

Properties

name: string

Methods

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

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

    Parameters

    • depth: number

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

    Returns Gsk.Transform

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

    The result of this function can later be parsed with [funcGsk.Transform.parse].

    Parameters

    Returns void

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

    Parameters

    • angle: number

      the rotation angle, in degrees (clockwise)

    Returns Gsk.Transform

  • Rotates next angle degrees around axis.

    For a rotation in 2D space, use [methodGsk.Transform.rotate]

    Parameters

    • angle: number

      the rotation angle, in degrees (clockwise)

    • axis: Graphene.Vec3

      The rotation axis

    Returns Gsk.Transform

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

    Use [methodGsk.Transform.scale_3d] to scale in all 3 dimensions.

    Parameters

    • factorX: number

      scaling factor on the X axis

    • factorY: number

      scaling factor on the Y axis

    Returns Gsk.Transform

  • scale3d(factorX: number, factorY: number, factorZ: number): Gsk.Transform
  • Scales next by the given factors.

    Parameters

    • factorX: number

      scaling factor on the X axis

    • factorY: number

      scaling factor on the Y axis

    • factorZ: number

      scaling factor on the Z axis

    Returns Gsk.Transform

  • Applies a skew transform.

    Parameters

    • skewX: number

      skew factor, in degrees, on the X axis

    • skewY: number

      skew factor, in degrees, on the Y axis

    Returns Gsk.Transform

  • to2d(): [number, number, number, number, number, number]
  • Converts a GskTransform 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 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.

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

  • to2dComponents(): [number, number, number, number, number, number, number]
  • Converts a GskTransform 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]

  • toAffine(): [number, number, number, number]
  • Converts a GskTransform 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]

  • Computes the actual value of self and stores it in out_matrix.

    The previous value of out_matrix will be ignored.

    Returns Graphene.Matrix

  • toString(): string
  • Converts a matrix into a string that is suitable for printing.

    The resulting string can be parsed with [funcGsk.Transform.parse].

    This is a wrapper around [methodGsk.Transform.print].

    Returns string

  • toTranslate(): [number, number]
  • Converts a GskTransform 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]

  • Transforms a graphene_rect_t using the given transform self.

    The result is the bounding box containing the coplanar quad.

    Parameters

    Returns Graphene.Rect

  • unref(): void
  • Releases a reference on the given GskTransform.

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

    Returns void

  • Parses the given string into a transform and puts it in out_transform.

    Strings printed via [methodGsk.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, Gsk.Transform]

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Type alias with type parameter
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method