- Qt 6.12
- Qt Canvas Painter
- QML Types
- transform2d
- Qt Canvas Painter | Commercial or GPLv3

# transform2d QML Value Type

Provides transform2d type,a 3x3 2D transformation matrix, matching to QTransform. More...

Import Statement: | `import QtCanvas2D`
Since: | Qt 6.12
Status: | Technology preview

This type is in technology preview and is subject to change.

## Methods

- real m11()
- real m12()
- real m13()
- real m21()
- real m22()
- real m23()
- real m31()
- real m32()
- real m33()
- real determinant()
- transform2d inverted()
- void reset()
- void rotate(real angle)
- void rotateRadians(real angle)
- void scale(real scale)
- void scale(real sx, real sy)
- void setMatrix(real m11, real m12, real m21, real m22, real m31, real m32)
- void setMatrix(real m11, real m12, real m13, real m21, real m22, real m23, real m31, real m32, real m33)
- void shear(real sh, real sv)
- transform2d times(real factor)
- transform2d times(transform2d other)
- void translate(real dx, qreal dy)
- transform2d transposed()

## Detailed Description

A `transform2d` type has nine values, each accessible via the properties `m11` through `m33` in QML (in row/column order).

A property of type `transform2d` defaults to the identity matrix, whose diagonal entries `m11`, `m22` and `m33` are all `1`, with all other components `0`.

This value type is provided by the QtCanvas2D import.

See also QTransform.

## Method Documentation

### real m11()

Returns the horizontal scaling factor.

### real m12()

Returns the vertical shearing factor.

### real m13()

Returns the horizontal projection factor.

### real m21()

Returns the horizontal shearing factor.

### real m22()

Returns the vertical scaling factor.

### real m23()

Returns the vertical projection factor.

### real m31()

Returns the horizontal translation factor.

### real m32()

Returns the vertical translation factor.

### real m33()

Returns the division factor.

### real determinant()

Returns the determinant of this transform2d.

### transform2d inverted()

Returns the inverse of this transform2d if it exists, else the identity matrix.

### void reset()

Resets the matrix to an identity matrix, i.e. all elements are set to zero, except m11 and m22 (specifying the scale) and m33 which are set to 1.

### void rotate(real angle)

Rotates the coordinate system counterclockwise by the given angle in degrees.

### void rotateRadians(real angle)

Rotates the coordinate system counterclockwise by the given angle in radians.

### void scale(real scale)

Scales the coordinate system by scale both horizontally and vertically.

### void scale(real sx, real sy)

Scales the coordinate system by sx horizontally and sy vertically.

### void setMatrix(real m11, real m12, real m21, real m22, real m31, real m32)

Sets the matrix elements to the specified values, m11, m12, m21, m22, m31 and m32. Note that this function replaces the previous values.

### void setMatrix(real m11, real m12, real m13, real m21, real m22, real m23, real m31, real m32, real m33)

Sets the matrix elements to the specified values, m11, m12, m13 m21, m22, m23 m31, m32 and m33. Note that this function replaces the previous values.

### void shear(real sh, real sv)

Shears the coordinate system by sh horizontally and sv vertically.

### transform2d times(real factor)

Returns the transform2d result of multiplying this transform2d with the scalar factor.

### transform2d times(transform2d other)

Returns the transform2d result of multiplying this transform2d with the other transform2d.

### void translate(real dx, qreal dy)

Moves the coordinate system dx along the x axis and dy along the y axis.

### transform2d transposed()

Returns the transpose of this transform2d.