TGUI
1.6.1
|
Defines a transform matrix. More...
#include <TGUI/Transform.hpp>
Public Member Functions | |
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.
tgui::Transform::Transform | ( | ) |
Default constructor.
Creates an identity transform (a transform that does nothing).
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.
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 |
tgui::Transform::Transform | ( | const std::array< float, 16 > & | matrix | ) |
Constructs a transform from a 4x4 matrix.
matrix | 4x4 transform matrix, similar to what getMatrix returns |
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.
other | Transform to combine with this transform |
|
nodiscard |
Return the inverse of the transform.
If the inverse cannot be computed, an identity transform is returned.
|
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.
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).
angle | Rotation angle, in degrees |
center | Center of rotation |
void tgui::Transform::roundPosition | ( | float | pixelScaleX, |
float | pixelScaleY ) |
Rounds the position stored in the transform to the nearest pixel.
pixelScaleX | Pixels per point horizontally |
pixelScaleY | Pixels per point vertically |
void tgui::Transform::roundPosition | ( | Vector2f | pixelScale | ) |
Rounds the position stored in the transform to the nearest pixel.
pixelScale | Pixels per point, both horizontally and vertically |
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).
factors | Scaling factors |
center | Center of scaling |
Transform a rectangle.
If the transform contains a rotation, the bounding rectangle of the transformed rectangle is returned.
rectangle | Rectangle to transform |
Combine the current transform with a translation.
offset | Translation offset to apply |