TGUI
0.10-beta
|
Defines a transform matrix. More...
#include <TGUI/Transform.hpp>
Public Member Functions | |
Transform () | |
Default constructor. More... | |
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. More... | |
Transform (const float matrix[16]) | |
Constructs a transform from a 4x4 matrix. More... | |
const float * | getMatrix () const |
Return the transform as a 4x4 matrix. More... | |
Transform | getInverse () const |
Return the inverse of the transform. More... | |
Vector2f | transformPoint (const Vector2f &point) const |
Transform a 2D point. More... | |
FloatRect | transformRect (const FloatRect &rectangle) const |
Transform a rectangle. More... | |
Transform & | combine (const Transform &other) |
Combine the current transform with another one. More... | |
Transform & | translate (const Vector2f &offset) |
Combine the current transform with a translation. More... | |
Transform & | rotate (float angle, const Vector2f ¢er={0, 0}) |
Combine the current transform with a rotation. More... | |
Transform & | scale (const Vector2f &factors, const Vector2f ¢er={0, 0}) |
Combine the current transform with a scaling. More... | |
Transform | operator* (const Transform &right) const |
Overload of binary operator * to combine two transforms. More... | |
Transform & | operator*= (const Transform &right) |
Vector2f | operator* (const Vector2f &right) const |
void | roundPosition () |
Rounds the position stored in the transform to the nearest integer. | |
void | roundPositionForText () |
Rounds the position stored in the transform to the nearest integer. | |
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 float | matrix[16] | ) |
Constructs a transform from a 4x4 matrix.
matrix | Pointer to a 4x4 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 |
Transform tgui::Transform::getInverse | ( | ) | const |
Return the inverse of the transform.
If the inverse cannot be computed, an identity transform is returned.
const float * tgui::Transform::getMatrix | ( | ) | const |
Return the transform as a 4x4 matrix.
This function returns a pointer to 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 |
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 |