TGUI  0.9-beta
Transform.hpp
1 //
3 // TGUI - Texus' Graphical User Interface
4 // Copyright (C) 2012-2020 Bruno Van de Velde (vdv_b@tgui.eu)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24 
25 
26 #ifndef TGUI_TRANSFORM_HPP
27 #define TGUI_TRANSFORM_HPP
28 
30 
31 #include <TGUI/Config.hpp>
32 #include <TGUI/Rect.hpp>
33 
35 
36 namespace tgui
37 {
40  // Based on sf::Transform from SFML
42  class TGUI_API Transform
43  {
44  public:
45 
52 
53 
67  Transform(float a00, float a01, float a02,
68  float a10, float a11, float a12,
69  float a20, float a21, float a22);
70 
71 
77  Transform(const float matrix[16]);
78 
79 
92  const float* getMatrix() const;
93 
94 
103 
104 
112  Vector2f transformPoint(const Vector2f& point) const;
113 
114 
124  FloatRect transformRect(const FloatRect& rectangle) const;
125 
126 
137  Transform& combine(const Transform& other);
138 
139 
147  Transform& translate(const Vector2f& offset);
148 
149 
161  Transform& rotate(float angle, const Vector2f& center = {0, 0});
162 
163 
175  Transform& scale(const Vector2f& factors, const Vector2f& center = {0, 0});
176 
177 
185  Transform operator *(const Transform& right) const;
186  Transform& operator *=(const Transform& right);
187  Vector2f operator *(const Vector2f& right) const;
188 
189 
191  private:
192 
193  float m_matrix[16];
194  };
195 }
196 
198 
199 #endif // TGUI_TRANSFORM_HPP
Vector2f transformPoint(const Vector2f &point) const
Transform a 2D point.
Defines a transform matrix.
Definition: Transform.hpp:43
Namespace that contains all TGUI functions and classes.
Definition: AbsoluteOrRelativeValue.hpp:36
Transform()
Default constructor.
const float * getMatrix() const
Return the transform as a 4x4 matrix.
Transform & scale(const Vector2f &factors, const Vector2f &center={0, 0})
Combine the current transform with a scaling.
FloatRect transformRect(const FloatRect &rectangle) const
Transform a rectangle.
Transform & combine(const Transform &other)
Combine the current transform with another one.
Transform & rotate(float angle, const Vector2f &center={0, 0})
Combine the current transform with a rotation.
Transform getInverse() const
Return the inverse of the transform.
Transform(const float matrix[16])
Constructs a transform from a 4x4 matrix.
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 & translate(const Vector2f &offset)
Combine the current transform with a translation.