Transform.hpp
1 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2014 Laurent Gomila (laurent.gom@gmail.com)
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 #ifndef CPP3DS_TRANSFORM_HPP
26 #define CPP3DS_TRANSFORM_HPP
27 
29 // Headers
31 #include <cpp3ds/Graphics/Rect.hpp>
32 #include <cpp3ds/System/Vector2.hpp>
33 
34 
35 namespace cpp3ds
36 {
41 class Transform
42 {
43 public :
44 
51  Transform();
52 
67  Transform(float a00, float a01, float a02,
68  float a10, float a11, float a12,
69  float a20, float a21, float a22);
70 
86  const float* getMatrix() const;
87 
97  Transform getInverse() const;
98 
108  Vector2f transformPoint(float x, float y) const;
109 
118  Vector2f transformPoint(const Vector2f& point) const;
119 
134  FloatRect transformRect(const FloatRect& rectangle) const;
135 
148  Transform& combine(const Transform& transform);
149 
168  Transform& translate(float x, float y);
169 
187  Transform& translate(const Vector2f& offset);
188 
206  Transform& rotate(float angle);
207 
232  Transform& rotate(float angle, float centerX, float centerY);
233 
257  Transform& rotate(float angle, const Vector2f& center);
258 
277  Transform& scale(float scaleX, float scaleY);
278 
304  Transform& scale(float scaleX, float scaleY, float centerX, float centerY);
305 
323  Transform& scale(const Vector2f& factors);
324 
348  Transform& scale(const Vector2f& factors, const Vector2f& center);
349 
351  // Static member data
353  static const Transform Identity;
354 
355 private:
356 
358  // Member data
360  float m_matrix[16];
361 };
362 
375 Transform operator *(const Transform& left, const Transform& right);
376 
389 Transform& operator *=(Transform& left, const Transform& right);
390 
403 Vector2f operator *(const Transform& left, const Vector2f& right);
404 
405 } // namespace sf
406 
407 
408 #endif // SFML_TRANSFORM_HPP
409 
410 
FloatRect transformRect(const FloatRect &rectangle) const
Transform a rectangle.
Vector2f transformPoint(float x, float y) const
Transform a 2D point.
const float * getMatrix() const
Return the transform as a 4x4 matrix.
Transform & scale(float scaleX, float scaleY)
Combine the current transform with a scaling.
Transform getInverse() const
Return the inverse of the transform.
Transform & rotate(float angle)
Combine the current transform with a rotation.
Transform()
Default constructor.
Transform & translate(float x, float y)
Combine the current transform with a translation.
static const Transform Identity
The identity transform (does nothing)
Definition: Transform.hpp:353
Define a 3x3 transform matrix.
Definition: Transform.hpp:41
Transform & combine(const Transform &transform)
Combine the current transform with another one.