Transform2
Transform2 represents a 2D transform that combines translation, rotation, and non-uniform scaling around an arbitrary pivot point. It lazily builds a Matrix3 suitable for use in 2D rendering pipelines and UI layouts.
Properties
Pivot point for rotation and scaling, in local units.
For a texture transform the units are texture coordinates, so (0.5, 0.5) is the middle of the texture. For a canvas node the units are pixels.
Vector2 pivot {0.0f, 0.0f};rotation float
Rotation angle in radians.
float rotation {0.0f};touched bool
Dirty flag indicating the cached matrix needs to be recomputed.
bool touched {true};Functions
Returns the 3×3 transform matrix.
Recomputes the underlying matrix if any component has changed since the last call, then returns the cached Matrix3.
Matrix3 Transform2::Get();Returns the 3×3 transform matrix without updating the cache.
Computes the matrix on the fly if any component has changed since the last update, otherwise returns the cached Matrix3. The touched flag is not cleared, so a later non-const call still refreshes the cache.
Matrix3 Transform2::Get() const;Rotate() void
Applies an additional rotation.
void Transform2::Rotate(float angle);| Parameter | Description |
|---|---|
| angle | Rotation angle in radians to add. |
Scale() void
Scales the transform.
void Transform2::Scale(const Vector2& value);| Parameter | Description |
|---|---|
| value | Scale factors to apply. |
SetPivot() void
Sets the pivot point used for rotation and scaling.
void Transform2::SetPivot(const Vector2& pivot);| Parameter | Description |
|---|---|
| pivot | New pivot point. |
SetPosition() void
Sets the translation component.
void Transform2::SetPosition(const Vector2& position);| Parameter | Description |
|---|---|
| position | New position. |
SetRotation() void
Sets the rotation component.
void Transform2::SetRotation(float rotation);| Parameter | Description |
|---|---|
| rotation | New rotation angle in radians. |
SetScale() void
Sets the scale component.
void Transform2::SetScale(const Vector2& scale);| Parameter | Description |
|---|---|
| scale | New scale factors. |