Defines a transform matrix.
More...
#include <TGUI/Transform.hpp>
|
| | Transform () |
| | Default constructor.
|
| | Transform (float a00, float a01, float a02, float a10, float a11, float a12, float a20, float a21, float a22) |
| | Construct a transform from a 3x3 matrix.
|
| | Transform (const std::array< float, 16 > &matrix) |
| | Constructs a transform from a 4x4 matrix.
|
| const std::array< float, 16 > & | getMatrix () const |
| | Return the transform as a 4x4 matrix.
|
| Transform | getInverse () const |
| | Return the inverse of the transform.
|
| Vector2f | transformPoint (const Vector2f &point) const |
| | Transform a 2D point.
|
| FloatRect | transformRect (const FloatRect &rectangle) const |
| | Transform a rectangle.
|
| Transform & | combine (const Transform &other) |
| | Combine the current transform with another one.
|
| Transform & | translate (const Vector2f &offset) |
| | Combine the current transform with a translation.
|
| Transform & | rotate (float angle, const Vector2f ¢er={0, 0}) |
| | Combine the current transform with a rotation.
|
| Transform & | scale (const Vector2f &factors, const Vector2f ¢er={0, 0}) |
| | Combine the current transform with a scaling.
|
| Transform | operator* (const Transform &right) const |
| | Overload of binary operator * to combine two transforms.
|
|
Transform & | operator*= (const Transform &right) |
|
Vector2f | operator* (const Vector2f &right) const |
| void | roundPosition (float pixelScaleX, float pixelScaleY) |
| | Rounds the position stored in the transform to the nearest pixel.
|
| void | roundPosition (Vector2f pixelScale) |
| | Rounds the position stored in the transform to the nearest pixel.
|
Defines a transform matrix.
◆ Transform() [1/3]
| tgui::Transform::Transform |
( |
| ) |
|
Default constructor.
Creates an identity transform (a transform that does nothing).
◆ Transform() [2/3]
| tgui::Transform::Transform |
( |
float | a00, |
|
|
float | a01, |
|
|
float | a02, |
|
|
float | a10, |
|
|
float | a11, |
|
|
float | a12, |
|
|
float | a20, |
|
|
float | a21, |
|
|
float | a22 ) |
Construct a transform from a 3x3 matrix.
- Parameters
-
| a00 | Element (0, 0) of the 3x3 matrix |
| a01 | Element (0, 1) of the 3x3 matrix |
| a02 | Element (0, 2) of the 3x3 matrix |
| a10 | Element (1, 0) of the 3x3 matrix |
| a11 | Element (1, 1) of the 3x3 matrix |
| a12 | Element (1, 2) of the 3x3 matrix |
| a20 | Element (2, 0) of the 3x3 matrix |
| a21 | Element (2, 1) of the 3x3 matrix |
| a22 | Element (2, 2) of the 3x3 matrix |
◆ Transform() [3/3]
| tgui::Transform::Transform |
( |
const std::array< float, 16 > & | matrix | ) |
|
Constructs a transform from a 4x4 matrix.
- Parameters
-
| matrix | 4x4 transform matrix, similar to what getMatrix returns |
◆ combine()
Combine the current transform with another one.
The result is a transform that is equivalent to applying the other transform followed by this transform. Mathematically, it is equivalent to a matrix multiplication (*this) * other.
- Parameters
-
| other | Transform to combine with this transform |
- Returns
- Reference to *this
◆ getInverse()
| Transform tgui::Transform::getInverse |
( |
| ) |
const |
|
nodiscard |
Return the inverse of the transform.
- Returns
- A new transform which is the inverse of this transform
If the inverse cannot be computed, an identity transform is returned.
◆ getMatrix()
| const std::array< float, 16 > & tgui::Transform::getMatrix |
( |
| ) |
const |
|
nodiscard |
Return the transform as a 4x4 matrix.
This function returns an array of 16 floats containing the transform elements as a 4x4 matrix, which is directly compatible with OpenGL functions.
glLoadMatrixf(transform.getMatrix().data());
- Returns
- 4x4 transform matrix
◆ operator*()
Overload of binary operator * to combine two transforms.
- Parameters
-
| right | Transform to combine with a copy of this transform |
- See also
- combine
◆ rotate()
| Transform & tgui::Transform::rotate |
( |
float | angle, |
|
|
const Vector2f & | center = {0, 0} ) |
Combine the current transform with a rotation.
The center of rotation is provided for convenience as a second argument, so that you can build rotations around arbitrary points more easily (and efficiently) than the usual translate(-center).rotate(angle).translate(center).
- Parameters
-
| angle | Rotation angle, in degrees |
| center | Center of rotation |
- Returns
- Reference to *this
◆ roundPosition() [1/2]
| void tgui::Transform::roundPosition |
( |
float | pixelScaleX, |
|
|
float | pixelScaleY ) |
Rounds the position stored in the transform to the nearest pixel.
- Parameters
-
| pixelScaleX | Pixels per point horizontally |
| pixelScaleY | Pixels per point vertically |
◆ roundPosition() [2/2]
| void tgui::Transform::roundPosition |
( |
Vector2f | pixelScale | ) |
|
Rounds the position stored in the transform to the nearest pixel.
- Parameters
-
| pixelScale | Pixels per point, both horizontally and vertically |
◆ scale()
| Transform & tgui::Transform::scale |
( |
const Vector2f & | factors, |
|
|
const Vector2f & | center = {0, 0} ) |
Combine the current transform with a scaling.
The center of scaling is provided for convenience as a second argument, so that you can build scaling around arbitrary points more easily (and efficiently) than the usual translate(-center).scale(factors).translate(center).
- Parameters
-
| factors | Scaling factors |
| center | Center of scaling |
- Returns
- Reference to *this
◆ transformPoint()
| Vector2f tgui::Transform::transformPoint |
( |
const Vector2f & | point | ) |
const |
|
inlinenodiscard |
Transform a 2D point.
- Parameters
-
- Returns
- Transformed point
◆ transformRect()
| FloatRect tgui::Transform::transformRect |
( |
const FloatRect & | rectangle | ) |
const |
|
nodiscard |
Transform a rectangle.
If the transform contains a rotation, the bounding rectangle of the transformed rectangle is returned.
- Parameters
-
| rectangle | Rectangle to transform |
- Returns
- Transformed rectangle
◆ translate()
| Transform & tgui::Transform::translate |
( |
const Vector2f & | offset | ) |
|
Combine the current transform with a translation.
- Parameters
-
| offset | Translation offset to apply |
- Returns
- Reference to *this
The documentation for this class was generated from the following file: