Class Transform2D

Transform2D metatype, wrapper for godot_transform2d.

Constructed using the idiom Transform2D(...), which calls __new.

typedef union godot_transform2d {
    uint8_t data[24];
    float elements[6];
    Vector2 columns[3];
    struct { Vector2 x, y, origin; };
} godot_transform2d;

Methods

Transform2D:affine_inverse () Returns the inverse of the transform, under the assumption that the transformation is composed of rotation, scaling and translation.
Transform2D:basis_xform_inv (vector) Returns a vector transformed (multiplied) by the inverse basis matrix.
Transform2D:basis_xform_vector2 (vector) Returns a vector transformed (multiplied) by the basis matrix.
Transform2D:get_origin () Returns the transform's origin (translation).
Transform2D:get_rotation () Returns the transform's rotation (in radians).
Transform2D:get_scale () Returns the scale.
Transform2D:interpolate_with (transform, weight) Returns a transform interpolated between this transform and another by a given weight (on the range of 0.0 to 1.0).
Transform2D:inverse () Returns the inverse of the transform, under the assumption that the transformation is composed of rotation and translation (no scaling, use affine_inverse for transforms with scaling).
Transform2D:orthonormalized () Returns the transform with the basis orthogonal (90 degrees), and normalized axis vectors (scale of 1 or -1).
Transform2D:rotated (angle) Rotates the transform by the given angle (in radians), using matrix multiplication.
Transform2D:scaled (scale) Scales the transform by the given scale factor, using matrix multiplication.
Transform2D:translated (offset) Translates the transform by the given offset, relative to the transform's basis vectors.
Transform2D:xform (value) Transforms the given Vector2, Rect2, or PoolVector2Array by this transform.
Transform2D:xform_inv (value) Inverse-transforms the given Vector2, Rect2, or PoolVector2Array by this transform.
Transform2D:xform_inv_rect2 (vector) Inverse-transforms the given Rect2.
Transform2D:xform_inv_vector2 (vector) Inverse-transforms the given Vector2.
Transform2D:xform_rect2 (vector) Transforms the given Rect2.
Transform2D:xform_vector2 (vector) Transforms the given Vector2.

Metamethods

Transform2D:__concat (a, b) Concatenates values.
Transform2D:__eq (a, b) Equality operation If either a or b are not of type Transform2D, always return false.
Transform2D:__mul (self, b) Multiplication operation.
Transform2D:__new (...) Transform2D constructor, called by the idiom Transform2D(...).
Transform2D:__tostring () Returns a Lua string representation of this transform.

Constants

Transform2D.FLIP_X The Transform2D that will flip something along the X axis.
Transform2D.FLIP_Y The Transform2D that will flip something along the Y axis.
Transform2D.IDENTITY The identity Transform2D with no translation, rotation or scaling applied.


Methods

Transform2D:affine_inverse ()
Returns the inverse of the transform, under the assumption that the transformation is composed of rotation, scaling and translation.

Returns:

    Transform2D
Transform2D:basis_xform_inv (vector)
Returns a vector transformed (multiplied) by the inverse basis matrix. This method does not account for translation (the origin vector).

Parameters:

Returns:

    Vector2
Transform2D:basis_xform_vector2 (vector)
Returns a vector transformed (multiplied) by the basis matrix. This method does not account for translation (the origin vector).

Parameters:

Returns:

    Vector2
Transform2D:get_origin ()
Returns the transform's origin (translation).

Returns:

    Vector2
Transform2D:get_rotation ()
Returns the transform's rotation (in radians).

Returns:

    number
Transform2D:get_scale ()
Returns the scale.

Returns:

    Vector2
Transform2D:interpolate_with (transform, weight)
Returns a transform interpolated between this transform and another by a given weight (on the range of 0.0 to 1.0).

Parameters:

Transform2D:inverse ()
Returns the inverse of the transform, under the assumption that the transformation is composed of rotation and translation (no scaling, use affine_inverse for transforms with scaling).

Returns:

    Transform2D

See also:

Transform2D:orthonormalized ()
Returns the transform with the basis orthogonal (90 degrees), and normalized axis vectors (scale of 1 or -1).

Returns:

    Transform2D
Transform2D:rotated (angle)
Rotates the transform by the given angle (in radians), using matrix multiplication.

Parameters:

  • angle number

Returns:

    Transform2D
Transform2D:scaled (scale)
Scales the transform by the given scale factor, using matrix multiplication.

Parameters:

Returns:

    Transform2D
Transform2D:translated (offset)
Translates the transform by the given offset, relative to the transform's basis vectors. Unlike rotated and scaled, this does not use matrix multiplication.

Parameters:

Returns:

    Transform2D
Transform2D:xform (value)
Transforms the given Vector2, Rect2, or PoolVector2Array by this transform.

Parameters:

Returns:

    Vector2, Rect2 or PoolVector2Array Transformed value
Transform2D:xform_inv (value)
Inverse-transforms the given Vector2, Rect2, or PoolVector2Array by this transform.

Parameters:

Returns:

    Vector2, Rect2 or PoolVector2Array Transformed value
Transform2D:xform_inv_rect2 (vector)
Inverse-transforms the given Rect2.

Parameters:

Returns:

    Rect2

See also:

Transform2D:xform_inv_vector2 (vector)
Inverse-transforms the given Vector2.

Parameters:

Returns:

    Vector2

See also:

Transform2D:xform_rect2 (vector)
Transforms the given Rect2.

Parameters:

Returns:

    Rect2

See also:

Transform2D:xform_vector2 (vector)
Transforms the given Vector2.

Parameters:

Returns:

    Vector2

See also:

Metamethods

Transform2D:__concat (a, b)
Concatenates values.

Parameters:

  • a First value, stringified with GD.str
  • b First value, stringified with GD.str

Returns:

    String
Transform2D:__eq (a, b)
Equality operation If either a or b are not of type Transform2D, always return false.

Parameters:

Returns:

    bool
Transform2D:__mul (self, b)
Multiplication operation. Either multiply another Transform2D or xform value.

Parameters:

Returns:

    Transform2D, Vector2, Rect2 or PoolVector2Array Transformed value
Transform2D:__new (...)

Transform2D constructor, called by the idiom Transform2D(...).

  • Transform2D(): creates an IDENTITY transform.
  • Transform2D(number angle, Vector2 position): constructs the transform from a given angle (in radians) and position.
  • Transform2D(Vector2 x, Vector2 y, Vector2 origin): constructs the transform from the three column vectors.
  • Transform2D(Transform2D other): returns a copy of other

Parameters:

  • ...

Returns:

    Transform2D
Transform2D:__tostring ()
Returns a Lua string representation of this transform.

Returns:

    string

Constants

Transform2D.FLIP_X
The Transform2D that will flip something along the X axis.
  • FLIP_X Transform2D(-1, 0, 0, 1, 0, 0)
Transform2D.FLIP_Y
The Transform2D that will flip something along the Y axis.
  • FLIP_Y Transform2D(1, 0, 0, -1, 0, 0)
Transform2D.IDENTITY
The identity Transform2D with no translation, rotation or scaling applied.
  • IDENTITY Transform2D(1, 0, 0, 1, 0, 0)
generated by LDoc 1.4.6 Last updated 2023-01-04 08:52:34