Documentation de SFML 2.6.1

Attention: cette page se réfère à une ancienne version de SFML. Cliquez ici pour passer à la dernière version.
Loading...
Searching...
No Matches
Transform.hpp
1
2//
3// SFML - Simple and Fast Multimedia Library
4// Copyright (C) 2007-2023 Laurent Gomila (laurent@sfml-dev.org)
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 SFML_TRANSFORM_HPP
26#define SFML_TRANSFORM_HPP
27
29// Headers
31#include <SFML/Graphics/Export.hpp>
32#include <SFML/Graphics/Rect.hpp>
33#include <SFML/System/Vector2.hpp>
34
35
36namespace sf
37{
42class SFML_GRAPHICS_API Transform
43{
44public:
45
53
68 Transform(float a00, float a01, float a02,
69 float a10, float a11, float a12,
70 float a20, float a21, float a22);
71
87 const float* getMatrix() const;
88
99
115 Vector2f transformPoint(float x, float y) const;
116
131 Vector2f transformPoint(const Vector2f& point) const;
132
147 FloatRect transformRect(const FloatRect& rectangle) const;
148
167 Transform& combine(const Transform& transform);
168
187 Transform& translate(float x, float y);
188
206 Transform& translate(const Vector2f& offset);
207
225 Transform& rotate(float angle);
226
251 Transform& rotate(float angle, float centerX, float centerY);
252
276 Transform& rotate(float angle, const Vector2f& center);
277
296 Transform& scale(float scaleX, float scaleY);
297
323 Transform& scale(float scaleX, float scaleY, float centerX, float centerY);
324
342 Transform& scale(const Vector2f& factors);
343
367 Transform& scale(const Vector2f& factors, const Vector2f& center);
368
370 // Static member data
372 static const Transform Identity;
373
374private:
375
377 // Member data
379 float m_matrix[16];
380};
381
394SFML_GRAPHICS_API Transform operator *(const Transform& left, const Transform& right);
395
408SFML_GRAPHICS_API Transform& operator *=(Transform& left, const Transform& right);
409
422SFML_GRAPHICS_API Vector2f operator *(const Transform& left, const Vector2f& right);
423
437SFML_GRAPHICS_API bool operator ==(const Transform& left, const Transform& right);
438
451SFML_GRAPHICS_API bool operator !=(const Transform& left, const Transform& right);
452
453} // namespace sf
454
455
456#endif // SFML_TRANSFORM_HPP
457
458
Define a 3x3 transform matrix.
Definition Transform.hpp:43
Transform & translate(float x, float y)
Combine the current transform with a translation.
Transform & rotate(float angle, const Vector2f &center)
Combine the current transform with a rotation.
Transform getInverse() const
Return the inverse of the transform.
Transform & scale(const Vector2f &factors)
Combine the current transform with a scaling.
Transform & translate(const Vector2f &offset)
Combine the current transform with a translation.
FloatRect transformRect(const FloatRect &rectangle) const
Transform a rectangle.
Transform & scale(const Vector2f &factors, const Vector2f &center)
Combine the current transform with a scaling.
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 & scale(float scaleX, float scaleY)
Combine the current transform with a scaling.
static const Transform Identity
The identity transform (does nothing)
Vector2f transformPoint(const Vector2f &point) const
Transform a 2D point.
const float * getMatrix() const
Return the transform as a 4x4 matrix.
Transform()
Default constructor.
Transform & rotate(float angle)
Combine the current transform with a rotation.
Transform & rotate(float angle, float centerX, float centerY)
Combine the current transform with a rotation.
Transform & combine(const Transform &transform)
Combine the current transform with another one.
Transform & scale(float scaleX, float scaleY, float centerX, float centerY)
Combine the current transform with a scaling.
Vector2f transformPoint(float x, float y) const
Transform a 2D point.