Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.

Transform2D

A 2×3 matrix representing a 2D transformation.

Description

A 2×3 matrix (2 rows, 3 columns) used for 2D linear transformations. It can represent transformations such as translation, rotation, and scaling. It consists of three Vector2 values: x, y, and the origin.

For a general introduction, see the Matrices and transforms tutorial.

Note

There are notable differences when using this API with C#. See C# API differences to GDScript for more information.

Tutorials

Properties

Vector2

origin

Vector2(0, 0)

Vector2

x

Vector2(1, 0)

Vector2

y

Vector2(0, 1)

Constructors

Transform2D

Transform2D()

Transform2D

Transform2D(from: Transform2D)

Transform2D

Transform2D(rotation: float, position: Vector2)

Transform2D

Transform2D(rotation: float, scale: Vector2, skew: float, position: Vector2)

Transform2D

Transform2D(x_axis: Vector2, y_axis: Vector2, origin: Vector2)

Methods

Transform2D

affine_inverse() const

Vector2

basis_xform(v: Vector2) const

Vector2

basis_xform_inv(v: Vector2) const

float

determinant() const

Vector2

get_origin() const

float

get_rotation() const

Vector2

get_scale() const

float

get_skew() const

Transform2D

interpolate_with(xform: Transform2D, weight: float) const

Transform2D

inverse() const

bool

is_conformal() const

bool

is_equal_approx(xform: Transform2D) const

bool

is_finite() const

Transform2D

looking_at(target: Vector2 = Vector2(0, 0)) const

Transform2D

orthonormalized() const

Transform2D

rotated(angle: float) const

Transform2D

rotated_local(angle: float) const

Transform2D

scaled(scale: Vector2) const

Transform2D